Basic Linux Commands for Server Management

Linux Commands

ls – List files and folders in the current directory. use ls -al for detailed list.

rmdir <directory> – deletes a directory.

cd <directory/path>– change directory.

cd .. – moving one directory up.

wget – downloading files.

rm -rf folder – delete a folder named “folder” and its files.

cp -i filename /user – copies the file filename to directory user. here “-i” helps for to get a prompt before overwriting an existing file.

mv -i faltu falti – moving or renaming a file from faltu to falti.

locate something – searches for the keyword “something”.

logout – to logout from current session.

clear– to clear the command window.

df -h -T – disk space usage.

more file.txt– reading the content of a text file called file.txt

nano /etc/httpd.conf – to edit the content of httpd.conf file.

passwd – changing password for root user.

Find Largest Files

CentOS: find /var/log -type f -size +100000k -exec ls -lh {} ; | awk ‘{ print $9 “: ” $5 }’

Debian:  find /var/log  -type f -size +100000k -exec ls -lh {} ; | awk ‘{ print $8 “: ” $5 }’

Zipping and Unzipping

tar -zcf archive.tar.gz /home/www/ – compress the folder www to archive.tar.gz

tar -zxf file.tar.gz – unzip tar.gz file

tar -xvf file.tar – unzip tar file

tar -t file.tar – list contents of tar file

tar -xvfj file.tar.bz2 – unzip tar.bz2 file

gunzip file.gz – unzip gzip file

unzip file.zip – unzip zip file

bunzip2 file.bz2 – unzip bzip2 file

References:
http://library.linode.com/linux-tools/common-commands

Leave a comment

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