User File Permissions
System Users and Permissions
All files within a Linux system define permissions for owner, group, and others.
The available permissions for any given owner, group, and other users is as follows:
Read
Write
Execute
None
An owner, group, or other users can have any combination of the above permissions.
The following list shows all possible options:
Read only
Write only
Execute only
Read and Write
Read and Execute
Write and Execute
Read, Write, and Execute
None
Viewing Permissions in Terminal
Open up a terminal and navigate to the home directory if necessary.
View all the contents of the home directory with:
ls -l
For each non hidden file found by ls -l
the following is displayed:
- file type
- file permissions
- number of contained folders
- file owner
- file group
- file size (in bytes)
- file last touched date
- file name
Output:
The line with the Desktop
directory can be broken down as follows:
- file type:
d
for directory - file permissions:
rwxr-xr-x
- number of contained files:
4
- file owner:
student
- file group:
student
- file size (in bytes):
4096
bytes (4
kilobytes) - file last touched date:
Apr 20 10:00
- file name:
Desktop
The file permissions section defines read, write and execute permissions for each of the file owner, file group, and all other users.
rwxr-xr-x
is broken into three:
rwx
: the file owner has read, write and execute permissionsr-x
: the file group has read and execute permissionsr-x
: all other users have read and execute permissions
Bringing it together:
drwxr-xr-x 4 student student
:- Directory that allows the
student
user toRead, Write, and Execute
, thestudent
group toExecute and Read
, and all others toExecute
only.
- Directory that allows the
The line with the snap
directory is as follows:
drwx------ 4 student student
:- Directory that allows the
student
owner toRead, Write, and Execute
, thestudent
group hasNone
permissions, and all other users haveNone
permissions.
- Directory that allows the
Alternate Users
Now that you have a basic understanding of the user and file permissions structure lets take a look at a different directory with alternate users.
Using the ls -l
command view the file permissions for all files within the root directory:
ls -l /
Output:
Take note that all folders and files located within the root directory belong to the root
user and root
group.
/usr/
File Permission Breakdown
drwxr-xr-x 21 root root 4096 Apr 20 10:20 tmp
drwxr-xr-x
:
d
: file is of the directory typerwx
: root owner has read, write and execute privilegesr-x
: root group has read and execute privilegesr-x
: all other users have read and execute privileges
/lost+found/
File Permission Breakdown
drwx------ 2 root root 16384 Mar 11 14:32 lost+found
drwx------
:
d
: file is of the directory typerwx
: the root owner has read, write and execute privileges---
: the root group has no permissions---
: all other users have no permissions
You may also notice that some of the lines begin with an l
. The first character on the line will always provide what type of file it is. In this particular example the l
signifies a symbolic link. The other types of files you may see are as follows:
-
: regular filed
: directoryc
: character device fileb
: block device files
: socket filel
: symbolic link
You are not expected to fully understand any of the special file types in this course.