Day 3 Task: Basic Linux Commands with a Twist
Task: What are the Linux commands to
View the content of a file and display line numbers.
cat -n <filename>
Change the access permissions of files to make them readable, writable, and executable by the owner only.
Check the last 10 commands you have run.
history | tail -10
Remove a directory and all its contents.
rm -r directoryname
Create a
fruits.txt
file, add content (one fruit per line), and display the content.Add content in
devops.txt
(one in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava. Then, append "Pineapple" to the end of the file.Show the first three fruits from the file in reverse order.
Show the bottom three fruits from the file, and then sort them alphabetically.
Create another file
Colors.txt
, add content (one color per line), and display the content.echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" > Colors.txt
Add content in
Colors.txt
(one in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey. Then, prepend "Yellow" to the beginning of the file.echo -e "Yellow\n$(cat Colors.txt)" > Colors.txt
Find and display the lines that are common between
fruits.txt
andColors.txt
.Count the number of lines, words, and characters in both
fruits.txt
andColors.txt
.
Subscribe to my newsletter
Read articles from Khushbu Koradiya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by