Table of contents
No headings in the article.
Task: What is the Linux command to
1. To view what's written in a file.
The cat command is used to view the content of the file.txt reads data from the file and gives its content as output.
Syntax: cat file_name
2. To change the access permissions of files.
Chmod is the command used to change the access permissions of a file.
There are three basic file system permissions, or modes, to files and directories:
1. read (r=4): The file can be opened, and its content viewed. 2. write (w=2): The file can be edited, modified, and deleted. 3. execute (e=1): If the file is a script or a program, it can be run (executed).
Each mode can be applied to these classes:
1. user (u): A user is the owner of the file 2. group (g): The group is a collection of users. 3. other (o): Other is every one that is not the owner or in the group.
Syntax: chmod permissions file_name
Example : chmod u=rwx,g=rw,o=r file_name this is equivalent to command
chmod 755 file_name
3. To check which commands you have run till now.
history command is used to check the commands you have run till now.
4. To remove a directory/ Folder
The rm command is used to remove directories and files permanently without moving them to the trash directory. The rmdir command removes empty directories. rm -rf command removes the directory forcefully.
Syntax: rm folder_name
5 . To create a fruits.txt file and view the content
6. To Show only the top three fruits from the file. To show only the top three fruits we will use the head command. The Linux head command prints the first lines of one or more files to standard output. By default, it shows the first 10 lines. We can pass a -n, where n shows the specified number of line
Syntax: head -n file_name
7. To Show only the bottom three fruits from the file To show only bottom three fruits we will use tail command**.** Tail is a command which prints the last few lines (10 lines by default) of a certain file.
Synatx: tail -n file_name
8. To create another file Colors.txt and to view the content. Commands: vi Colors.txt cat Colors.txt
9. To find the difference between fruits.txt and colors.txt files. To find the difference between the content of two files we can use diff command.
Thank you for reading! Hope you find this article helpful.
Don't forget to follow me on socials:
LinkedIn: https://www.linkedin.com/in/maaz-mohd-4a6b54180/
Twitter: https://twitter.com/maazmohd313