Linux everyday

Today i am going to share some very easy but useful Linux commands . I have been using Cent-Os last 2 years and found these commands in my everyday life . Some of the commands may need root user permission , if you find “permission denied” exception try to switch your user to root and then run those commands . Or you can also run all the commands by adding a “sudo” before them .

Switching to a user :

$su username$

Password: Provide your password

Creating a group :

$groupadd testgroup$

Creating a user in a group :

$useradd -g groupname youruser$

Deleting a User :

$userdel youruser$

Deleting a group :

$groupdel testgroup$

Setting password to a user :

$passwd youruser$

Then provide old your password and new password to change.

To see all the available groups in your machine :

$cat /etc/group$

To change the owner of a folder along with its sub folders :

$chown -R username:groupname foldername$

For example to make youruserthe owner of all the folders of /home/youruser

$chown -R youruser:testgroup /home/youruser$

To delete a file :

rm fileName

To delete a folder :

rm -r folderName

To delete a folder without permission (It’s the supreme delete , think twice before you apply this command) :

rm -rf folderName

Change to directory :

$cd directorName$

To search for specific file/folder with a keyword in it’s name your whole OS :

$locate keyword$

If you are running this command for the very first time in your OS try running $updatedb$ and then run the command

To search for a keyword inside all the files of a folder :

$cd folderName$

$find folder_name -iname “*” | xargs grep keyword $

To see all the files along with the hidden files in a folder :

$ls -lh folder_name$

To see size of all the files in a folder :

$ls -lsh folder_name$

To see details information of all the files in a folder :

$ls -la$

To see the total size of a folder in MB :

$du -sh folder_name$

To find total free space of yous machine :

$df -h$

To ssh to a remote machine :

$ssh -l username ip$ (For example : $ssh -l testuser$)

Then provide the password of that user to login

To secure copy a folder from local computer to remote computer :

$scp -r localFolder username@ip:/path_to_copy$

And then provide the password .

For example : To copy songs folder to a machine with ip with user testuser

$scp -r /home/testuser/songs testuser@$

Similarly to copy a remote file in your local machine :

$scp -r username@ip:/file_to_copy  path_to_copy$

To login to a telnet server :

$telnet hostname port $

Then provide the password

To see your internet configuration :


To edit your internet configuration file and add a mapping to a domain with its ip:

$gedit /etc/hosts$

You will find something like               localhost.localdomain localhost
Then add your ip and domain at the end of file

and save . Rememebr you have to be root to save the file .

To change the hostname of your OS :

$gedit /etc/sysconfig/network$ and change the HOSTNAME and save

To display all the network connections :

$netstat -anp$

To find which process in running in a port :

$netstat -anp | grep port_number$

To download a file :

$wget file_url$

To see all running processes in your machine:

$ps -ef$

To search for a specific process :

$ps -ef | grep process_name$   (For example to search apache : $ps -ef | grep apache$)

To kill a process:

$kill -9 processID$  (You will find the processID of the process by running the previous command )

To see the running processes along with its CPU Usage :


To start a service :

$service service_name start$

To stop a service :

$service service_name stop$

To start a service during OS boot up :

$/sbin/chkconfig service_name ON$

To stop a service to start during OS boot up :

$/sbin/chkconfig service_name OFF$

To see the run level of a service :

$/sbin/chkconfig service_name –list$

Have fun with Linux :)