πŸ“ŒDay 3 Task: Basic Linux Commands

Β·

3 min read


πŸ™‹πŸ»1. To view what's written in a file.

✍🏽 We can use cat CMD to view the content of the File.

CMD -> cat <filename>

πŸ“example:


πŸ™‹πŸ»2. To change the access permissions of files.

✍🏽 We can use chmod the command allows you to modify these permissions using a numeric or symbolic representation.

πŸš€CMD -> chmod <permissions> <filename>

Here's a breakdown of the numeric representation:

  • πŸ“0: No permission (---)

  • πŸ“1: Execute permission (--x)

  • πŸ“2: Write permission (-w-)

  • πŸ“3: Write and execute permissions (-wx)

  • πŸ“4: Read permission (r--)

  • πŸ“5: Read and execute permissions (r-x)

  • πŸ“6: Read and write permissions (rw-)

  • πŸ“7: Read, write, and execute permissions (rwx)

    πŸš€ chmod 777 tasks.md


πŸ™‹πŸ»3. To check which commands you have run till now.

✍🏽 The history command is used to show the list of previously used commands.

πŸ“example:


πŸ™‹πŸ»4. To remove a directory/ folder

✍🏽1. The rmdir command is used to remove empty directories. If the directory you want to remove is empty, you can use the following syntax:

πŸ“rmdir <directory_name>

πŸš€ If the directory is not empty, you will receive an error and the directory will not be removed. In that case, you can use the rm command.

✍🏽2. The rm command is more versatile and can be used to remove both files and directories, including non-empty directories. However, be cautious when using rm as it permanently deletes the specified files and directories.

πŸ“rm -r <directory_name>


πŸ™‹πŸ»5. To create a fruits.txt and to view the content.

✍🏽. The touch command is used to create an empty file.

πŸ“touch <file_name>

πŸ“cat <file_name>

Example:


πŸ™‹πŸ»6. Add content in fruits.txt(One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

✍🏽 We can use Vim or any other editor.


πŸ™‹πŸ»7. To show only top three fruits from the file.

✍🏽 The head command is used to display the first few lines of a file on the command line

πŸ“head -n 3 fruits.txt


πŸ™‹πŸ»8. To show only last three fruits from the file.

✍🏽 The tail command is used to display the last few lines of a file on the command line

πŸ“tail -n 3 fruits.txt


πŸ™‹πŸ»9. To create a colors.txt and to view the content.

✍🏽1. The touch command is used to create an empty file.

πŸ“touch <file_name>

πŸ“cat <file_name>


πŸ™‹πŸ»10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.

✍🏽 We can use Vim or any other editor.


πŸ™‹πŸ»11. To find the difference between fruits.txt and colors.txt file.

✍🏽The diff command compares files line by line and displays the differing content.

πŸ“diff [options] <file1> <file2>


🌟 Conclusion:

Congratulations! πŸŽ‰ Linux is a powerful, open-source operating system. We hope this blog has given you a Question/Answer πŸš€ Embrace the Linux power and have fun with your Linux journey! 🐧πŸ’ͺ

πŸ” Did you find this blog helpful? Let us know in the comments below! πŸ‘‡ And if you have any questions or need further assistance, we're here to help! πŸ€—

Happy Linux-ing! πŸ’»βœ¨

Β