Day3, 90 Days of Devops Challenge
Table of contents
No headings in the article.
Task: What is the linux command to
To view what's written in a file.
To change the access permissions of files.
To check which commands you have run till now.
To remove a directory/ Folder.
To create a fruits.txt file and to view the content.
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 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.
To view what's written in a file.
The 'cat' command can be used to display the content of a file.
syntax: cat <filename>
To change the access permissions of file.
Linux chmod command is used to change the access permissions of files and directories. It stands for change mode.
syntax: chmod <options> <permissions> <file name\>
ex. Following “chmod” command will give the user permission to read, write and execute a file
- To check which commands you have run till now.
Linux history command is used to display the history of the commands executed by the user. It is a handy tool for auditing the executed commands along with their date and time.
syntax: history
- To remove a directory/ Folder.
rmdir command is used to delete a directory. But will not be able to delete a directory including a sub-directory. It means, a directory has to be empty to be deleted.
To create a file and view its content
vim command is used to create a file.
syntax: vim fruits.txt
cat command is used to view the content in the file.
Create a devops.txt file and add content on each line
Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava
syntax: vim devops.txt
after executing this command file gets created and opened in editor.
Now enter the fruits name in each line.
To view top three lines of devops.txt file
syntax: head -3 devops.txt
To see last three lines of devops.txt file
syntax: tail -3 devops.txt
Create a new file colors.txt using echo command and add content in it
while creating the file.
syntax : echo "Yellow,Red,Blue">colors.txt
Now to view the content use cat commnd nas below.
syntax: cat colors.txt
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey
syntax: vi colors.txt then hit 'i' to insert data in file.
To find the difference between fruits.txt and Colors.txt file.
diff stands for difference. This command is used to display the differences in the files by comparing the files line by line
syntax: diff Colors.txt fruits.txt