File Permission in Linux
Day06

Hi there! My name is Yashswini and I'm a Linux Engineer with 3 years of experience in automation, continuous integration, and deployment. My expertise lies in DevOps and Cloud Computing with a focus on AWS. I have hands-on experience in various tools and technologies related to infrastructure automation, managed services, containerization, and monitoring and logging. I have a passion for troubleshooting and resolving issues and I'm always eager to learn and explore new technologies
About File Permission :
File permissions in Linux are a way to control access to files and directories. They determine who can read, write, and execute a file or directory. Linux uses a three-level permission system for files and directories, which applies to three different groups: the owner, the group, and others.
Each file and directory has three types of permissions:
Read (r): Allows the file to be viewed and its contents read. For directories, it allows the contents of the directory to be listed.
Write (w): Allows the file to be modified, including creating, deleting, and renaming the file. For directories, it allows files to be created, deleted, or renamed within the directory.
Execute (x): Allows the file to be executed as a program or script. For directories, it allows accessing and traversing the directory.
The permissions are specified for each group mentioned earlier: owner, group, and others.
Example:

In this example, the file myfile.txt has the following permissions:
The owner has read and write permissions (rw-).
The group has read-only permissions (r--).
Others have read-only permissions (r--).
Changing file permission using chmod
With the help of the change mode ‘chmod’ command, we can set the permissions such as read, write, and execute on a directory or file for the owner, user, and the group.
1. Numeric mode
In a numeric mode, file permissions do not denote as characters but as a three-digit octal number. The following table provides the numbers for all permission types.

for example:
chmod 764 sample
chmod 764 and checking permission. In the above command, we have changed the file permissions to 764. 764 represents the following:
The owner can read, write, and execute
The user group can read and write
Any user can only read
Symbolic mode:
The symbolic representation uses letters to represent the permissions and can be modified using operators like
+(add),-(remove), or=(set explicitly). For example:
for example:
#chmod u+x myfile.txt
here user have permission of execute the myfile.txt
Changing ownership and group
For changing the ownership of a directory or file, use the command below:
# chown user
If you want to change the user along with the group for a directory or file, use the command below
#chown user: group filename
If you wish to change group owner only, use the command below
# chgrp group_name filename



![Jenkins Freestyle Project for DevOps Engineers[Day-23 Task]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1690291895202%2Fc7012bdd-d2f6-44e4-8d64-6d071c0c7c39.png&w=3840&q=75)
