Basic Linux Commands

Shubham SinghShubham Singh
2 min read

To view what's written in a file.

Cat: This is used to concatenate and display files on the terminal. It can also be used to modify existing ones.

To change the access permissions of files.

Chmod: This command is used to change the access permissions of files and directories.

For example: Following “chmod” command will give the user permission to read, write and execute a file.

To check which commands you have run till now.

History: This command is used to view the previously executed command.

To remove a directory/ Folder.

rmdir: Use the rmdir command to remove the directory, specified by the Directory parameter, from the system.

To create a fruits.txt file and to view the content.

Vim: This is a text editor used in Linux. It stands for “Vi Improved”.

Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

Echo: The output of the echo can be redirected to a file instead of displaying it on the terminal. We can achieve this by using the > or >> operators for output redirection.

To Show only top three fruits from the file.

Head: The head command, as the name implies, prints the top N number of data of the given input. By default, it prints the first 10 lines of the specified files

To Show only the bottom three fruits from the file.

Tail: This command prints the last N number of data of the given input. By default, it prints 10 lines.

We can specify the number of lines, that we want to display.

To create another file Colors.txt and to view the content.

Touch: It is used to create a file without any content. The file created using the touch command is empty. This command can be used when the user doesn't have data to store at the time of file creation.

Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple and Grey.

Echo: The output of the echo can be redirected to a file instead of displaying it on the terminal. We can achieve this by using the > or >> operators for output redirection.

To find the difference between fruits.txt and Colors.txt file.

Diff: This command is used to find the difference between two files.

0
Subscribe to my newsletter

Read articles from Shubham Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shubham Singh
Shubham Singh