DEV Community

Cover image for Hands-on Basic Linux Commands: #Day3 of 90DaysofDevOps
On-cloud7
On-cloud7

Posted on

Hands-on Basic Linux Commands: #Day3 of 90DaysofDevOps

Task: What is the Linux command to:

1. To view what's written in a file.

Viewing the Contents of a File: You can use the cat command to see what's written in a file. For example:

Image description

Image description

2. To change the access permissions of files.
To modify the access permissions of files, you can use the chmod command. For instance:

Image description

Image description

  1. chmod +rwx filename to add permissions

  2. chmod -rwx directoryname to remove permissions.

  3. chmod +x filename to allow executable permissions.

  4. chmod -wx filename to take out write and executable permissions.

Image description
There are three options for permission groups available to you in Linux.

owners: these permissions will only apply to owners and will not affect other groups.

groups: you can assign a group of users specific permissions, which will only impact users within the group.

users: these permissions will apply to all users, and as a result, they present the greatest security risk and should be assigned with caution.

There are three kinds of file permissions in Linux:

Read (r): Allows a user or group to view a file.

Write (w): Permits the user to write or modify a file or directory.

Execute (x): A user or group with execute permissions can execute a file or view a directory.

3. To check which commands you have run till now.

Image description

Image description
4. To remove a directory/ Folder.

Image description

Image description
5. To create a fruits.txt file and to view the content.

Image description

Image description

6. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

Image description

Image description
7. Show only the top three fruits from the file.

Image description

Image description
8. Show only the bottom three fruits from the file.

Image description

Image description

9. To create another file Colors.txt and to view the content.

Image description

Image description

10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.

Image description

Image description
11. To find the difference between fruits.txt and Colors.txt files.

Image description

Image description

Top comments (0)