Basic Commands in Linux with Examples for Beginners

The GNU Bourne-Again Shell (bash) is a program that interprets commands typed in by the user. Each string typed into the shell can have up to three parts: the command, options and arguments. Each word typed into the shell is separated from each other with spaces. Commands are the name of programs that are installed on the system. Each command has its own options and arguments.
The ENTER key is pressed when a user is ready to execute a command. Each command is typed on a separate line and the output from each command displays before the displays a prompt. If a user wants to type more than one command on a single line, a semicolon ;, can be used as a command separator. A semicolon is a member of a class of characters called metacharacters that has special meaning for bash.

Examples of Simple Commands

date : The date command is used to display the current date and time. It can also be used by the superuser to set the system clock. An argument that begins with a plus sign specifies a format string for the date command.
This command will show you Day, Month, Date and Hour, Minute and Second.
#date +%R
This format will show Hour and Minute like as 05:34

#date +%x
This format will show you date in digit format with sequence of Month, Date and Year like as 05/06/2018.

The passwd command changes a user’s own password. You must enter old password before change will be allowed.

The head command display the beginning of file. By default this command display 10 lines, but they have a –n option that allows a different number of lines to be specified.
Ex. head /etc/passwd
This command will show first 10 lines of file /etc/passwd.
If we want to display 20 lines of /etc/passwd file you have to execute following command.
head –n 20 /etc/passwd

The tail command displays the end of file.
Ex. tail /etc/passwd

Linux System Administrator Interview Questions and Answers for Freshers

The wc command counts lines, words and characters in a file. It can take a –l, -w, or –c option to display only the lines, words, or characters respectively.
Ex. wc /etc/passwd
This command shows the number of lines, words and characters in a /etc/passwd file.
wc –l /etc/passwd
This command shows the number of lines in a /etc/passwd file.
wc –c /etc/passwd
This command shows the number of characters in a /etc/passwd file.

The ls command is used to list the number of files in specified file.

The history command displays a list of previously executed commands.

Most Reading