Mastering Essential Linux Commands 2

Mastering Essential Linux Commands  2

Welcome back to our Linux learning adventure!

A Beginner's Guide Part 2

In this article, we'll go over some basic Linux commands that will allow you to execute basic activities with ease. Everything from file manipulation to directory management will be covered. So, put on your virtual hard hat and let's begin!πŸ‘·β€β™‚οΈπŸ‘·β€β™€οΈ

In Linux, you can create files with almost any file extension or no extension at all. Unlike some other operating systems, Linux does not restrict the creation of files based on their extensions. You are free to use any combination of characters, including periods (.) in filenames.

There are various ways to create a file in Linux. Here are some common approaches.

Using the touch command: You can use the touch command to create an empty file. As an example,

Using touch command :

touch file.txt

Using vim editor :

vim file1.txt

After opening vim editor, Press the 'i' key to enter insert mode and type your text.

Press the "Esc" key to exit insert mode and return to normal mode. Then type ":wq" and press "Enter" This command tells Vim to write (save) the file and exits from the editor.

View File Content πŸ“„

Have you ever wondered what's inside a file without opening it? The cat command in Linux will take care of you. Simply type:

cat file1.txt

Changing File Permissions πŸ—„:

To change file permissions, we use the "chmod" command, which stands for change mode. The "chmod" command is as follows with example :

Checking the current permission with file

Now, try to the file permission to make file1.txt executable.

You can see the the above file is made as a Executable.

View Command History πŸ“š

To see your command history, simply use the history command:

history

Remove a Directory/Folder πŸ—‘οΈ

Using the rmdir command, you can easily delete a directory:

In our directory, there is "dir1" is present so now we have to remove it by following

rmdir dir1

Create and View File Content πŸŽπŸ“

For example, consider creating a file: you can use the echo command & to view its content, we'll use the cat command again

echo "Here no fruits names are saved" > fruits.txt
cat fruits.txt

Similarly, create a file "devops.txt" (one per line) for content added in one line - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

Note: In devops.txt we added the fruit name, don't be confused.

echo -e "Apple\nMango\nBanana\nCherry\nKiwi\nOrange\nGuava" > devops.txt

Display the top three fruits πŸ™„

head -n 3 devops.txt

Display the bottom three fruits πŸ™„

tail -n 3 devops.txt

Create and Manipulate with file πŸ‘¨β€πŸ”§

Repeat the process to create, add and view the Colors.txt file

echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" > Colors.txt

Find the Differen😲

The diff command can be used to compare the contents of fruits.txt and Colors.txt:

diff fruits.txt Colors.txt

The --- line in the "diff" output represents the separator line that separates the differences between the two files. In the context of the "diff" command's output, it's used to indicate a change or difference between the two files.

Congratulations! You've just mastered some basic Linux commands. These skills will serve as a strong foundation for your Linux journey. 🌟

I hope you enjoy the blog post!

If you do, please show your support by giving it a like ❀, leaving a comment πŸ’¬, and spreading the word πŸ“’ to your friends and colleagues 😊

Did you find this article valuable?

Support Vyankateshwar Taikar's blog by becoming a sponsor. Any amount is appreciated!