Task: What is the Linux command to:-
To view what's written in a file.
To change the access permissions of files.
To check which commands you have run till now.
To remove a directory/ Folder.
To create a fruits.txt file and to view the content.
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
Show only the top three fruits from the file.
Show only the bottom three fruits from the file.
To create another file Colors.txt and to view the content.
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
To find the difference between fruits.txt and Colors.txt files.
1. To view what's written in a file.
cat <file-name>

⏩ cat command shows what is written in the file.
2. To change the access permissions of files.
chmod 777 <file-name>

⏩ command To change the access permissions of files is chmod 777 <file-name> and to check the access use ls -lrt command.
3. To check which commands you have run till now.
history

⏩ history command is used to show which commands we are used till now.
4. To remove a directory/ Folder.
rm -r<folder/directory-name>

⏩ command for removing directory/folder is rm -r folder name
5. To create a fruits.txt file and view the content.
touch <file-name.txt>
cat <file-name>

⏩ for creating a fruits.txt file we are using the touch command and to view content inside this file we use the cat command.
6. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
vim <file-name>

⏩ first, we create a file devops.txt by using the touch command, then we use the vim command to add the content to this file.
7. Show only the top three fruits from the file.
head -3 <file-name>

⏩ head -3 command is used to show only the top three fruits from the file.
8. Show only the bottom three fruits from the file.
tail -3 <fil-name>

⏩ tail -3 command is used to show only the bottom three fruits in the file.
9. To create another file Colors.txt and to view the content.
touch <file-name>
cat <file-name>

⏩ for creating a Colors.txt file use the touch command and for viewing the content use the cat command.
10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
vim <file-name>

⏩ for adding content in the file use the vim command.
11. To find the difference between fruits.txt and Colors.txt files.
diff <file1-name> <file2-name>

⏩ command for finding the difference between two files i.e. fruits.txt and Colors.txt files use diff command.



