Day 3 of 90DaysOfDevOps
Day 3 Task: Basic Linux Commands is the focus for today.
Task: What is the Linux command to
To view what's written in a file.
We use the "cat" command to view what is written in the file :
To change the access permissions of files.
First, we need to view what the current permissions are on the file by using "ls -all" :
As seen above, the file has "read-write rw" permission for user, "r for read" for the group and "r for read" for others.
I need to change the file permissions to read only by using the following chmod command:
Kindly refer to the permissions link for further details on octal notation.
To check which commands you have run till now.
we use the "history" command to view all the commands we have run till now:
To remove a directory/ Folder.
we can use the rm command with "-d" for the directory or "rmdir" command for deleting empty directories.
To create a fruits.txt file and to view the content.
we can use various editors for creating files and then adding content to it. In our case, we are using "vim" to create a file and "cat" to display the content of the file.
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
To Show only top three fruits from the file.
To Show only the bottom three fruits from the file.
To create another file Colors.txt and to view the content.
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
To find the difference between fruits.txt and Colors.txt file.
We can use the "diff" function to find the difference between two files:
Also, we can use the "vimdiff" function for side-by-side comparisons: