Change Ordinary Permission Bits
Change Ordinary Permission Bits
The teacher wants to edit the marks while allowing the report group to read them. Other users should receive no ordinary access from this file's mode. chmod changes permission bits so the access policy can match that intention.
Ownership answers who owns the file; permissions describe allowed operations for the applicable classes. Changing one does not automatically change the other. Let's set a deliberate mode and read the result rather than treating a bigger number as a generally better permission setting.
What you’ll learn
- Change mode bits with chmod and verify them.
- Keep permissions separate from ownership and choose only the access required.
Changing bits does not change the owner
Before
A file has both an owner and permission mode.
marks.txtChange mode
chmod 640 replaces the ordinary permission bits.
rw-r-----Owner remains
The operation does not select a new owning user.
same owner
Set the marks file to mode 640
Prepare the example
Use a fresh practice folder and a file you own. The first line creates the exercise report. We will set its ordinary bits to 640, then inspect them. You do not need sudo merely to change the mode of your own eligible practice file.
Bash · Linux terminal
printf 'Diya: 72\n' > marks.txt
chmod 640 marks.txt
ls -l marks.txtExpected behavior; machine-dependent details
The mode begins -rw-r-----; remaining listing fields vary.chmod 640 marks.txt selects owner read/write, group read and no ordinary access for others. The digits identify permissions, not a new owner. The following ls -l displays the updated triplets and the owning user and group beside them.
Ask whether each granted operation matches the requirement. This example does not request execution, so adding execute bits just to remove an error would be unrelated. If another user still cannot read the report, inspect group membership, directory search access and any ACL or policy constraints. Broadening every bit can mask the actual explanation and give more access than the task needs.
Select symbolic changes or a numeric ordinary mode
chmod changes the permission bits on files and directories. You can describe the change with letters such as u+x or set the complete mode with numbers such as 755.
What Are File Permissions?
In Linux, every file and folder has permissions that determine who can read, write, or execute it. These permissions are categorized by:
- Owner – the person who created the file
- Group – a set of users who share access
- Others – everyone else
Check Current Permissions
Let’s check the permissions of a file using the ls -l command:
ls -l myscript.sh
-rw-r--r-- 1 user user 123 Jul 2 10:00 myscript.sh
This tells us:
rw-— Owner can read and writer--— Group can readr--— Others can read
Using chmod to Change Permissions
▶ Symbolic Mode
Let's say you want to give execute permission to the owner:
chmod u+x myscript.sh
ls -l myscript.sh
-rwxr--r-- 1 user user 123 Jul 2 10:00 myscript.sh
What we did:
u= user (owner)+= add permissionx= execute
▶ Numeric Mode
You can also use numbers to set all permissions at once:
chmod 755 myscript.sh
ls -l myscript.sh
-rwxr-xr-x 1 user user 123 Jul 2 10:00 myscript.sh
This means:
7= read + write + execute (owner)5= read + execute (group)5= read + execute (others)
Examples for Practice
Make a file readable and writable only by the owner:
chmod 600 secrets.txt
Make a script executable by everyone:
chmod a+x deploy.sh
Remove write permission from group:
chmod g-w report.txt
Verify Your Changes
Always check your work:
ls -l
Change permissions deliberately with chmod
So now you know:
- How to view file permissions
- How to use
chmodin symbolic and numeric modes - How to verify your changes with
ls -l
Managing file permissions is a core skill in Linux. Practice often and you’ll master it in no time!
Try it, then check the worked answer
Your task: Does chmod change the file's owner?
Use a fresh practice folder and a file you own. The first line creates the exercise report. We will set its ordinary bits to 640, then inspect them. You do not need sudo merely to change the mode of your own eligible practice file.
Bash · complete example for this question
printf 'Diya: 72\n' > marks.txt
chmod 640 marks.txt
ls -l marks.txtExpected behavior; machine-dependent details
The mode begins -rw-r-----; remaining listing fields vary.Worked answer
No; it changes mode bits.
chmod changes mode bits, not the owning user. The value 640 encodes access choices. To change ownership, use the appropriate ownership command with its own authorization requirements; do not interpret the digits as user identifiers.
Check your decision
Permissions and ownership answer different questions
Translate the access requirement into specific bits, apply them and read them back. Keep ownership and directory traversal separate from the file's mode. The right setting is the one that grants the needed operations, not the broadest setting that happens to make an error disappear.
Reaching the recap and completing the quizzes are separate milestones.