
Table of Contents -
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.
To Show only top three fruits from the file.
To Show only 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 file.
1- To view what's written in a file.
๐ฑ The cat Command: Displaying File Contents ๐
๐ Simplicity: The
catcommand is straight forward and easy to use.โก๏ธ Speed: It efficiently displays the entire contents of a file quickly.
๐ Complete Output: It prints the full content of a file without any pagination or truncation.
๐ Versatility: The
catcommand can handle multiple file arguments, concatenating their contents together.2- To change the access permissions of files.
To change the access permissions of files in Linux, you can use the
chmodcommand. Thechmodcommand allows you to modify the read, write, and execute permissions for the owner, group, and others.๐ Changing File Access Permissions ๐
๐ Identify the File: Locate the file for which you want to modify the permissions.
๐ Understand Permission Types: There are three types of permissions:
๐งโ๐ป Owner: The user who owns the file.
๐ฅ Group: The group to which the file belongs.
๐ Others: All other users on the system.
๐ต๏ธโโ๏ธ Numeric Mode: Assign permissions using numeric values:
๐ Read (r): Assign a value of 4.
๐๏ธ Write (w): Assign a value of 2.
๐โโ๏ธ Execute (x): Assign a value of 1.
โ๏ธ Example: To give read and write permissions to the owner, read-only permissions to the group, and no permissions to others:
The numeric value for the desired permissions is 640.
Execute the command:
chmod 640 <file_path>
3- To check which commands you have run till now.
By using the
historycommand, you can quickly review and reuse previously executed commands, saving time and reducing typing effort in the Linux shell.๐ Purpose of the
historyCommand โฒ๏ธ๐ Command History: The
historycommand displays the command history of the current shell session.๐ข Command Numbers: Each command in the history is assigned a unique number, indicating its position in the history list.
๐ Listing Commands: It presents the command history as a numbered list, showing the command numbers on the left and the corresponding commands on the right.
โฌ๏ธโฌ๏ธ Navigation: You can navigate through the command history using the Up and Down arrow keys on your keyboard, making it easy to find and reuse previously executed commands.
4- To remove a directory/ Folder.
To remove a directory or folder in Linux, you can use the
rmcommand with the-roption, which stands for "recursive." This option allows you to delete a directory and all its contents. Here's how you can remove a directory:rm -r <directory_path> or rm filename.
5- To create a fruits.txt file and to view the content.
vim fruits.txtcat fruits.txt6- Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
touch devops.txt
echo -e "Apple\nMango\nBanana\nCherry\nKiwi\nOrange\nGuava" > devops.txt
7- To Show only top three fruits from the file.
head -3 <file_name>
8- To Show only bottom three fruits from the file.
tail -3 <file_name>
9- To create another file Colors.txt and to view the content.
touch Colors.txt
cat Colors.txt
10- Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" > Colors.txt
11- To find the difference between fruits.txt and Colors.txt file.
diff fruits.txt Colors.txt
Thank you for reading this blog! ๐ I hope you found the information helpful and engaging. Remember, learning is a never-ending adventure, and discovering new concepts and technologies can be incredibly exciting and rewarding. ๐ Whether you're diving deeper into Linux commands, exploring new programming languages, or embracing the world of DevOps, there's always something new to learn and explore. ๐ So, stay curious, keep exploring, and never stop expanding your knowledge! ๐๐โจ Happy learning! ๐



