Linux Shell commands

Top 10 Linux Shell Commands for Beginner

If you are a newbie to the Linux command line, then you will find that the commands are totally different than the one you are accustomed to on your PC or Mac computers. This is a guide that will help all the newbies’ who have made the switch from Window to Linux. The following are the important Linux shell commands that you must master to use this OS.

  1. Man

The manual command is the man command. This is a command that shows the manual of the command that you have inputted. There are situations where you will need to get more information about certain commands that you are using. The man command will help you to get into details of every command. These commands will give information on library routines, kernel, system calls, etc., of the system.

  • Basic syntax

man [option(s)] keyword(s)

  • Ex:  man ls: this command provides information about ls pages.
  1. Find

The find command is used to search for files in the command line. It is a very useful and handy command offered in Linux. You can use it to find files on various standards like: permissions, size, modification time, modification date, etc. This find command is part of most of the Linux OS and hence you do not have to look for any package to use it.

  • Basic syntax

$ find location comparison-criteria search-term

  • Ex: $ find . /test -name “abc.txt”

This command will search for files through their name.

  1. Locate

The locate command is the most used command on Linux OS. It is the command that helps you to quickly and easily find where the files and directories on Linux are.  It will check out the various databases and shows up the file names that match at least one pattern to the standard output. It will help in finding the files by the name. If no options are used, then locate command will display all the pathnames that the user has access to.

  • Basic Syntax

locate [options] name(s)

  • Ex: locate file1 dir1, to list the paths of the files and directories named file 1 and dir 1.
  1. Alias

If you would like to open up a group of commands in a Linux shell, then you can use the alias command.  The alias command helps in customizing the shells as it is built into the shells like bash, ksh, csh, etc. The shells will only be able to recognize the aliases and they will only work for the users who have created the aliases. It is very useful in creating a shortcut for a command.

  • General syntax

alias name=’command’

  • Ex: alias home=’cd /home/mark/public_html’

This instruction will create a ‘home’ alias that will take you to the /home/mark/public_html directory when you type the home option at the command prompt.

  1. History

To know all the last commands that you have used in the recent past, you can use the history command. In the Linux OS, the history command is set to show the last five hundred commands that you have used. The list of your past commands can also be accused if you check out the history folder and look into .bash_history.

Type history n, to get a list of the last n commands. Typing history without any options will show up  the full history list.

  • Ex: To check out last 25 commands, use history 25.
  1. cd

This is a Linux command that will be used the most by you in the Linux command line. cd means ‘change directory’. This Linux command will change the working directory of the shell. You can use this command to shift from one place to the other in your file system.

  • Basic syntax

cd [directory]

  • Ex: cd /, to change to root directory.  cd ..

This command will change to the parent directory. 

  1. cp

The cp line command means to copy. It is used whenever you need to make a copy of your files and directories. It will help in copying files from the source to destination. It can also be used to copy multiple sources to the directory. To copy multiple files, you need to specify the various files you need to copy in the source option and also specify the destination directory.

  • Command syntax

cp [option] . . . SOURCE. . . DIRECTORY

  • Ex: cp /home/photos/pictures/picture.jpg /home/photos/backup/picture.jpg.

This cp command will create a copy of the file home/photos/picture/picture.jpg in the directory home/photos/backup.

  1. rm

This rm UNIX command is the short form of remove. It is also a very common UNIX command that is used by most people. It will help in removing files, symbolic links, directories, etc., from the file system. It does not remove any directories by default. It will help in removing specific files.

  • Syntax

rm [OPTION] . . . FILE. . ., specific file will be removed by this rm command.

  • Ex: rm myfile.txt, this is a command that will help in removing the myfile.txt.

rm *, this command will remove all  the files from the working directory.

  1. mv

The Linux mv command is the abbreviation of the move files command. You can move the source directory to the destination directory easily using the mv command. It is also used to rename files.

  • Syntax

mv [OPTION] . . . SOURCE. . . DIRECTORY

  • Ex: $ cd /home/rakku/

$ mv data/ /use/home/rakku/archived/ , to move the data to  the archived directory.  

  1. ls

This is one of the most commonly used commands in Linux. It will list out the contents of files and the directories of the directory.

  • Syntax

ls [OPTION] . . . [FILE] . . .

  • Ex: ls –laxo : this command will list out the files with permissions and also show the hidden files. It will display the files in a column format and the group information will not be revealed.

The above mentioned commands are the most commonly used and popular Linux shell commands that are used in a Linux program. As a beginner, it is important for you to know the syntax and the use of these commands to help you in writing Linux programs.

Cheap Linux VPS