ITNuvoAkademiya
Academy homePackagesPlaylistsToolsSubnet calculatorSearchGlossary
CiscoCCNA · CCNA: networking fundamentals1. Introduction2. Network Fundamentals3. Network Access4. IP Connectivity5. IP Services6. IPv67. Security Fundamentals8. AutomationCCNP: Enterprise networks · coming soon
LinuxLinux: system administrator üçün · Linux for system administrators1. Getting to know Linux2. Working with text3. Users and permissions4. Processes and packages5. Inside the system6. Monitoring and logs7. NetworkingRed Hat Enterprise Linux · Red Hat Enterprise Linux: from beginner to advanced1. Getting started2. Packages3. Users and permissions4. SELinux5. Services6. Storage7. Networking8. Building services9. Boot and recovery10. DevOps11. Security and monitoring
FortinetFortiGate Administrator · FortiGate Administrator: from first login to ZTNA1. Getting to know FortiGate2. Routing, policy and NAT3. Security profiles4. Users and logs5. Resilience, SD-WAN and automation6. VDOM7. VPN and ZTNA8. Proxy9. DMZ
MonitoringZabbix · Zabbix: from installation to alerts1. Introduction2. Installation and the database3. Basics: groups, templates, users4. Connecting devices5. Alerts, Grafana and the API
VirtualizationProxmox VE · coming soonVMware ESXi · coming soon
My account / Sign in
AZENRU
← itnuvo.com

Permissions: rwx, chmod, chown, umask

Lesson 3.37 minBeginnerDecember 1, 2026
Open

This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.

Key points

  • Three sets (u, g, o) × three rights (r=4, w=2, x=1): chmod 640, chmod g+w,o=.
  • chown user:group, chgrp group, -R for a directory; only root changes the owner.
  • umask shows the current value; a permanent change goes in ~/.bashrc for one user, /etc/profile.d/*.sh for everyone.
  • In ls -l a trailing . shows an SELinux context and + an ACL.
  • On "Permission denied", check three layers: permissions (ls -l), ACL (getfacl), SELinux (ls -Z, ausearch).

A quick review

CodeLooks likeTypical use
755rwxr-xr-xDirectories, scripts
644rw-r--r--Regular files, web content
750rwxr-x---A directory only the group can enter
640rw-r-----Configuration the group reads
600rw-------Keys, secret configuration
700rwx------Home directories on RHEL

Symbolic form: u, g, o, a + +, -, = + r, w, x.

srv-web01
[ali@srv-web01 ~]$ sudo mkdir -p /srv/hesabat
[ali@srv-web01 ~]$ sudo chown ops1:webdev /srv/hesabat
[ali@srv-web01 ~]$ sudo chmod 770 /srv/hesabat
[ali@srv-web01 ~]$ ls -ld /srv/hesabat
drwxrwx---. 2 ops1 webdev 6 Dec  1 12:02 /srv/hesabat

The right way for a whole directory — separate permissions for directories and files:

srv-web01
[ali@srv-web01 ~]$ sudo find /srv/hesabat -type d -exec chmod 770 {} +
[ali@srv-web01 ~]$ sudo find /srv/hesabat -type f -exec chmod 660 {} +
[ali@srv-web01 ~]$ sudo chmod -R u=rwX,g=rwX,o= /srv/hesabat

The capital X in the last command means "give x only to directories and to files that are already executable". One command gets both directories and files right.

umask

srv-web01
[ali@srv-web01 ~]$ umask
0022
[ali@srv-web01 ~]$ umask -S
u=rwx,g=rx,o=rx
[ali@srv-web01 ~]$ grep -n "umask" /etc/login.defs | head -n 2
91:UMASK		022

For a user working in a team, umask 007 (file 660, directory 770) — "others see nothing":

srv-web01
[ali@srv-web01 ~]$ echo "umask 007" | sudo tee -a /home/ops1/.bashrc
[ali@srv-web01 ~]$ sudo -iu ops1 bash -c "umask; touch /tmp/sinaq; ls -l /tmp/sinaq"
0007
-rw-rw----. 1 ops1 ops1 0 Dec  1 12:10 /tmp/sinaq

For all users: create the file /etc/profile.d/umask.sh. The UMASK in /etc/login.defs is used only when the home directory is created.

Three layers: permissions, ACL, SELinux

On Ubuntu "Permission denied" is almost always about permissions. On RHEL the check goes through three layers, and all three must allow it:

LayerHow to see itHow to fix itLesson
Standard permissionsls -lchmod, chownthis lesson
ACL+ in ls -l, getfaclsetfacl3.5
SELinuxls -Z, ausearch -m AVCrestorecon, semanage, setseboolunit 4
srv-web01
[ali@srv-web01 ~]$ ls -l /var/www/html/index.html
-rw-r--r--. 1 root root 31 Dec  1 12:15 /var/www/html/index.html
[ali@srv-web01 ~]$ curl -s -o /dev/null -w "%{http_code}\n" http://localhost/
403
[ali@srv-web01 ~]$ ls -Z /var/www/html/index.html
unconfined_u:object_r:user_home_t:s0 /var/www/html/index.html

The permissions are fine (644), but the site returns 403. The cause is the SELinux context — user_home_t is forbidden for the web server. We will solve this scenario in unit 4. The lesson here: on RHEL chmod 777 is never the fix — and often it does not even help.

Lab: a team directory

In the Red Hat simulator, on srv-web01:

  1. Create the directory /srv/hesabat owned by ops1 with group wheel (if the simulator has no webdev group).
  2. Set the mode to 770 and check with ls -ld.
  3. Create a file in the directory and find the trailing dot in ls -l.
  4. Look at the SELinux context with ls -Z /srv/hesabat.
srv-web01
[ali@srv-web01 ~]$ sudo mkdir -p /srv/hesabat
[ali@srv-web01 ~]$ sudo chown ops1:wheel /srv/hesabat
[ali@srv-web01 ~]$ sudo chmod 770 /srv/hesabat
[ali@srv-web01 ~]$ ls -ld /srv/hesabat
drwxrwx---. 2 ops1 wheel 6 Dec  1 12:02 /srv/hesabat
[ali@srv-web01 ~]$ ls -Zd /srv/hesabat
unconfined_u:object_r:var_t:s0 /srv/hesabat

Check: ls -ld → drwxrwx---. ops1 wheel.

Check yourself

5 questions · answers are shown instantly · 3 correct answers complete the lesson

1What does the capital X do in chmod -R u=rwX,g=rwX,o= dir?

One command gets both directories and files right.

2Where is a permanent umask for all users set?

Login shells read these files.

3In ls -l output a + appears at the end of the permissions. What does it mean?

A dot (.) shows SELinux, a plus (+) an ACL.

4The permissions are 644, but httpd returns 403. What is the next step?

On RHEL the third layer is SELinux.

5What is the default mode of a newly created home directory on RHEL?

HOME_MODE 0700.
Was this lesson useful?

Comments

Sign in to comment.