Basic Unix commands for server maintenance

Some of my websites hosted on a VPS started behaving erratically a few days back. WP based websites resulted in killed sessions. Magento ones simply stopped working prompting “500 Internal Server” error. Pinging server IP yielded desired results though. Static pages were also fine.

Tech support guys of the server hosting company were clueless. Finally, fixed the issue myself realising the culprit was unprecedented creation of session files due to some bot attacks. Server’s inode usage had exceeded the limit and hence file creation failed even though there was enough disk space left on the server.

For a ready reckoner listing some essential Unix commands for system admins responsible for monitoring and maintenance of server.

dfdfSee how much free disk space
dudu -b subdirEstimate disk usage of directory in Bytes
aliasalias lls=”ls -alF”Create new command “lls” for long format of ls
xhostxhost +
xhost –
Permit window to display from x-window program from threat
Allow no x-window access from other systems
foldfold -s file1   |   lprFold or break long lines at 60 characters and send to printer
tartar -cf subdir.tar subdir
tar -xvf subdir.tar
Create an archive called subdir.tar of a directory
Extract files from an archive file
ghostview (gv)gv filename.psView a Postscript file
ping (traceroute)ping
See if machine is alive
Print data path to a machine
toptopPrint system usage and top resource hogs
logout (exit)logout or exitHow to quit a UNIX shell.

grep <str><files>grep “bad word” *Find which files contain a certain word
 chmod <opt> <file>chmod 644 *.html
chmod 755 file.exe
Change file permissions read only
Change file permissions to executable
 passwdpasswdChange passwd
 ps <opt>ps aux
ps aux   |   grep dhyatt
List all running processes by #ID
List process #ID’s running by dhyatt
 kill <opt> <ID>kill -9 8453Kill process with ID #8453
 gcc (g++) <source>gcc file.c -o file
g++ fil2.cpp -o fil2
Compile a program written in C
Compile a program written in C++
 gzip <file>gzip bigfile
gunzip bigfile.gz
Compress file
Uncompress file
mail < file1
Send file1 by email to someone
Read mail using pine
 telnet <host>
        ssh <host>
ssh -l dhyatt
Open a connection to vortex
Open a secure connection to jazz as user dhyatt
ftp <host>
ncftp <host/directory>
Upload or Download files to station1
Connect to archives at UNC

Leave a Reply

Your email address will not be published. Required fields are marked *