πDay 3 Task: Basic Linux Commands
Table of contents
- ππ»1. To view what's written in a file.
- ππ»2. To change the access permissions of files.
- ππ»3. To check which commands you have run till now.
- ππ»4. To remove a directory/ folder
- ππ»5. To create a fruits.txt and to view the content.
- ππ»6. Add content in fruits.txt(One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
- ππ»7. To show only top three fruits from the file.
- ππ»8. To show only last three fruits from the file.
- ππ»9. To create a colors.txt and to view the content.
- ππ»10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
- ππ»11. To find the difference between fruits.txt and colors.txt file.
- π Conclusion:
ππ»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! π»β¨