Day 6: File Permissions in Linux — Master chmod, chown, and umask

By Fiza | Future DevOps Engineer | #10DaysOfLinux

Hey everyone!

I'm Fiza, currently learning Linux as part of my journey to become a DevOps Engineer. Welcome to Day 6 of my #10DaysOfLinux series, where we explore an important and beginner-friendly topic: File Permissions in Linux.

Let’s dive in!

---

Why Do File Permissions Matter in Linux?

Linux is a multi-user operating system, which means multiple users can access and use the system at the same time. To maintain privacy and control, Linux uses file permissions to decide who can:

Read a file (r)

Write or modify a file (w)

Execute or run a file (x)

Each file and folder has permissions assigned for:

1. Owner

2. Group

3. Others

---

1. Using chmod – Change File Mode

The chmod command is used to change the permissions of a file or directory.

Symbolic Mode Example:

chmod +x script.sh

This gives the execute permission to the file.

Numeric Mode Example:

chmod 755 file.txt

This sets:

Owner: Read + Write + Execute (7)

Group: Read + Execute (5)

Others: Read + Execute (5)

Quick Reference:

Number Permission

7 Read + Write + Execute

6 Read + Write

5 Read + Execute

4 Read only

---

2. Using chown – Change Ownership

The chown command changes the owner and/or group of a file or directory.

Example:

chown fiza:fiza file.txt

This sets both the user and group ownership to fiza.

---

3. Understanding umask – Set Default Permissions

umask sets default permissions for newly created files and directories.

Check Current umask:

umask

Set a Temporary umask:

umask 022

This means:

New files: 644 (rw-r--r--)

New directories: 755 (rwxr-xr-x)

---

How to View File Permissions

Use the ls -l command to list file details with permissions:

ls -l

You'll see something like:

-rw-r--r-- 1 fiza fiza 0 May 22 10:00 file.txt

---

Conclusion

Understanding file permissions in Linux is essential for system security and access control. Commands like chmod, chown, and umask are simple but powerful. Practice using them to build confidence as a Linux user!

---

Let’s Connect!

If you’re enjoying this series and learning something new, don’t forget to follow me on Hashnode to stay updated with the rest of my journey!

Follow me here:

https://hashnode.com/@devopslover540

See you on Day 7!

0
Subscribe to my newsletter

Read articles from Fiza_devops_lover_540 directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Fiza_devops_lover_540
Fiza_devops_lover_540

> "Learning Linux, Git, and Shell scripting on my path to becoming a DevOps Engineer. Sharing my tech journey step by step." "Aspiring DevOps Engineer on a journey from Git to the Cloud. Learning Linux, mastering Shell scripting, and exploring automation one command at a time. Sharing my DevOps learning path and experiences as I grow."