Day-3 of DevOps Challenge: Today's task is all about basic Linux commands with a twist.
View the content of a file and display line numbers. ๐๐ฌ
Change the access permissions of files to make them readable, writable, and executable by the owner only. ๐๐จโ๐ป
Remove a directory and all its contents ๐๏ธ
Create a fruits.txt
file ๐, add one fruit per line ๐๐๐, and then display the content ๐.
Add content to devops.txt
(one item on each line) ๐ Apple, ๐ฅญ Mango, ๐ Banana, ๐ Cherry, ๐ฅ Kiwi, ๐ Orange, ๐ Guava. Then, add "๐ Pineapple" to the end of the file.
Show the first three fruits from the file in reverse order.
tac
: Reverses the order of the lines from the output of the head
command.
tail -n 3 devops.txt: Displays the last three lines of the devops.txt file.
sort: Sorts the lines alphabetically.
Create another file Colors.txt, add content (one color per line), and display the content.
Add content in Colors1.txt (one in each line) - Red, Pink, White, Black. Then, prepend "Yellow" to the beginning of the file.
-i flag tells sed to edit the file in place.
1iYellow inserts "Yellow" at line 1 (the beginning) of Colors.txt.
Find and display the lines that are common between fruits.txt and Colors.txt.
First, ensure both fruits.txt and Colors.txt are sorted. This is necessary because comm expects sorted input.
-12
option suppresses lines unique to the first (-1
) and second (-2
) file, showing only the lines that are common (-12
).Count the number of lines, words, and characters in both
fruits.txt
andColors.txt
.
Df (disk free) command will have an account of available disk space, used by file system.
Du (disk usage) command reports the size of directory tree including all the content.
Useradd Command create user
Grep Command how to searches for a particular string/ word in a text file.
Ping โ This command will ping a host and check if it is responding.