OneCompiler

Top 15 most frequently used Linux Commands

561

1.) To check if port is open and a process is running in it use below command :-

userName@hostName:~# netstat -tulpn | grep 9092

2.) To check if a process is running :-

 userName@hostName:~# ps -ef | grep zookeeper 

3.) To kill a process :-

userName@hostName:~#  kill -9 9092

4.) To switch to root user :-

userName@hostName:~# sudo -i

5.) To empty log file :-

userName@hostName:~# truncate logfile - - size 0

6.) To grep in log file :-

userName@hostName:~# grep 'hello' yourfile.log
userName@hostName:~# grep -rnw 'sparkAll.log' -e 'ApplicationMaster'

7.) PING (Packet INternet Groper) command is to test connectivity between two machines.

userName@hostName:~# ping destinationHostName/destinationIPAddress

8.) To use Find cmd :-

userName@hostName:~# find / -name xxxx
userName@hostName:~# locate / -name xxxx

9.) To view top process running : top

userName@hostName:~# top

To quit, type q

10.) To find list of all processes running :-

userName@hostName:~#  initctl list

11.) To find top files greater than 10M size :-

userName@hostName:~# sudo find / -type f -size +10M -exec ls -lh {} \;

12.) To search for a software in apt repository

userName@hostName:~#  apt-cache search mysql-server

13.) to search for a string in file opened with vi, use '/' and type required string, to go to next occurance type n or N

14.) The telnet is used to connect to remote hosts using a command line interface

userName@hostName:~# telnet destinationHostName portNo

15.) To find ipaddress of the linux machine

userName@hostName:~# ifconfig | grep inet