Top 10 Linux Useful Command and Usage

Let me take an opportunity to introduce few Linux Useful Command and Usage which are used in  Linux for basic Troubleshooting.


Lets start with  Top 10 Linux Useful Command

1. Du Command Used to Find out which Directory in Given path have maximum data.

Command Name : du- Summarize disk usage of each FILE, recursively for directories.


Command Syntax :  du -sm <path>

We have sorted the OutPut of du -sm <path> with sort command , because of that it is showing us data in a sorted way.

And Last directory has highest data.


relevant command Usage :   du -sm /usr/* | sort -n -k1
  0 /usr/etc
  0 /usr/games
  0 /usr/local
  0 /usr/src
  0 /usr/tmp
  10 /usr/include
  26 /usr/libexec
  37 /usr/sbin
  172 /usr/bin
  215 /usr/lib64
  722 /usr/share
  774 /usr/lib


Last directory is have Maximum data in MB 774.

We just sorted the Output of du -sm ./*

2.Find command with exec option to Find Out Highest  files.

  • Top 10 biggest file more than 1MB size .
    relevant command eg :  This command contain type f (file) , size , and Then also list the output with ls -l

    find  <path> -type f -size +1000 -exec ls -l {} \; | sort -n -k5 | tail -10
  • In addition to above command you can Remove all files which are more than 1 MB like below
    relevant command eg : 

    find  <path> -type f -size +1000 -exec rm -f {} \;

3. Find Out how many users are currently logged into System and other User details using who,id,finger,passwd file,ldapuser

  • who command
    Command will seems like shown below:
    relevant command eg :

      kpiplani pts/0 2018-01-02 06:33 (
  • id <userid> to check current user details
    relevant command eg :

     id keshav
      uid=1001(keshav) gid=1001(keshav) groups=1001(keshav)
  • finger command
    relevant command eg:

    finger keshav
     Login: keshav Name: Keshav 
     Directory: /home/keshav Shell: /bin/bash
     On since Thu Oct 12 12:51 (IST) on tty1 from :0
      82 days 5 hours idle
     On since Tue Jan 2 12:03 (IST) on pts/0 from :0.0
     On since Sun Dec 24 22:25 (IST) on pts/1 from :0.0
      4 hours 3 minutes idle
     No mail.
     No Plan.
  • User details in Linux File system stored on /etc/passwd path
     relevant eg : cat /etc/passwd | grep -i keshav
  • For searching users in  Ldap we can use genet command
    relevant eg :

    getent passwd | grep -i keshav

4. List of Open Files

  • lsof command for checking open files if we know process id
    relevant command eg :

     lsof -p <process_id>
  • For checking listen port with given process.
    relevant command eg:

     lsof -p <process_id> | grep -i listen
  • For checking Process Id bind with given port.
    relevant command eg:

     lsof -i :<port_number>

5. Checking if File is currently INUSE by any process.

  • fuser Command will tell you if file is in use by any process or not
     relevant command eg :  fuser <filenamewithpath>

6. If your file System is 100% full and you want to compress any files, It will give you error message .

you can compress it via gzip command with below syntax

7. gzip command

 relevant command eg : gzip -c (file_name) >>(filesystempathwhich is notfull/file_name.gz)

Then you can remove or null the file and can move zip file back to current file system.

8. For checking System last reboot and load Average. We can use below command:

relevant  command eg:

  17:50:49 up 82 days, 4:59, 3 users, load average: 0.02, 0.03, 0.00

It will also tell us how many users are currently logged In to system.

9. Memory /RAM usage command and Disk Utilization

  • For Memory/RAM use below command :

relevant commands eg:

free -h
  total used free shared buffers cached
 Mem: 7.5G 5.3G 2.2G 321M 289M 2.1G
 -/+ buffers/cache: 3.0G 4.5G
 Swap: 8.0G 1.4G 6.6G
  • For Disk Usage:
    df -k /root
     Filesystem 1K-blocks Used Available Use% Mounted on
      236715920 61582520 172727384 27% /


10. You can check history of previous commands as well via history command:

relevant command eg:

history | tail -20
  1031 ps huH -p 11629 | wc -l
  1032 top-H
  1033 top -H
  1034 top
  1035 top -H
  1036 top -H -p 11629
  1037 htop
  1038 top -H
  1039 uptime
  1040 free -h

For clearing up all history you can use command

relevant command eg:

history -c


Please follow and like us:

Leave a Reply

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