Create three users:
Example:
[root@test119 ~]# useradd kavita
[root@test119 ~]# useradd ramu
[root@test119 ~]# useradd srinu
Make ramu the member of the group kavita
Example:
[root@test119 ~]# gpasswd -a ramu kavita
Adding user ramu to group kavita
Create a directory
Example:
[root@test119 ~]# mkdir /linux
Check the default permission of the above created directory
[root@test119 ~]# ls -ld /linux/
drwxr-xr-x 2 root root 4096 Aug 28 11:26 /linux/
Give full permissions to the above created directory
Example using absolute mode
[root@test119 ~]# chmod 777 /linux/
(or)
Example using symbolic mode
[root@test119 ~]# chmod ugo=rwx /linux/
Check the permissions on the directory
[root@test119 ~]# ls -ld /linux/
drwxrwxrwx 2 root root 4096 Aug 28 11:26 /linux/
Log in as the user kavita
Example:
[root@localhost~]# su -kavita
As user kavita create a file inside the above created directory
-sh-4.1$ cd /linux/
-sh-4.1$ ls
-sh-4.1$
-sh-4.1$ cat >fedora
This is a version of linux operating system
ctrl+D
Check the permisson on the file
Example:
-sh-4.1$ ls -l
total 4
-rw-r--r-- 1 kavita kavita 44 Aug 28 11:41 fedora
Explaination
1. The user kavita has Read and Write permission on this file
2. The group kavitha has read and write permisson on this file (as ramu is a member of the group kavita he will also have rad and write permisson).
3. Others will have read only permisson ( as srinu belong to others he will have only read permisson).
To check the permissons
Example:- As kavita try to read and add some content to the file
-sh-4.1$ cat fedora
This is a version of linux operating system
-sh-4.1$ cat >> fedora
This line has been added by kavita
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
Example:- As ramu try to read and add some content to the file ( open another terminal and do the following)
-sh-4.1$ su - ramu
Password:
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
-sh-4.1$ cat >> fedora
This line has been added by ramu
Example:- As srinu to read and add some content to the file (Open another terminal and do the following)
[root@test119 ~]# su - srinu
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
cat: fedora: Permission denied
Change the permisson on the above file
Example:- Remove write permission for the group kavita
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ chmod g=r fedora
-sh-4.1$ ls -l
total 4
--w-r---w- 1 kavita kavita 106 Aug 28 12:04 fedora
Check the permisson on the above file
Example:- As ramu try to read and add some content to the file
-sh-4.1$ su - ramu
Password:
-sh-4.1$ whoami
ramu
-sh-4.1$
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
This line is added by ramu
-sh-4.1$ cat >> fedora
-sh: fedora: Permission denied
Change the permisson on the above file
Example:- Give write permission for others
-sh-4.1$ su - kavita
Password:
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ chmod 646 fedora
-sh-4.1$ ls -l
total 4
-rw-r--rw- 1 kavita kavita 106 Aug 28 12:04 fedora
check the permisson on the above file
Example:- As srinu try to read and add some content to the file
[root@test119 ~]# su - srinu
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
This line is added by ramu
-sh-4.1$ cat >> fedora
This line has been added by srinu
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
This line is added by ramu
This line has been added by srinu
Example:
[root@test119 ~]# useradd kavita
[root@test119 ~]# useradd ramu
[root@test119 ~]# useradd srinu
Make ramu the member of the group kavita
Example:
[root@test119 ~]# gpasswd -a ramu kavita
Adding user ramu to group kavita
Create a directory
Example:
[root@test119 ~]# mkdir /linux
Check the default permission of the above created directory
[root@test119 ~]# ls -ld /linux/
drwxr-xr-x 2 root root 4096 Aug 28 11:26 /linux/
Give full permissions to the above created directory
Example using absolute mode
[root@test119 ~]# chmod 777 /linux/
(or)
Example using symbolic mode
[root@test119 ~]# chmod ugo=rwx /linux/
Check the permissions on the directory
[root@test119 ~]# ls -ld /linux/
drwxrwxrwx 2 root root 4096 Aug 28 11:26 /linux/
Log in as the user kavita
Example:
[root@localhost~]# su -kavita
As user kavita create a file inside the above created directory
-sh-4.1$ cd /linux/
-sh-4.1$ ls
-sh-4.1$
-sh-4.1$ cat >fedora
This is a version of linux operating system
ctrl+D
Check the permisson on the file
Example:
-sh-4.1$ ls -l
total 4
-rw-r--r-- 1 kavita kavita 44 Aug 28 11:41 fedora
Explaination
1. The user kavita has Read and Write permission on this file
2. The group kavitha has read and write permisson on this file (as ramu is a member of the group kavita he will also have rad and write permisson).
3. Others will have read only permisson ( as srinu belong to others he will have only read permisson).
To check the permissons
Example:- As kavita try to read and add some content to the file
-sh-4.1$ cat fedora
This is a version of linux operating system
-sh-4.1$ cat >> fedora
This line has been added by kavita
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
Example:- As ramu try to read and add some content to the file ( open another terminal and do the following)
-sh-4.1$ su - ramu
Password:
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
-sh-4.1$ cat >> fedora
This line has been added by ramu
Example:- As srinu to read and add some content to the file (Open another terminal and do the following)
[root@test119 ~]# su - srinu
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
cat: fedora: Permission denied
Change the permisson on the above file
Example:- Remove write permission for the group kavita
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ chmod g=r fedora
-sh-4.1$ ls -l
total 4
--w-r---w- 1 kavita kavita 106 Aug 28 12:04 fedora
Check the permisson on the above file
Example:- As ramu try to read and add some content to the file
-sh-4.1$ su - ramu
Password:
-sh-4.1$ whoami
ramu
-sh-4.1$
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
This line is added by ramu
-sh-4.1$ cat >> fedora
-sh: fedora: Permission denied
Change the permisson on the above file
Example:- Give write permission for others
-sh-4.1$ su - kavita
Password:
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ chmod 646 fedora
-sh-4.1$ ls -l
total 4
-rw-r--rw- 1 kavita kavita 106 Aug 28 12:04 fedora
check the permisson on the above file
Example:- As srinu try to read and add some content to the file
[root@test119 ~]# su - srinu
-sh-4.1$ cd /linux/
-sh-4.1$ ls
fedora
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
This line is added by ramu
-sh-4.1$ cat >> fedora
This line has been added by srinu
-sh-4.1$ cat fedora
This is a version of linux operating system
This line has been added by kavita
This line is added by ramu
This line has been added by srinu