advanced command freebsd
tar Command Through Network Over SSH Session :
# tar cvfz – /wwwdata | ssh root@192.168.1.201 “cat > /backup/wwwdata.tar.gz”
restore tar backup over ssh session:
# cd /
# ssh root@192.168.1.201 “cat /backup/wwwdata.tar.gz” | tar zxvf –
restart network service over ssh session :
# /etc/rc.d/netif restart && /etc/rc.d/routing restart
Find Information About The Process Including All Command Line Parameters
$ ps auxww
or
$ ps auxww | grep –color mysqld
vi / vim perform search and replace operation
Simple format is as follows:
:%s/old-string/new-string/
To replace all occurrences of word foo with bar on all lines, use the g option:
:%s/old-string/new-string/g
Find and Replace with Confirmation
:%s/UNIX/Linux/gc
Case Insensitive Find and Replace
:%s/unix/Linux/gi
Case sensitive Find and Replace
:%s/UNIX/bar/gI
Rsync: Preserve / Copy Hard Links ( Backup Rsnapshot Directory Tree )
#rsync -az -H –delete –numeric-ids /path/to/source server2:/path/to/dest
Where,
- -a : Archive mode (i.e. recurse into directories, and preserve symlinks, file permissions, file modification times, file group, file owner, device files & special files)
- -z : Compress file data during the transfer
- -H : Preserve hard links (i.e. copy hard links as hard links)
- –delete : Delete extraneous files from the receiving side (ones that aren’t on the sending side), but only for the directories that are being synchronized i.e. keep exact replica of your /raid6/rsnapshot directory.
- –numeric-ids : Transfer numeric group and user IDs rather than using user and group names and mapping them at both ends.