What are the basic Linux commands to:
1.To view what's written in the file :
cat filename: This command is used to display all the contents in the particular file on the terminal.
2.To change the access permissions of the file:
chmod777 filename: This command is used to provide the permissions to the owner, group and others as a three-digit number.
Various digits and their permissions are listed below:
0: (000) No permission.
1: (001) Execute permission.
2: (010) Write permission.
3: (011) Write and execute permissions.
4: (100) Read permission.
5: (101) Read and execute permissions.
6: (110) Read and write permissions.
7: (111) Read, write and execute permissions.
3.To check the commands you have run till now.
history: This command is used to list all the commands we've used recently.
4.To remove a directory or a folder:
rmdir: Deleting an empty directory has the special command rmdir, which only removes an empty directory, protecting you from recursive mistakes.
5.To create a fruits.txt file and to view the content:
touch filename: This command is used to create a file.
cat filename: This command is used to display all the contents in the file.
Here we've created a file named fruits.txt and to access the contents from the file we've used the cat fruits.txt command
6.Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
echo "contents" >> filename: We can use the echo command to add content to the file line by line.
7.To Show only the top three fruits from the file.
head -n: This command is used to display the top n contents in the file.
8.To Show only the bottom three fruits from the file.
tail -n: This command is used to display the bottom n contents in the file.
9.To create another file colors.txt and to view the content.
touch filename: This command is used to create a file.
cat filename: This command is used to display or view all the contents in the file.
10.Add content in colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, and Grey.
11.To find the difference between fruits.txt and colors.txt files.
diff filename1 filename2: This command is used to find diff between two files.
-
Thank you for reading!!
Great initiative by the #trainwithshubham community.
#devops #90daysofdevops
Let's connect on LinkedIn-https://www.linkedin.com/in/piyush-verma-8b1b4426a/