Most used commands for managing Linux server.

If you are using linux server then most of the time you would be using command line interface for interacting with your server or installing, updating your server applications.
As a linux server admin you should know following commands :

cd -  : Go to previous directory

cd    :   Go to $HOME

pushd . Put current dir on stack so you can popd back to it

which  : Show full path name of command

time :  See how long a command takes

time cat : Start stopwatch. Ctrl-d to stop.

ls -lrt :   List files by date.

find -type f -print0 | xargs -r0 grep -F ‘test’  :  Will search all regular files for ‘test’in this dir and below

find -maxdepth 1 -type f | xargs grep -F ‘test’ : Search all regular files for ‘test’ in this dir.

find -type d ! -perm -111 : You will get output as dirs which are not accessible by all

gpg -c : Use to Encrypt a file

gpg file.gpg : Use to Decrypt a file

tar -c dir/ | bzip2 > dir.tar.bz2 : Using this command you can compress archive of dir/

wget -r -nd -np -l1 -A ‘*.jpg’ http://wwwDOTexampleDOTcom/dir/ :  Using this command you can download a set of files at current directory.

echo ‘wget url’ | at 01:00 : If you need to download certain file from a url say at 1AM to your current dir then you can use this command.

wget -nv –spider –force-html -i bookmarks.html :  Check links in a file ethtool eth0 : Show status of ethernet interface eth0

ip link set dev eth0 up : You can bring interface eth0 up (or down)

ip route show : this command will list routing table

ip route add default via 1.2.3.254 : If you need to set default gateway for 1.2.3.254 then use this command with preferred gateway number.

hostname -i  : Lookup local ip address

netstat -tup : this command will list all active connections to/from your system.

sed ’s/string1/string2/g’ : If you need to replace string1 with string2 then use this command.

sed -n ‘1000p;1000q‘ : this command will print 1000th line.

history | wc -l : command will count lines

cal 9 1752 : if you need to read calendar for a particular date use this command it will display a calendar for a particular month year.

gzip < /dev/cdrom > cdrom.iso.gz : if you need to save copy of data from cdrom then use this command.

cdrecord -v dev=/dev/cdrom -audio *.wav : if you want to make a audio CD from all wave in current dir

ls -lSr : Show files by size, you will get file with smallest file size at the top.

uname -a : it will display kernel version and system architecture

grep “model name” /proc/cpuinfo : this command will display information of your CPU.

Posted under Fantastico Hosting, Reseller Hosting, WHM cpanel Hosting, cPanel account Hosting

This post was written by admin on September 15, 2008

Tags: , ,