The command you need is chmod to change permissions in Linux. The Linux permission system works differently from Windows. We have some numbers associated with the permission.
1 – Execution
2 – Writing
4 – Reading
So you always have to make some math to apply for the permission. If you want to assign the execution permission you can set as 1, write permission 2 and reading permission 4. Write + Reading is equal to 6, so the permission is 6. If you want Read + Write + Execution is equal to 7. In the below section explained how to check file permissions.
How to check file permissions
alisson@devops:~$ touch new_file
alisson@devops:~$ ls -la new_file
-rw-rw-r-- 1 alisson alisson 0 Feb 20 19:21 new_file
The command touch is responsible to change the access time of any file. If the file does not exist, it creates one. Checking the output, you can see that we have the permissions: read+write, read+write, read, but what means that sequence:
user – group – other
In the same line, we can see alisson alisson, the first one is the user owner for this file and the second one is the group. By default, all the users created on Linux have a group with the same name as the user.
If you remember the numbers which represent the permission, we can make a calculation, read+write = 4 + 2 = 6. Then we have the following permissions:
664
Therefore, the user can read and write. Users from the same group can also read and write, users who do not belong to the group can just read.
Now, we can create a directory and analyze the permissions as we did just now:
How to check permissions for directory
alisson@devops:~$ mkdir new_folder
alisson@devops:~$ ls -la | grep new_folder
drwxrwxr-x 2 alisson alisson 4096 Feb 20 19:29 new_folder
Analyzing the permissions, we can see, read + write + execution for the user and group, and read + execution for the others. If we make the following association:
read + write + execution = 4 + 2 + 1 = 7
read + execution = 4 + 1 = 5
So, whenever you give 777 that means, you are proving read + write + execution to user, group and owner.
Command to change permissions
Use chmod command and associated numbers to change file permissions.
$ chmod 777 newfile
Related
-
Secure S3 File Upload Using API Gateway, Lambda & PostgreSQL (Complete AWS Architecture Guide
Modern applications often allow users to upload files—documents, invoices, images, or datasets. But a production-grade upload pipeline must be secure, scalable, and well-organized. In this article, we will build a complete end-to-end architecture where: We will implement this using Amazon API Gateway, AWS Lambda, PostgreSQL, and Amazon S3. This architecture is widely used in cloud-native…
-
AI Agents in Data Engineering: Everything You Need to Know
AI agents are revolutionizing data engineering by automating tasks such as monitoring pipelines, generating SQL queries, and ensuring data quality. They enhance productivity, speed up troubleshooting, and improve data accessibility for users. While offering significant advantages, AI agents also face challenges in security, accuracy, and integration with existing systems.
-
The End-to-End AI Stack – A Real Guide for Developers to Code, Create, and Execute
Artificial Intelligence tools are on the rise, from writing assistants to coding helpers and automation platforms. However, many professionals struggle to compare these tools effectively. This is where the AI Stack becomes important. Modern AI tools like ChatGPT, NotebookLM, and Antigravity serve different purposes, and understanding their roles helps in: Layer 1: Conversational AI (Thinking…
![How to Set File Permissions in Linux [+Example]](https://srinimf.com/wp-content/uploads/2022/04/pexels-photo-9034968.jpeg?w=1024)





