To view what's written in a file.
The cat command is used to view the contents of the file in Linux.
To change the access permissions of files.
Syntax-
chmod 777 <Filename>
Here we are providing all the Permission to the file (Read, Write, and Execute).
Check which commands you have run till now.
The history command is used to check all the commands you have run till now.
To remove a directory/ Folder.
rm -rf<Filename>
To create a fruits.txt file and to view the content.
To create the fruit.txt file we will use the touch command.
To view the contents we will use the cat command
We are not able to see the output because the file is empty.
Add content in fruits.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
By using any editor such as vim(vi), nano, or cat command, we will use vim followed by the filename. vim fruits.txt
For inserting the contents we will press "i".
After inserting the contents press Esc & ":wq" to save and exit from vim.
Show only the top three fruits from the file.
head -n <Filename>
n - Number of the lines to be displayed
Show only the bottom three fruits from the file.
tail -n <Filename>
n - Number of the lines to be displayed
To create another file Colors.txt and to view the content.
To create the file we will use the touch command and to view the contents we used the cat command
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, and Grey.
To find the difference between the fruits.txt and Colors.txt files.
diff fruits.txt Colors.txt