Day-3 Basic Commands in Linux - Part 2

Day-3 Basic Commands in Linux - Part 2

What is the Linux command to:

  1. To view what's written in a file

    We can use the "cat" command to see what's written in the file.

  2. To change the access permissions of files.

To change the access permissions of a file or directory we use "chmod".

By using "ls -l" or "ls -al" you can see the permission of files or directories

In Linux, there are 3 types of owners for example User. global and others.

File permission falls into three categories as well that are Read, Write and Execute.

Below is for "ls -al"

  1. To check which commands you have run til now

To do this, we have to run the "history" command as it shows you all those commands which you ran on the machine.

  1. To remove a directory/Folder

To remove the empty directory, we use the command "rmdir Project".

Sometimes some directories consist of subdirectories and Text files. To remove directories that consist of subdirectories and files, we use the command "rm -rf Project"

  1. To create "fruits.txt" file and view the content

We use the "touch" command to create a text file and to read the content of the file, we use the "cat" command

  1. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava

We can use the "vim" or "vi" editor to add content to the text files.

We Press "i" to enter insert mode.

Once we enter insert mode, We add the Apple, Mango, Banana, Cherry, Kiwi, Orange and Guava, one in each line

After inserting the names one by each line, Press the "ESC" button and write "wq" to save and exit.

To read the content of the file is saved or not, we can check with help of "cat"

  1. To show only the top three foods from the file

    We use "head -i" to show top-level food from the file

  2. To show only the bottom three foods from the file

we use "tail -i" to show only the bottom three foods

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

  1. Add content in colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple and Grey.

  2. To find the difference between fruits.txt and Color.txt

Thank you all for reading the blog, I hope it has helped you a lot in clearing the concepts. Keep supporting the community.

#TrainWithShubham #Devops #90DaysOfDevopsChallenge