Skip to main content

Command Palette

Search for a command to run...

๐Ÿ› ๏ธ Linux DevOps Toolbox: Elevate Your Productivity with Command-Line Magic ๐Ÿš€๐Ÿ’ก

Day-3 Task of 90 Days Of Devops

Published
โ€ข4 min read
๐Ÿ› ๏ธ Linux DevOps Toolbox: Elevate Your Productivity with Command-Line Magic ๐Ÿš€๐Ÿ’ก
V

Experienced QA professional with a passion for manual and automation testing. Proficient in DevOps practices, ensuring seamless integration and continuous delivery. Dedicated to ensuring top-notch software quality and efficiency. Eager to contribute my skills to Hashnode's vibrant tech community. Let's collaborate and create exceptional experiences!

Linux is a powerful operating system with a wealth of commands to manage files and directories efficiently. In this blog, we will explore several fundamental Linux commands to perform various file operations. In this blog, we will explore several fundamental Linux commands to perform various file operations. Let's dive in! ๐Ÿš€

๐Ÿ‘๏ธ๐Ÿ“„To View the contents of a file

Cat - This Linux command allows you to view the contents of a file

Simply type cat filename & Press Enter

Replace "filename" with the name of the file you want to view.

๐Ÿ”’๐Ÿ”‘Change access permissions of files

chmod -To modify the access permissions of a file, use the chmod command followed by the permission code and the file name.

The permission code consists of three digits representing read (4), write (2), and execute (1)permissions for the owner, group, and others, respectively.

Simply type chmod 644 filename& Press Enter

For example - To give read and write permissions to the owner (4 for read + 2 for write = 6) and read-only permissions to the group (4) and others (also 4):

Here's a breakdown of the numeric representation as per the command

The first digit (6) represents the permissions for the owner (read + write). The second digit (4) represents the permissions for the group (read). The third digit (also 4) represents the permissions for others (read). Replace "filename" with the name of the file you want to modify. After running this command, the owner will have read and write permissions, while the group and others will have read-only permissions.

โฒ๏ธ๐Ÿ“œCheck your command history

history -To view the list of commands you have run in the terminal session history.

Simply type history& Press Enter

This will display a numbered list of commands you executed during the current session.

๐Ÿ—‘๏ธ๐Ÿ“Remove a directory/folder

rm - To remove a directory/ Folder.

Simply type rm filename/directoryname & Press Enter

๐Ÿ“๐ŸŽCreate a fruits.txt file and view its content

touch - To create an empty file named "fruits.txt,"

cat -To view the contents of the file (we discussed earlier)

Simply type touch filename & Press Enter

then ,type cat filename & Press Enter

๐Ÿ“๐ŸŽAdd content in fruits.txt (One in each line)

Vim - To open a file to add content

Simply type vim filename Press Enter

Inserting Text: To start inserting or editing text within the file, press i for insert mode. You can then type or modify text as needed.

Saving and Exiting: To save the changes and exit vim, press Esc to ensure you are in normal mode, and then type :wq or ZZ (Shift + zz) Press Enter

๐Ÿ”๐ŸŽ๐Ÿ‹๐ŸŒTo Show only the top three fruits from the file

head - To display the top lines of the file

Simply type head -3 filename Press Enter

you can also use the head command with the -n option

๐Ÿ”ป๐Ÿฅ๐ŸŠ๐ŸTo Show only the bottom three fruits from the file

tail -To display the last lines of the file,

Simply type head -3 filename Press Enter

you can also use the tail command with the -n option

๐Ÿ“๐ŸŽจ๐ŸŒˆTo create another file with content in Colors.txt (One in each line) and to view the content.

We already discussed this earlier touch ,vim & cat command

๐ŸŽ๐Ÿ†š๐ŸŽจTo find the difference between fruits.txt and Colors.txt file

diff - To compare the contents of two files and find the differences

Simply type diff filename1 filename2 Press Enter

The diff command will display the lines that are different between the two files, if any.

With these essential Linux commands, you can efficiently manage and manipulate files and directories in your system.๐Ÿš€๐Ÿš€๐Ÿš€

๐ŸŒˆSo, I hope you found this blog helpful!

๐Ÿค”If you have any questions or need further assistance, please let me know in the comments section below. I am here to support you on your learning journey.

โœŒIf you found this information valuable, consider following me on Hashnode for more insightful blogs. Stay tuned for future articles filled with exciting content.

๐Ÿš€๐Ÿš€Happy learning!๐Ÿค—