Table of Contents

List Set And Change Standard Ugo Rwx Permissions

General Information

Ownership and permissions.


Permissions Overview

Permissions tools

Chmod Modes

Change file1 ownership to rjones and group to student

chown rjones:student file1

List Permissions

ls -l
-rw-r--r--. 2 root root          0 Jun 20 15:11 file1
-rw-r--r--. 2 root root          0 Jun 20 15:11 file2
drwxr-xr-x. 3 root root         17 Jun 20 14:50 newdir

Change Permissions

Symbolic

Add write permissions to a file for the group

chmod g+w file1

Take away read permissions for others, for all of dir1 directory and its contents

chmod -R o-r dir1

Add execute permissions to directories only in a tree

chmod -R ug+X dir1

Octal

Set file1 permissions using octal notation

chmod 740 file1

Setuid, Setgid, sticky bits

Add setuid to script1

chmod u+s script1


Same scenario, octal mode

chmod 4740 script1

When there are four numbers in chmod, the first is for setuid/gid/stickybit:


umask: default file/directory permissions

View current defaults

umask
0022


The above yields a file with the following permissions by default:

-rw-r--r--   1 user user    0 Jun 22 14:01 file1


Temporarily change the default for this session only

umask 266
 
touch testfile
ls -l
dr-x--x--x   2 user user 4096 Jun 22 14:09 testdir
-r--------   1 user user    0 Jun 22 14:08 testfile


Permanent umask changes (system wide)

vim /etc/bashrc
vim /etc/profile
 
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
       umask 002
    else
       umask 022
fi