Networking notes
How to change MAC (hardware) address of NIC (network interface card)
$ ifconfig eth0 down $ ifconfig eth0 hw ether 00:ab:cd:ef:12:34 # new MAC address $ ifconfig eth0 up $ ifconfig eth0 | grep HWaddr # check new MAC address
Sparse files
How to create ~20GB sparse file
A few days ago, I wanted to download some files using DC network via Linux DC++. The problem was, that I had a borrowed laptop with no files to share, so I decided to create a faked file – in my case sparse file.
This Unix-like command creates ~20GB sparse file. To be clear, it’s file size seems to be 20GB for most of applications (including Linux DC++), but in real it’s only about a few bytes long, just because of “seek”. Zeros needn’t to be physically stored in the harddisk, they’re simply seeked.
$ dd if=/dev/zero of=<FILE> bs=1 count=0 seek=20480M
Sparse files are available on most of Unix-like file systems. Microsoft implements sparse files since release of NTFS (fsutil).
Subversion commands (svn)
SVN Update
svn update – Bring changes from the repository into your working copy.
$ svn update [-r <REV>] [<PATH>]
Usage examples:
$ svn update # update the whole working copy to the latest revision $ svn update doc/ # update doc/ directory to the latest revision $ svn update -r 128 # update (revert) the whole working copy to revision #128 $ svn update -r 56 stack.h stack.c # update (revert) stack.h and stack.c files to revision #56
SVN Merge
svn merge – Apply the differences between two sources to a working copy path.
$ svn merge -r <FROM_REV>:<TO_REV> [<PATH>]
Usage examples:
$ svn merge -r 58:56 stack.h # undo stack.h file changes from revision #58 to revision #56
Transfer files using Secure Copy (scp)
Transfer file/directory from remote host to localhost:
$ scp [<USER>@]<HOST>:<REMOTE_PATH> <LOCAL_PATH>
Usage example:
$ scp v-teq@v-teq.com:~/.vimrc ~/.vimrc # copy .vimrc file from remote host to the local one $ scp user@example.com:/etc/resolv.conf /tmp/dns.txt
Transfer file from localhost to remote host:
$ scp <file/directory> user@example.com:~/remote/directory
Transfer file/directory from localhost to remote host:
$ scp file.txt user@example.com:~/remote/directory
Screen
screen – screen manager with VT100/ANSI terminal emulation
Create new screen window
$ screen # open screen manager with new window
^A c # create new window
Kill screen window
^A k // kill current window ^A :quit // kill all the session (also ^A ^\)
Detach screen session
$ screen -d
^A d
Re-attach the screen session
$ screen -list # shows current sessions $ screen -r # when only one avaible session is running $ screen -r # from list of current sessions $ screen -r / # multiuser session $ screen -d -r # detach session first
Allow multiuser mode
$ chmod u+s /usr/bin/screen # first time only $ chmod 755 /var/run/screen # first time only
^A: multiuser on ^A: acladd StHAdPdbENeKq // the 2nd argument is crypted password (created by mkpasswd)
Managing screen windows
^A A // rename current window ^A " // list of windows ^A S // split current window horizontally ^A [0-9] // quick access window #No.[0-9]
