(Day-3) : Basic Linux Commands

Motivated and goal-oriented aspiring DevOps engineer with a strong passion for optimizing software development and deployment processes
Hi folks, welcome to Day-3 of the #90daysofdevops challenge. In this blog we will be covering some more basic commands that we require involving the file hierarchy system (FHS), we will do a bunch of operations on the same Ubuntu instance that we created using the EC2 Instance Connect.
1. To view what is written in a file:
We can use the cat command to view the contents of a file.
cat command :

2. To change the access permissions of files:
We can use the chmod command to change the access permissions of a file that is set by default.

Notice in the last line of the above code that the permissions of the devops.txt file have changed to 661, i.e., user=read and write, groups=read and write, others = only execute.
3. To check which commands you have run till now:
In Linux, we have a command "history" which gives you the list of all the commands you have used in your current session.

4. To remove a directory/ Folder:
To remove/ delete a directory or folder we can use the command rm:

Note that the Folder2 above is deleted using the -r flag which means deleting the directory along with the sub-directories/ files inside of Folder2 recursively.
5. To create a fruits.txt file and view the content:
We can create a file using a couple of ways. First, let us use the cat command way:

In the above code execution, we used the ">>" operators to input the file with contents and used the cat command without the ">>" to view the contents of the file. Note: We can't edit the file. To create the file in an editable mode, we need the vi editor
Let's do the same operation using the vi editor:

Here, after going inside the editor we have added the text in the "insert" mode and saved it using the command ":wq"
6. To show only the top two fruits and then the bottom two fruits :
We can use the head and tail commands here to view the contents respectively:

7. To find the difference between two txt files :
We use the diff command followed by the file names of the files we want the difference of. This command is used to display the differences in the files by comparing the files line by line.
That is it for today, we will be coming up with more complex codes and advance commands in the upcoming days. Thank you! Ciao!




