0% found this document useful (0 votes)
22 views2 pages

File Permission Commands in Linux

This document discusses using the chmod command to set different file permission combinations for the user, group, and others. It provides examples of creating files with execute-only, read-only, owner-only, and mixed permissions and validates the permissions were set correctly using ls -l.

Uploaded by

Raja Kashmiri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

File Permission Commands in Linux

This document discusses using the chmod command to set different file permission combinations for the user, group, and others. It provides examples of creating files with execute-only, read-only, owner-only, and mixed permissions and validates the permissions were set correctly using ls -l.

Uploaded by

Raja Kashmiri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Solution:

To create a file with ONLY execute rights for the user, group and other users:

shell

Copy code

$ cd /home/afnog

$ touch [Link]

$ chmod 111 [Link]

$ ls -l [Link]

The output of the last command should be:

css

---x--x--x 1 afnog afnog 0 Aug 5 16:07 [Link]

To create a file with ONLY readonly rights for the user, group and other users:

shell

Copy code

$ cd /home/afnog

$ touch [Link]

$ chmod 444 [Link]

$ ls -l [Link]

The output of the last command should be:

css

-r--r--r-- 1 afnog afnog 0 Aug 5 16:09 [Link]

To create a file with rwx rights ONLY for the owner (user) and no rights for anyone else:

shell

$ cd /home/afnog

$ touch [Link]

$ chmod 700 [Link]


$ ls -l [Link]

The output of the last command should be:

diff

Copy code

-rwx------ 1 afnog afnog 0 Aug 5 16:10 [Link]

To create a file with Owner (user) rights of rwx, Group Rights of x (only), Other user rights of r (only):

shell

Copy code

$ cd /home/afnog

$ touch [Link]

$ chmod 751 [Link]

$ ls -l [Link]

The output of the last command should be:

-rwx--xr-- 1 afnog afnog 0 Aug 5 16:11 [Link]

To check that all the files have been created with the correct permissions, run the command:

$ ls -l

The output should be:

diff

-r--r--r-- 1 afnog afnog 0 Aug 5 16:09 [Link]

---x--x--x 1 afnog afnog 0 Aug 5 16:07 [Link]

-rwx--xr-- 1 afnog afnog 0 Aug 5 16:11 [Link]

-rwx------ 1 afnog afnog 0 Aug 5 16:10 [Link]

This confirms that all the files have been created with the correct permissions as specified in the
assignment.

You might also like