Linux Permission commands

Linux Permission commands

Every file and directory in your Linux system has the following 3 permissions defined for all the 3 owners discussed above.

Read: This permission give you the authority to open and read a file.

Write: The write permission on a directory gives you the authority to add, remove and rename files stored in the directory

Execute: In Windows, an executable program usually has an extension “.exe” and which you can easily run. Linux, you cannot run a program unless the execute permission is set. If the execute permission is not set, you might still be able to see/modify the program code(provided read & write permissions are set), but not run it.

Let’s see file permissions in Linux with examples:

ls – l  This list command will show the file permissions

[oracle@oracletest scripts]$ ls -l
total 24
-rw-rw-r--. 1 oracle oracle 42 Oct 21 01:49 kiruba.txt
-rwxrwxr-x. 1 oracle oracle 1291 Oct 20 23:47 rman_bkp.sh
-rw-rw-r--. 1 oracle oracle 6979 Oct 20 23:48 rman.log
-rwxr--r--. 1 oracle oinstall 515 Sep 9 14:45 setEnv.sh
-rwxr--r--. 1 oracle oinstall 134 Sep 7 10:54 stop_all.sh

So, Here we listed some files with permissions

r = read permission
w = write permission
x = execute permission
 = no permission

permissions with chmod command

We can use the chmod command which stands for change mode. Using the command, we can set permissions (read, write, execute) on a file/directory for the owner, group.

There are 2 ways to use the command

  • Absolute mode
  • Symbolic mode

Absolute(Numeric) Mode

In this mode file permissions are not represented as characters, we can give in a three-digit octal number.

NumberPermission TypeSymbol
0No Permission
1Execute–x
2Write-w-
3Execute + Write-wx
4Readr–
5Read + Executer-x
6Read +Writerw-
7Read + Write +Executerwx

Example: chmod three-digit octal number filename

chmod 777 kiruba.txt

we were given this permission to text file we can able to read, write and execute the specified file

 

Symbolic Mode

In the Absolute mode, we can change permissions for all 3 owners. In the symbolic mode, we can modify the permissions of a specific owner also make use of mathematical symbols to modify the Linux file permissions.

OperatorDescription
+Adds permission to a file or directory
Removes the permission
=Sets the permission and overrides the permissions set earlier.

The various owners are represented as –

User Denotations
uuser/owner
ggroup
oother
aall

Changing Ownership and Group:

changing the ownership of a file/directory we can use the following command

chown user filename

Eg: chown kiruba rman_backup.log

To change group-owner only, use the command

chgrp group_name filename

Eg: chgrp oracle rman.log

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter: https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8