Wednesday, July 11, 2018

Linux Command

#To find process by port

root@My-ThinkPad $ sudo lsof -i :5672 | grep LISTEN  
[sudo] password for root: 
beam.smp 953 rabbitmq   52u  IPv6 33026      0t0  TCP *:amqp (LISTEN)

Kill process  

sudo kill 953

#rmdir - Remove folder 

root@My-ThinkPad $ rmdir {foldername}  

#Remove folder permanently  

root@My-ThinkPad $ sudo rm -rf folderName

FYI: you can use letters

-f, -r, -v: 
    -f = to ignore non-existent files, never prompt
    -r = to remove directories and their contents recursively
    -v = to explain what is being done

#Run execute files 

root@My-ThinkPad $ sudo ./{filename}.run 
e.g. root@My-ThinkPad $ sudo ./bitnami-rabbitmq-3.7.6-0-linux-x64-installer.run 

#Run script files 

root@My-ThinkPad $ sh {filename}.sh

#copy file from one folder to another 

root@My-ThinkPad $ sudo cp /opt/user/1.html /opt/user1

#copy file from one computer  to another 

root@My-ThinkPad $ sudo scp /opt/user/1.html root@My-ThinkPad1:/opt/user1
#ls - Show files in directory

root@My-ThinkPad $ ls 
Desktop Downloads
Music Pictures

#Show hidden files 

root@My-ThinkPad $ ls -a
 
 
#Show hidden files with details 

root@My-ThinkPad $ ls –al 

#To create folder 

root@My-ThinkPad $ mkdir {foldername} 

#Unzip file in folder  

root@My-ThinkPad $ unzip file.zip -d destination_folder 

-d means external folder, its optional 

If the unzip command isn't already installed on your system, then run: 

root@My-ThinkPad $ sudo apt-get install unzip 
e.g. root@My-ThinkPad $ unzip glassfish-4.1.zip -d /home/hcdc/webapps/ 

 #pwd - To know which directory you are in, It gets absolute path  

root@My-ThinkPad $ pwd
/home/root

#cd- Go to directory

root@My-ThinkPad $ cd Downloads 
root@My-ThinkPad: Downloads $ 

No comments:

Post a Comment