Basic Linux Commands

Basic Linux Commands

Task: What is the Linux command

  1. To view what's written in a file.

cat:- This command displays the contents of one or more files without having to open files for editing.

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

cat -E: This shows $ at the end of the line

cat -s: This squeezes blank lines into one line

cat -b: This adds line numbers to non-blank lines

cat -n: This adds line numbers to all lines

  1. To change the access permissions of files.

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

  1. To check which commands you have run till now.

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

  1. To remove a directory/ Folder.

rm file- Remove or delete the file.

rm -r directory- Remove the directory and its contents recursively.

rm -r file- Force removal of file without prompting for confirmation.

rm -rf directory- Forcefully remove the directory recursively.

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

vim -This is A Linux text editor used to create files and view content.

cat - By using Cat we can also create files and view the content.

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

Vim- Vim editor use to add content to devops.txt file.

  1. Show only the top three fruits from the file.

head- The head command prints the first lines of the file. By default, it shows the first 10 lines. But you can also use arguments to modify the output.

  1. 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.

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

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

  1. To find the difference between the fruits.txt and Colors.txt files.

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

Thanks for reading!!!!!