Hands-on Basic Linux Commands: #Day3 of 90DaysofDevOps
Tags: devops, linux, awschallenge, 90daysofdevops
Published: 2024-06-03 16:29:07

**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b0cqj7dylposvq0jt2i6.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xj512vqu8pjo960rqr57.png)

**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tom2lo9t4vzkqk2xru6s.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1kj8eezfed9pvnjh4k17.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jpsqyosovm8nbpu04e0t.png)
**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bfrbndibk3yr5dgc6km9.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m8do5k4qkiyu342i9vzw.png)
**4. To remove a directory/ Folder.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eege2hn9e2n668wzxem0.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qcm6251jiu9y6odadnss.png)
**5. To create a fruits.txt file and to view the content.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o1xcqqfv9wjdyrk6dbb9.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8tgx9ll4q8c8iz764ml.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/scydfh2npciox52cl1t8.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o28yzhczbdjc2yig88wn.png)
**7. Show only the top three fruits from the file.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0yzh74seh8lx7rlkrf0v.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecr3s0uvihze7hi7wqgh.png)
**8. Show only the bottom three fruits from the file.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34z1896hzww3bxh1c9e9.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbqxclp88mrwmwjvbm4e.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ggzuxo3i3lto3i57muft.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9b3pc7q4ysw16448072m.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ie01ciq56z35vwfd5k8i.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65trdci6by8aci9dr82k.png)
**11. To find the difference between fruits.txt and Colors.txt files.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qii9rtjv2sybpbenxhai.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/piid44z8q273wbm36ehb.png)