Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Last Updated: Mar 27, 2024
Difficulty: Easy

Linux - Commands and Arguments

Leveraging ChatGPT - GenAI as a Microsoft Data Expert
Speaker
Prerita Agarwal
Data Specialist @
23 Jul, 2024 @ 01:30 PM

Introduction

Linux is a widely used operating system, but what is the language it follows? How do we pass arguments? How do we give commands? Let us find all these answers through this blog.

commands and arguments


What Is A Command Line Interface?

Command-line interfaces are also called CLIs. CLIs take input commands that are entered by the keyboard and run them.

The command line interface in Linux systems is bash. It stands for Bourne again shell. The features of this shell include the characteristics of sh (the original Bourne shell), csh (the C shell), and ksh (the Korn shell).

Commands in Linux

Let us study each command one by one.

echo Command

As the name signifies, it echoes or returns the input we give.

Syntax

echo text

Output

echo

Note that If the parts in the text are separated by white space, it is read as a separate argument. The white space is removed.

type Command

Type command is used to determine whether the given command is an external one or a built-in command.

Syntax

type cd

Output

type

touch Command

The touch command is used to make new files.

Syntax

touch file_name

Output

touch

cat Command

We use cat to create a file, display the file content, copy the content, etc.

Syntax

cat file_name

Output

cat

rm Command

The rm command removes a file.

Syntax

rm file_name

Output

rm

cp Command

The cp command has the task of copying.

Syntax

cp old file new file

Output

cp

mv Command

This command moves a file from one location to other.

Syntax

mv file_name path of the directory

Output

mv

tac Command

cat, when reversed, is called tac. It shows the content of the file in a reversed manner.

Syntax

tac file_name

Output

tac

date Command

Use the date command to see the date, time, time zone, and more.

Syntax

date  

Output

date

sleep Command

This command gives rest to the terminal for a few seconds.

Syntax

Sleep time

Output

sleep

time Command

Time command tells the time to run a command.

Syntax

time  

Output

time


df Command

If you need to see the disk space used in the file system, use df.

Syntax

df  

Output

df

exit Command

Exit command takes you out of the shell

Syntax

exit  

Output

exit

To exit the terminal, you must press the ENTER key on your keyboard.

clear Command

Clear command empties the terminal

Syntax

clear  

Output

clear

Press the ENTER key on the keyboard to clear the terminal screen.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Arguments in Linux

The primary feature of a shell is to scan the command line. When we enter an output, it generates an output for the same. It cuts the line in arguments. While the system does the task of scanning, it makes some changes to the typed arguments. We refer to this process as shell expansion.

Syntax

command argument
args

White Space Elimination

White spaces occupy the space although they are not visible. They get removed while showing results.

Syntax

echo text

Example

white space

Single and Double Quotes

In case you want to include the white spaces, you need to use single and double quotes. In that case, Linux echo will treat them as a single command.

Syntax

echo 'text'   
echo  "text"   
echo quotes

Space and Line

In order to add a tab space or start a new line, use the ‘echo -e’ command. To add a new line use '\n' and '\t' to add a tab space. We can use both single or double quotes.

Syntax:

echo -e ‘text’
echo -e “text”
space and line

 

Frequently Asked Questions 

What is the full form of BASH?

BASH stands for Bourne again shell.

State the difference between cat and tac commands.

The Cat command correctly displays the file's content, while the tac command displays it in reverse order.

Which command displays the disk space?

df command displays the disk space.

What is the difference between exit and clear commands?

exit command takes you out of the terminal while the clear command cleans the terminal.

How do we remove a file using some command in the terminal?

We can use the rm command to remove a file.

Conclusion

This article has discussed the commands and arguments in the Linux Operating System. We have studied each command one by one. We hope you got clarity on this topic. To read more about Linux, refer to the following articles-

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available. Take a look at the interview experiences and interview bundle for placement preparations.

Happy Coding!

Topics covered
1.
Introduction
2.
What Is A Command Line Interface?
3.
Commands in Linux
3.1.
echo Command
3.2.
type Command
3.3.
touch Command
3.4.
cat Command
3.5.
rm Command
3.6.
cp Command
3.7.
mv Command
3.8.
tac Command
3.9.
date Command
3.10.
sleep Command
3.11.
time Command
3.12.
df Command
3.13.
exit Command
3.14.
clear Command
4.
Arguments in Linux
4.1.
White Space Elimination
4.2.
Single and Double Quotes
4.3.
Space and Line
5.
Frequently Asked Questions 
5.1.
What is the full form of BASH?
5.2.
State the difference between cat and tac commands.
5.3.
Which command displays the disk space?
5.4.
What is the difference between exit and clear commands?
5.5.
How do we remove a file using some command in the terminal?
6.
Conclusion