🌈 Day 3: Day-To-Day Use Linux Commands

🌈 Day 3: Day-To-Day Use Linux Commands

💡📝 Tasks at Hand:

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

Command:cat

Syntax:cat filename.txt

Explanation: Displays the entire contents of the specified file on the terminal screen.

2. To change the access permissions of files:

Command:chmod

Syntax:chmod [options] permissions filename

Explanation: Modifies the read, write, and execute permissions for a file or directory.

3. To check which commands you have run till now:

Command:history

Syntax:history

Explanation: Lists a chronological record of the commands executed in the current terminal session.

4. To remove a directory/Folder:

Command:rmdir

Syntax:rmdir directory_name or rm -rf directory_name

Explanation: Deletes an empty directory. To remove a directory with its contents, use rmdir directory_name or rm -rf directory_name (use with caution!).

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

Commands:

  • touch fruits.txt (creates the file)

  • cat fruits.txt (views the content)

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

Command:echo -e "Apple\nMango\nBanana\nCherry\nKiwi\nOrange\nGuava" > fruits.txt

7. To Show only the top three fruits from the file:

Command:head -n 3 fruits.txt

8. To Show only the bottom three fruits from the file:

Command:tail -n 3 fruits.txt

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

Commands:

  • touch Colors.txt (creates the file)

  • cat Colors.txt (views the content)

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

Command:echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" > Colors.txt

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

Command:diff fruits.txt Colors.txt

Explanation:

  • This command compares the contents of fruits.txt with Colors.txt.

  • It outputs the differences between the files in a line-by-line format.

Happy coding :) 🚀🌟

🔗 Let's Connect..!

🌐LinkedIn

🌐Twitter

🌐GitHub