linux commands
How to Latest Study Top 10

Some useful basic Linux commands

Linux is very easy and useful OS if you are handy with commands. By using Linux command you can easy operate things on you fingertip.

So lets see some useful commands.

Go to any path

 Type : cd #any path#

Example : cd /usr/data/test

 

Go to back folder

type : ../

 

Give permission of any folder to any user from root

type : sudo chown -R #username# #path of Folder# 

Example : sudo chown  -R admin /usr/data/java

 

Copy any folder to any folder forcefully.

Type : yes | cp -fr #path of folder to copy# #path of destinatio  where to copy#

Example : yes | cp -fr /usr/data/test /usr/data/java

 

Last lines of any log file

Type : tail -100f #fileName# (Log or txt file)

Example : tail -100f abc.log

 

 Running process by Name

Type : ps -aef | grep #Process Name#

Example : ps -aef | grep tomcat

 

Kill Any process using process ID

Type : kill -9 #process ID#

Example : kill -9 13234

 

Remove any folder 

Type : rm -rf #folder Name# (Do not add “/” in start or else whole system will get removed).

Example : rm -rf test

 

To find any word from any folder

Type : grep -r “string to be searched” /path/to/dir

Example : grep -r “tomcat” /path/to/dir 

 

Scp from one server to another

Type : scp #path of file in same server# #another Server user#@another Server ip#:#Path where to copy# 

Example : scp  /usr/data/test [email protected]:/data/home/test

 

Search with line number visible

Type : grep -nr ‘#String to search#’ #fileName#

Example : grep -nr ‘tomcat’ abc.log

 

Go to line Number of any file 

Type :less +#line Number# -N #fileName#  (pg down to down — up to up—- q to exit)

Example :less +12321 -N abc.log 

 

You would like to read these posts as well:

 

Leave a Reply

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