Every file on Linux has permissions — who can read it, change it, or run it. Get them wrong and a program stops working, or a private file becomes open to everyone. The good news: checking and fixing them takes one or two commands.
See the permissions first
- Open a terminal in the folder that holds the file.
- Type ls -l and press Enter.
- Look at the start of the line for your file — you will see something like -rw-r–r–.
That string is the permissions. The first character is the file type (– for a file, d for a folder). The next nine letters come in three groups of three.
What the letters mean
- r — read: open and view the file.
- w — write: change or delete the file.
- x — execute: run it as a program, or open a folder.
- First group — you, the owner. Second group — the group. Third group — everyone else.
So -rw-r–r– means you can read and write it, and everyone else can only read it. A dash means that permission is off.
Change them safely with chmod
- To let yourself run a script: chmod u+x script.sh — the u is you, and +x adds execute.
- To remove execute again: chmod u-x script.sh.
- To set a normal document so you can edit it and others can only read it: chmod 644 document.txt.
- To set a script so you can run it and others can only read it: chmod 755 script.sh.
The numbers work the same way: 4 is read, 2 is write, 1 is execute. Add them up for each group — 6 is read + write, 7 is read + write + execute, 5 is read + execute.
One safety rule
Never use chmod 777 just to make a problem go away. That gives everyone full control of the file, including anyone else who can sign in to the machine. Change only the file you need, change only the permission you need, and check the result again with ls -l.
Small change, checked twice — that is how you fix permissions without creating a bigger problem.


