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,

  1. -a : Archive mode (i.e. recurse into directories, and preserve symlinks, file permissions, file modification times, file group, file owner, device files & special files)
  2. -z : Compress file data during the transfer
  3. -H : Preserve hard links (i.e. copy hard links as hard links)
  4. –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.
  5. –numeric-ids : Transfer numeric group and user IDs rather than using user and group names and mapping them at both ends.
Freebsd Mount a NAS via SMB / CIFS
#mount_smbfs -I 1.2.3.4 //username@nasserver/share /path/to/local/mnt
Apache: Make Changes In a Config File Take Effect Without Restarting Server
# /etc/init.d/httpd reload
or
# apachectl -k graceful