#90DaysOfDevOps #Day3
hello everyone,
This is Day 3 of the #90DaysOfDevOps challenge. we learned in the last article about some basic Linux commands. Today we learn more about Linux commands.
Day 3 Task: Basic Linux Commands.
To view what's written in a file.
-> cat
Linux is a handy way to view file contents. It can swiftly display content in the terminal or concatenate outputs, the cat command is used.
cat <filename.txt> or cat filename
To change the access permissions of files.
-> chmod
The chmod command enables you to change the permissions on a file. You must be a superuser or the owner of a file or directory to change its permissions.
chmod 777 <file or folder name>
To check which commands you have run till now.
-> history
history command is used to view the previously executed command.
To remove a directory/ Folder.
-> rm -r and rm -d or rmdir
The rm -d command is for removing empty directories.
while the rm -r command deletes non-empty directories.
To create a fruits.txt file and to view the content.
-> touch <filename.txt>
To create a new file in the current directory, you need to run the touch command followed by the name of the file.
->echo -e <option> > filename.txt
To add some content to the "fruits.txt" file using the echo command:
This command will write the fruit names to the file, separated by newlines (\n). The -e option enables the interpretation of escape sequences like \n.
-> cat <filename.txt>
To view the contents of the "fruits.txt" file using the cat command:
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
The first command creates a new file called devops.txt and writes the string "Apple" to it. The \> symbol is used to redirect the output of the echo command to the file devops.txt. The second to seventh commands append the strings "Mango", "Banana", "Cherry", "Kiwi", "Orange", and "Guava" to the end of the file devops.txt, respectively. The \>> symbol is used to append the output of the echo command to the end of the file.
Now, if you run the cat command to display the contents of the devops.txt file, you will see:
This is the list of fruits written to the devops.txt file, with each fruit on a new line.
To Show only top three fruits from the file.
->head -n <filename.txt>
head command is used to show the top two (any number) fruits from devops.txt file with option -n.
To Show only bottom three fruits from the file.
-> tail -n <filename.txt>
tail command is used to show bottom two (any number) fruits from the devops.txt file with option -n.
To create another file Colors.txt and to view the content.
->touch Colors.txt to create the file.
->cat Colors.txt to view content of the file
The touch command is used to create empty file.
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
The first command writes the string "Red" to the Colors.txt file. The \> symbol is used to redirect the output of the echo command to the file Colors.txt. The second to eighth commands append the strings "Pink", "White", "Black", "Blue", "Orange", "Purple", and "Grey" to the end of the file Colors.txt, respectively. The \>> symbol is used to append the output of the echo command to the end of the file.
cat Colors.txt command display the content each color line by line.
To find the difference between fruits.txt and Colors.txt file.
-> diff :
The diff fruits.txt and Colors.txt show the difference between two files.
If there is no difference it shows nothing.
If there is difference then it shows the lines which are different from each other.
how different from each other.
#90daysofdevops #allaboutday3
Subscribe to my newsletter
Read articles from Jyoti Hegde directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Jyoti Hegde
Jyoti Hegde
Completed Engineering in Information Technology & I am learning DevOps. #DevOps #AWS #Cloud #Python