You are on page 1of 3

CH-6-LAB: PERMISSIONS

OBJECTIVE:
To assign permissions for files and directories
PRE-REQUISITE:
Machine with Linux Installed
TOPOLOGY:

1. Adding a new directory(folder)


[root@localhost ~]# mkdir /myfolder
[root@localhost ~]# cd /myfolder/

2. Adding new file in directory


[root@localhost myfolder]# touch test_file
3. To check working username
[root@localhost myfolder]# whoami

Result:
root

4. To check an existing file/dir default permissions

[root@localhost myfolder]# Is -Id test_file


-rw-r--r--1 root root 0 sep 1 00:06 test_file

5. Set write permissions to the group level only by using Symbolic Mode

Syntax:
[root@localhost myfolder]# chmod <permission_mode> <file/dir_name>
[root@localhost myfolder]# chmod g+w test_file
Verification:
[root@localhost myfolder]# Is -Id test_file
-rw-rw-r--1 root root 0 Sep 1 00:06 test_file

6. Remove read permissions for others only by using symbolic mode


[root@localhost myfolder]# chmod o-r test_file

Verification:
[root@localhost myfolder]# Is -Id test_file
-rw-rw— 1 root root 0 Sep 1 00:06 test_file
7. Assign read, write and execute permissions to others only by using symbolic
mode

[root@localhost myfolder]# chmod o=rwx test_file

Verification:
[root@localhost myfolder]# Is -Id test_file
.,-rw-rw-rwx 1 root root 0 Sep 1 00:06 test_file

8. Assign execute permissions to owner, group and others by using symbolic


mode
[root@localhost myfolder]# chmod +x test_file

Verification:
[root@localhost myfolder]# Is -Id test_file
-rwxrwxrwx 1 root root 0 Jul 13 00:06 test_file

9. Remove write and execute permissions from group and others also.
[root@localhost myfolder]# chmod g-wx,o-wx test_file Verification:
[root@localhost myfolder]# Is -Id test_file
-rw-r-r-1 root root 0 Sep 1 00:06 test_file

10. Assign write permissions to others by using Absolute Mode(Numeric


Mode)

Syntax:
[root@ local host myfolder]# chmod <permission_modexfile/dir>
[root@localhost myfolder]# chmod 646 test_file
Verification:
[root@localhost myfolder]# Is -Id test_file
-rw-r--rw-1 root root 0 sep 1 00:06 test_file

11. Assign full permissions to owner, group and others on admin directory
using Absolute Mode

[root@localhost ~]# chmod 777 /root


#### OR #####

12. Assign full permissions to owner, group and others on admin directory using
Symbolic Mode

[root@localhost ~]# chmod u+rwx,g+rwx,o+rwx /root

13. To find result, add a normal user and try to access file as a normal user
[root@localhost myfolder]# useradd zoomuser
[root@localhost myfolder]# su – zoomuser
[zoomuser@localhost ~]$ cd /root/myfolder

Verification:
[zoomuser@localhost myfolder]$ cat»test_file This is a zoom user file Ctrl+d (to
save data)
[zoomuser@localhost myfolder]$ cat test_file
This is a zoom user file

Verification:
[root@localhost ~]# Is-ld /root
drwxrwxrwx 2 root root 4096 Sep 1 02:22 /root
Note: user can read and write in file because file is having read and write
permissions on other level

END

You might also like