Below are the top 9 Linux commands that are most commonly used in the Linux environment. These commands can help you get familiarised with the basics of Linux systems.

1.alias

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  
  alias  
 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  

3.find

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 6M

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.

 history

6. ps

process status ‘ps’ used to get information of a running process.A good article on ps command: https://www.journaldev.com/24613/linux-ps-command

 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

 scp user1@host1.com:/files/file1 user1@host2.com:/files

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.More info: https://linuxhint.com/top_-command-_linux/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 

Leave a Reply

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

Verified by MonsterInsights