# HG changeset patch # User Oleksandr Gavenko # Date 1235327113 -7200 # Node ID 70c9abe044cf0772efb98713ed7f4c8d9f446788 # Parent d9f385e0aa0479e41631f03eaf5cc36274fb4ae0# Parent 668e8fc73f20de36d886e2d9e55cc23b1fac9853 merge diff -r 668e8fc73f20 -r 70c9abe044cf apache.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apache.rst Sun Feb 22 20:25:13 2009 +0200 @@ -0,0 +1,13 @@ +-*- outline -*- + +* How reread config file? + +For Linux + + $ /etc/init.d/apache2 restart + +or for FreeBSD + + $ /usr/local/etc/rc.d/apache2 restart + + diff -r 668e8fc73f20 -r 70c9abe044cf bash.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bash.rst Sun Feb 22 20:25:13 2009 +0200 @@ -0,0 +1,16 @@ +-*- outline -*- + +* How override PS1, PS2? + +When loading bash read ~/.bash_profile and ~/.bashrc. + +Put at end of these files + + PS1='\u@\H$ ' + +When xterm start bash - it start as nonlogin. So ~/.bash_profile and ~/.bashrc +didn't read. To workaround this use + + $ xterm -e bash -i -c "mc -x" + +That make bash interactive and init file readed. diff -r 668e8fc73f20 -r 70c9abe044cf date.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/date.rst Sun Feb 22 20:25:13 2009 +0200 @@ -0,0 +1,52 @@ +-*- outline -*- + +* Getting current date/time. + + $ date +"%Y-%m-%d %H:%M:%S" + +* Setting current date/time. + + $ sudo date --set="2009-02-22 12:12:00" +"%Y-%m-%d %H:%M:%S" + +Or set utc time: + + $ sudo date --utc --set="2009-02-22 12:12:00" +"%Y-%m-%d %H:%M:%S" + +and then timezone: + + $ sudo tzconfig +Your current time zone is set to Europe/Kiev +Do you want to change that? [n]: y + +Please enter the number of the geographic area in which you live: + + 1) Africa 7) Australia + 2) America 8) Europe + 3) US time zones 9) Indian Ocean + 4) Canada time zones 10) Pacific Ocean + 5) Asia 11) Use System V style time zones + 6) Atlantic Ocean 12) None of the above + +Number: 8 + +Then you will be shown a list of cities which represent the time zone +in which they are located. You should choose a city in your time zone. + +Amsterdam Andorra Athens Belfast Belgrade Berlin Bratislava Brussels +Bucharest Budapest Chisinau Copenhagen Dublin Gibraltar Guernsey Helsinki +Isle_of_Man Istanbul Jersey Kaliningrad Kiev Lisbon Ljubljana London +Luxembourg Madrid Malta Mariehamn Minsk Monaco Moscow Nicosia Oslo Paris +Podgorica Prague Riga Rome Samara San_Marino Sarajevo Simferopol Skopje +Sofia Stockholm Tallinn Tirane Tiraspol Uzhgorod Vaduz Vatican Vienna +Vilnius Volgograd Warsaw Zagreb Zaporozhye Zurich + +Please enter the name of one of these cities or zones +You just need to type enough letters to resolve ambiguities +Press Enter to view all of them again + +Name: [] Kiev + +Your default time zone is set to 'Europe/Kiev'. +Local time is now: Sun Feb 22 12:40:16 EET 2009. +Universal Time is now: Sun Feb 22 10:40:16 UTC 2009. +Your current time zone is set to Europe/Kiev diff -r 668e8fc73f20 -r 70c9abe044cf dns.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dns.rst Sun Feb 22 20:25:13 2009 +0200 @@ -0,0 +1,7 @@ +-*- outline -*- + +* How reread config file? + +** FreeBSD. + + $ named.reload diff -r 668e8fc73f20 -r 70c9abe044cf port.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/port.rst Sun Feb 22 20:25:13 2009 +0200 @@ -0,0 +1,92 @@ +-*- outline -*- + +* Port forwarding. + + $ ssh -L 8888:www.linuxhorizon.ro:80 user@computer -N + $ ssh -L 8888:www.linuxhorizon.ro:80 -L 110:mail.linuxhorizon.ro:110 \ + 25:mail.linuxhorizon.ro:25 user@computer -N + +The second example (see above) show you how to setup your ssh tunnel for web, pop3 +and smtp. It is useful to recive/send your e-mails when you don't have direct access +to the mail server. + +For the ASCII art and lynx browser fans here is illustrated the first example: + + +----------+<--port 22-->+----------+<--port 80-->o-----------+ + |SSH Client|-------------|ssh_server|-------------| host | + +----------+ +----------+ o-----------+ + localhost:8888 computer www.linuxhorizon.ro:80 + +* Port listening. + +Connect to a server: + + $ nc hostname port + +Be a server: + + $ nc -l -p port + +* Simple filetransfer. + +Serve a file: + + $ nc -l -p port < file + +Receive a file: + + $ nc hostname port > file + +* Filesystem cloning. + +Serve the filesystem: + + $ tar cOPp --same-owner / | nc -l -p port + +Receive the filesystem: + + $ nc -w3 hostname port | tar xPp + +* Disk cloning. + +Serve the disk image: + + $ dd if=/dev/hda | nc -l -p port + +Receive the image: + + $ nc -w3 hostname port | dd of=/dev/hda + +* Encrypted, compressed and IP restricted filetransfer. + +If combining encryption and compression, be sure to compress first then +encrypt when sending and reverse the order for receiving. Do not attempt to +encrypt then compress. Compression works by finding patterns which are +destroyed intentionally by the process of encryption. Also, though not +required, specifying the IP address of the host that will be transferring the +file is a good idea. + +Serving a compresssed, encrypted file from 192.168.0.1 to 192.168.0.2: + + $ gzip -c < file | openssl aes-128-cbc -e -k thispassword | nc -l 192.168.0.2 12345 + +Receiving, decrypting and decompressing that file: + + $ nc 192.168.0.1 12345 | openssl aes-128-cbc -d -k thispassword | gunzip -c > file + +* Scan with nmap. + +TODO + +* Scan with netcat. + + $ nc -v -w 2 -z hostname portrange + $ nc -v -w 2 -z hostname portlisting + +Where portrange is for example "10-20" to scan all ports between 10 and 20, +portlisting is for example 11,20,135 will scan these ports. + +I just tried this on windows xp, and the comma separated list of ports does +NOT work. Instead, use space separated list. eg: + + cmd> nc.exe -vv -w 2 -z www.example.com 20-25 79 80 110 137-139 443 diff -r 668e8fc73f20 -r 70c9abe044cf user-management.rst --- a/user-management.rst Mon Feb 16 21:35:39 2009 +0200 +++ b/user-management.rst Sun Feb 22 20:25:13 2009 +0200 @@ -1,10 +1,10 @@ -*- outline -*- -*Solaris +* Solaris. Add new user: - $ useradd -d /export/home/fred -m -s /bin/ksh -c "Fred Smith" fred + $ useradd -d /export/home/fred -m -s /bin/ksh -c "Fred Smith" fred where -d path to HOME dir, -m make home directory and copy the default skeleton files, -s your favourite shell, -c your full name. @@ -13,4 +13,17 @@ Change attribute already existing user: - $ usermod -d /export/home/new-home-dir -s /usr/bin/bash + $ usermod -d /export/home/new-home-dir -s /usr/bin/bash + +* FreeBSD. + +Add existing user to group: + + $ pw usermod user-name -G to-group + +Add a new user to group: + + $ pw useradd jerry -G sales + $ passwd jerry + + diff -r 668e8fc73f20 -r 70c9abe044cf windows.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windows.rst Sun Feb 22 20:25:13 2009 +0200 @@ -0,0 +1,42 @@ +-*- outline -*- + +* Vista and Samba. + +By default, you cannot authenticate and share files to and from Mac OS X or +Linux Samba due to a well known authentication method turned off by default. +To enable this, + +** Only for Windows Vista Ultimate/Business/Enterprise Editions. + +Goto Start—>Run and open gpedit.msc or secpol.msc + +Select Continue on the User Account Control prompt. This will launch the Group +Policy Object Editor for the Local Computer Policy. + +In the Group Policy Object Editor, expand: + +-> Computer Configuration +-> Windows Settings +-> Security Settings +-> Local Policies +-> Security Options + +Open the ‘Network security: LAN Manager authentication level’ policy and +change the Security Setting to: + +Send LM & NTLM - use NTLMv2 session security if negotiated + +** Windows Vista Home Edition. + +Since Windows Vista Home Edition does not feature the Group Policy Editor, you +may do the following to enable this feature: + +Goto Start—>Run—> and type regedit. + +Select Continue on the User Account Control prompt. + +Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa + +Create the following DWORD value (if it doesn’t exist): LmCompatibilityLevel + +And set its value to: 1