Photo by Sincerely Media on Unsplash
#Day 3- Linux Important Command
Welcome back Guys :) On the Thrilled Journey of #90DaysOfChallenge . Today will learn some more important Commands of LINUX .
For Changing File Permissions:
Linux empowers you to control who can access your files. The chmod
command is your key to managing permissions. For example:
This command changes the permissions of the file content.txt so that only the owner can read and modify it, while others have no access.
Removing Directories:
If you need to tidy up your digital space by removing directories, Linux offers two powerful commands: rmdir for empty directories and rm -r for directories with content. For example:
Creating and Viewing Files:
Creating a new file is as simple as pie with the touch command. To create a file named "fruits.txt," simply enter:
Once created, you can view the file's contents using the cat command:
Viewing File Contents:
Linux provides the cat command to satisfy your curiosity. Just type cat filename, and you'll see the magic unfold
This reveals the entire content of the file content.txt. It's like opening a treasure chest to find the hidden gems inside.
Creating and Comparing Another File:
You can create another file, like "Colors.txt," using the touch command. Then, add content using echo.
To compare "fruits.txt" and "Colors.txt" and see the differences, the diff command is your guide:
Displaying Top and Bottom Lines:
If you're looking for a quick overview of a file, Linux offers two handy commands: head
and tail
. To display the top three fruits from "fruits.txt," use:
This provides a glimpse of the first three lines in the file.
Now, to show only the bottom three fruits from a file, you can use the tail command with the -n option to specify the number of lines you want to display.
This command will display the last three lines from the "fruits.txt" file, which is like plucking the last three fruits from your basket. It's a useful way to view the end of a file, especially when you have a large document or log file.
Adding Content to Files:
The echo command helps you add content to your files. For example, to create a "devops.txt" file and populate it with a list of fruits, use:
This command adds each fruit on a new line within "devops.txt."