# What are Shell Commands?

Computer ScienceMCAUnix

The shell is the command interpreter on the Linux systems. It the program that interacts with the users in the terminal emulation window. Shell commands are instructions that instruct the system to do some action.

Some of the commonly used shell commands are:

## basename

This command strips the directory and suffix from filenames. It prints the name of the file with all the leading directory components removed. It also removes a trailing suffix if it is specified.

Example of basename is as follows:

## cal

This command is used to display a calendar. If a single parameter is specified, then the four-digit year is displayed. If there are two parameters, that denotes the month and the year. No parameter means that the current month is displayed.

Example of cal is as follows:

$pwd  The current directory is changed to example using cd and that is displayed using pwd command: /user/local/example  ## cp This command copies the contents of a file into another file. Example of cp is as follows: $ cat example.txt
This file is used as an example
$cp example.txt example.bak$cat example.bak
This file is used as an example


cp copies the contents of the text file example into the backup file example.bak

## clear

The clear command clears the terminal screen. It ignores any command line parameters that may be present.

Example of clear is as follows:

$clear  This clears the terminal screen. ## cmp This function compares two different files and reports the differences between them character by character. If the files differ, it tells the first byte and line number where they differ. Example of cmp is as follows: $ cat example1.txt
This is an example text file
$cat example2.txt This is also an example text file$ cmp example1.txt example2.txt
example1.txt example2.txt differ: byte 10, line 1


This example demonstrates that the first difference in example1.txt and exampl2.txt is in line 1 and at byte 10.

## mkdir

This command is used to create a directory in the Linux operating system.

Example of mkdir is as follows:

mkdir /fruit/apple


The above command creates a directory apple in the directory fruit.

## rmdir

This command is used to remove a directory. All the files and subdirectories in a directory should be deleted first before deleting a directory.

Example of rmdir is as follows:

rmdir example


This deletes the directory example.

## mv

The mv i.e. move command can be used for renaming directories.

Example of mv is as follows:

mv name1 name2


The initial name of the directory is name1 which is changed to name2.

Published on 11-Sep-2018 12:35:57