CSchantz Wiki

Advanced File Management

Advanced File Management

This covers things like the following

File and Directory Access Permissions

Permissions Classes

Permissions types

Permission Modes

drwxr-xr-x. 1 root     root            54 Jan 23  2024

This shows starting with the [-] that it is a normal file

-rw-r--r--. 1 root   root     3216 May 16 12:50 passwd

Now for a directory it would have a [d] to start

drwxr-xr-x. 1 root   root       28 Feb 13 19:00 nvme

For a symbolic link [l]

lrwxrwxrwx. 1 root   root       16 Mar  6 19:00 opensc-x86_64.conf -> /etc/opensc.conf

For a character device it would be a [c]

crw-rw----.  1 root     tty         7, 132 Jul 25 12:42 vcsa4

For a block device it would be a [b]

brw-rw----.  1 root     disk      252,   0 Jul 25 12:42 zram0

For a Named Pipe [s]

prw-------.  1 root     root          0 Jul 25 12:42 dmeventd-client

For a socket [s]

srwxr-xr-x.  1 root     root          0 Jul 25 12:42 mcelog-client

Modifying Access permission bits 

Octal
Value
Binary
Notation
Symbolic
Notation
Explanation
0 000 --- No permissions
1 001 --x Execute only
2 010 -w- Write only
3 011 -wx Write and Execute
4 100 r-- Read only
5 101 r-x Read and Execute
6 110 rw- Read and Write
7 111 rwx Read, Write, and Execute

Let us do some testing

touch test

This creates the file

Assign testing permissions

chmod 444 test

You may have guessed it this should modify permissions to a r-- r-- r-- file.

-r--r--r--.  1 user1 user1    0 Jul 25 14:45 test

The first grouping is the owner permission state, the second grouping is the group permissions state, and the last grouping is the everyone permission state

Lets break this down

[-] [r--] [r--] [r--]

Modify Permissions Bits Using Symbolic Form

1. Lets adjust the testing on the file so that the the owner can execute and the group and others can write

chmod u+x test -v
[root@rhel01 ~]# chmod u+x test -v
mode of 'test' changed from 0444 (r--r--r--) to 0544 (r-xr--r--)

You can now see that in for the first permission state bracket that the user has read and execute permissions [r].

2. Lets add the write permission for the group (you can put the -v after the command or at the end of the command)

chmod -v go+w test
[root@rhel01 ~]# chmod -v go+w test
mode of 'test' changed from 0544 (r-xr--r--) to 0566 (r-xrw-rw-)

Now you can see the group and others had read and write in their state brackets [rw].

3. Lets remove the write permissions for other users

chmod -v o-w test
[root@rhel01 ~]# chmod -v o-w test
mode of 'test' changed from 0566 (r-xrw-rw-) to 0564 (r-xrw-r--)

So now in the other state bracket the write permissions were removed

4.Now lets assign read, write, and execute to all of the categories at once.

chmod -v a=rwx