Top 9 Linux useful commands


As the name suggests Linux lets users to create custom commands or shortcuts to existing commands. Using alias convert long commands into mere characters by creating an alias for that command.

 List available aliases  
 Create a new alias  
   alias ll=’ls -l’  
 Remove an alias  
   unalias ll 

to keep the aliases persistent add the alias to ~/.bashrc ~/.zshrc files

2. df and du  

df command lets you see the available disk space for the filesystems on which the invoking user the required read permissions.

 df -h    # ‘h’ here is human readable format of memory like MB/GB 

du on the other hand lets user see the space usage for a particular directory or file on the given filesystem.

 du -h    # ‘h’ here is human readable format of memory like MB/GB  


find command is basically used to find files and directories. find supports searching file by file name, type, creation date, modification date, owner and by permissions.

Find file by name 
 find <search location> -name <filename> 
 find <search location> -iname <filename>    #ignore case 
 Find directory by name 

 find <search location> -type d -name <directory name>
 Find files by permissions
 find <search location> -type f -perm 0777 -print

 Find files by modified date

 find <search location> -mtime 30

 Find files by size

 find <search location> -size 50M

4. grep

grep helps in searching text in a file or occurrence of text in multiple files of a directory.
Search for text in a file
 grep 'search text' filename
 Search occurrence of a text in a directory
 grep 'search text' <location>

 Mostly used options i, r, n which basically stands for ignore case, recursive, line no.

 grep -irn 'search text' <location>

5. history

history command lists down all the recent commands that have been recently used.


6. ps

process status ‘ps’ used to get information of a running process.
 ps      #Lists the processes running in the current shell  
 ps -A   #Lists all the process running on the system  
 ps -ax  #List all the current processes  

7. scp

scp (secure copy) allows securely copy files between two locations. 
From local system to a remote system
 scp filename remote_user@host:/remote/directory
From remote to local system
 scp remote_user@host:/remote/filename /local/files

B/w two remote systems from your local system


8. tar

tar – tape archive, used to create compressed archive files. Supports different   types of archive types such tar, gzip and bzip.

 Create a tar file  
   tar -cvf target-file.tar source-directory.  
   # c – Create a new file  
   # v – Verbose  
   # f – Filename type of archive file  
 Untar files  
   tar -xvf filename.tar   
   # x – Extract  
   # v – Verbose  
   # f – Filename type of archive file 

9. top

top command gives complete process overview of the Linux system. The information includes running processes, resource usage, processor activity and kernel managed tasks in real time.
top command can be just invoked by running ‘top’ from the terminal
 Key terms to note:  
  us – processes running under userspace  
  sy – system kernel processes  
  id – idle time of CPU  
  wa – wait time for I/O 

Post a Comment