Task: Basic Linux Commands

Task: Basic Linux Commands

In this article, we'll explore fundamental Linux commands frequently used in everyday tasks involving Linux as the operating system.

Task: What is the linux command to

1. Viewing the content of a file ??

To view the contents of a file in Linux, you can use the “cat” command. For example, let’s say you have a file named “Example.txt” To view what’s written in this file, open your terminal and write cat Example.txt

2.Changing the access permissions of files ??

Changing the access permissions of files in Linux is done using the “chmod” command, which stands for “change mode.”

In Linux, every file has three types of permissions: read (r), write (w), and execute (x). These permissions can be set for three different categories of users: the file’s owner (u), the group (g) the file belongs to, and others (o) who are not the owner or part of the group.

  • “chmod u+rwx example.txt” grants read, write, and execute permissions to the file owner. Here’s an example

3. Checking the command history ??

To check the commands you have run in the current terminal session in Linux, you can use the “history” command.

4. Removing a directory/folder ???

Removing a directory or folder in Linux is done using the “rm -r” or “rm” command. ???

The “rm -r” command is used specifically to remove empty directories and "rm" is used to remove files. For example:

5. Creating and viewing the content of fruits.txt ??

To create a “fruits.txt” file in Linux, you can use the “vim” and "cat" command. ??

For example

6. Adding content to Devops.txt (One in each line)

To add content to the “Devops.txt” file, you can use a text editor or the “vim” command to append each fruit on a new line. Here’s an example using the “vim” command:

7. Showing the top three fruits from Devops.txt ??

To display only the top three fruits from the “devopss.txt” file, we can use the “head” command with the “-n” option, specifying the number of lines we want to see. In this case, we want to see the first three lines, which represent the top three fruits in the file

8. Showing the bottom three fruits from Devops.txt??

To display only the bottom three fruits from the “Devops.txt” file, you can use the “tail” command with the “-n” option, specifying the number of lines you want to see from the end of the file. In this case, we want to see the last three lines, which represent the bottom three fruits in the file

9. Creating and viewing the content of Colors.txt??

To create a new file called “Colors.txt” in Linux, you can use the “touch” command followed by the desired filename. This command will create an empty file named “Colors.txt” in the current directory. Now, to view the content of the file, you can use the “cat” command:

10. Adding content to Colors.txt (One in each line)

To add the specified content to the “Colors.txt” file with each color on a separate line, you can use the following command:

11. Finding the difference between fruits.txt and Colors.txt ????

To find the difference between the contents of two files, such as “fruits.txt” and “Colors.txt” you can use the “diff” command. Here’s an example:




要查看或添加评论,请登录

Mamta Kumari的更多文章

  • Basic Linux Shell Scripting for DevOps

    Basic Linux Shell Scripting for DevOps

    Tasks 1 . Explain in your own words and examples, what is Shell Scripting for DevOps.

  • Basics linux command

    Basics linux command

    What is Linux? LINUX is an open-source operating system (OS). It is based on UNIX.

  • DevOps

    DevOps

    What is DevOps? DevOps is a software development methodology that accelerates the delivery of higher-quality…