Basic Linux Commands
We will see some basic commands as 90DaysChallege then will see most used linux command for Devops.
- To view what's written in a file : To view the contents of a file in Linux, you can use the
catcommand.
cat firstfile.txt
- To change the access permissions of files: To change the access permissions of files in Linux, you can use the
chmodcommand. Thechmodcommand allows you to set permissions for the owner of the file, the group that the file belongs to, and all other users.
chmod 700 firstfile.txt
you can refer permission table to give the required permission:

- To check which commands you have run till now:
To check the list of commands that you have run previously in the terminal, you can use the history command.
To remove a directory/ Folder :
To remove a directory or folder in Linux, you can use the
rmdirorrmcommand depending on whether the directory is empty or not.If the directory is empty, you can use the
rmdircommand to remove it. Simply open up a terminal and type the following command, replacingdirectory_namewith the name of the directory that you want to remove:rmdir firstfolderIf the directory is not empty, you can use the
rmcommand with the-roption to recursively remove the directory and its contents. This will remove all files and subdirectories within the directory, so use it with caution.rm -r firstfolderTo create a fruits.txt file and to view the content :
To create a file named
fruits.txtin Linux, you can use a text editor likenano,vim, orgedit. Here's an example of how to create and edit the file using the vim editor.vim fruits.txtOnce you're in the editor, press the
ikey to enterInsertmode. This will allow you to start typing and add content to the file.Type the content you want to add to the file.
Once you've finished adding the content, press the
Esckey to exitInsertmode.To save the changes to the file and exit
vim, either you can type:wdor:xyou can view its contents using the
catcommand or other text editors or viewers.cat fruits.txt
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava :
To add the contents "Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava" in separate lines to a file named devops.txt using the echo command in Linux, you can use the following command:
echo -e "Apple\nMango\nBanana\nCherry\nKiwi\nOrange\nGuava" > devops.txt
This will add the contents to the devops.txt file in separate lines. Here's a breakdown of the command:
echo: This is the command used to print text to the terminal.-e: This option enables the interpretation of backslash escapes in the string. It allows us to use\nto create new lines in the output.
- To Show only top three fruits from the file.
To show only the top three fruits from the devops.txt file, you can use the head command in Linux along with the -n option. Here's how to do it:
head -n 3 devops.txt
The -n option allows you to specify the number of lines you want to display.
To Show only the bottom three fruits from the file :
To show only the bottom three fruits from the
devops.txtfile, you can use thetailcommand in Linux along with the-noption. Here's how to do it:tail -n 3 devops.txtTo find the difference between Two files(fruits.txt and Colors.txt file).
To find the difference between the
fruits.txtandColors.txtfiles in Linux, you can use thediffcommand. Here's how to do it:diff fruits.txt Colors.txtThis command will display the differences between the two files, if any. If the files are identical, there will be no output. If there are differences, the output will show which lines are different.
Now we will see some important and most used commands for DevOps.
ls: List the contents of a directory.cd: Change the current working directory.mkdir: Create a new directory.rm: Remove a file or directory.cp: Copy files or directories.mv: Move or rename files or directories.grep: Search for a pattern in a file.sed: Stream editor for filtering and transforming text.awk: Pattern scanning and processing language.cat: Concatenate and display files.tail: Display the last lines of a file.head: Display the first lines of a file.chmod: Change file permissions.chown: Change file ownership.ssh: Securely connect to a remote server.scp: Securely copy files between hosts.rsync: Efficiently synchronize files and directories.tar: Archive files and directories.curl: Transfer data from or to a server using various protocols.wget: Retrieve files from the web using various protocols.
This was the challenge for day 3 to learn Linux commands. If you any suggestion please do command.
Happy learning



