Day 6 : Cloud and DevOps
File Permissions and Access Control Lists
⚡File Permissions:
Linux file system determines who can access files and directories on a system and how. This blog gives an overview of Linux file permissions, how they work, and how to change them.
-- To View the permissions -> we use the ls -l command
Here we see the metadata of files and directories -
🌟Type of Ownership - 3 types
-- user (u) - This is applied only to the owner of the file or directory.
-- group (g) - This is applied to the group assigned to the file or directory and does not affect the actions of other users.
-- other users (o) - This is applied to all other users on the system.
🌟Security permissions -
File permissions -
Read - This permission is used to access the file's content. Read permission is required to make copies of a file because we need to access the file's content to duplicate it.
-- We can use cat or less commands to see the file content.
Wite - Required to modify or change the file content.
Execute - Allows us to execute the content of a file like a bash shell script, python programs, etc.
Directory permissions -
Read - This allows us to read the contents of the directory which means we can view the content (file or dir) stored within the directory. This is required for the ls command.
Write - This allows us to modify the content of the directory.
-- Create or copy files into the directory.
-- Move or remove files from the directory.
Recommended by LinkedIn
Execute - This permission is different on directories if we compare from files. Execute permission provides access to the directory. It not only authorizes you to look at extended information of files in the dir but also allows you to change your working directory or pass through this dir when you are accessing any subdirectory inside.
⚡How to change the security permissions:
We use the chmod command which stands for "change mode".
There are 2 ways of modifying the permissions.
Syntax: chmod <permission> <filename>
Ex.
> chmod u+x tasks.sh
> chmod 764 tasks.sh
Both the commands will give -
rwx to the owner (u)
rw- to group (g)
r-- to other users (o)
Another example -
> chmod ug+rwx tasks.sh
This gives read write and execute permission to the owner and group.
There can be many combinations and ways to define a set of permissions using symbols and octal values.