Managing File and Directory Permissions
Understand file and directory permissions.
We'll cover the following
Checking permissions
If we’re the system administrator, or if we can run the sudo
command, we can change the permissions on files and directories anywhere on our system.
The file structure we made in the home directory is something other users on the machine could use, so let’s copy the structure into the /var
directory so others can access it. We use the sudo
command since we don’t have write access to the /var
directory:
$ sudo cp -r ~/files /var/files
Next, we get a long listing of the /var/files
directory, showing all hidden files. This lets us view the permissions of the /var/files
directory itself:
su temp
sudo mkdir -p files/{movies,music,photos,docs/{diagrams,markdown},code/{go,js,elm}}
clear
sudo cp -r /files /var/files
ls -alh /var/files
Run the complete code on the terminal below for practice.
Get hands-on with 1400+ tech skills courses.