Skip to main content
Linux permissions guide

Chmod vs Umask

Use chmod to change permissions on a file or directory that already exists. Use umask to control the defaults used when a process creates new files or directories. This page is the quick comparison; use the diagnostic guide when ownership, groups, parent directories, setgid, or ACLs are also involved.

Quick answer

Use chmod for explicit modes, umask for defaults

chmod sets a permission mode now, such as chmod 755 public_html or chmod 644 index.html. umask subtracts permission bits from the default creation mode, so umask 022 usually creates files 644 and directories 755.

Chmod vs umask at a glance

Question Use chmod Use umask
What does it affect? Existing files and directories. New files and directories created after the umask is set.
Typical command chmod 755 folder_name umask 022
Best for Fixing a current file mode, deploy asset, script, static file, or private directory. Controlling what a shell, service account, deployment process, or container creates by default.
What it does not do It does not change ownership. Use chown for owner or group changes. It does not retroactively change existing files. Use chmod for that.

One Linux example: new defaults vs existing modes

Set umask before creating new files or directories when the default mode is the real problem.

umask 022
touch app.log
mkdir uploads
ls -l app.log
ls -ld uploads

With umask 022, app.log is usually created as 644, while uploads is usually created as 755.

Fix an existing file with chmod

If the file already exists, changing umask will not update that file. Use chmod when you need to change the actual permission bits now.

chmod 600 app.log

chmod 600 makes the existing file owner-readable and owner-writable, with no group or public access.

How chmod works

chmod sets the read, write, and execute bits for owner, group, and others. The common octal values are built from read 4, write 2, and execute 1.

  • chmod 755 public_html lets the owner write while group and public can read and enter the directory.
  • chmod 644 index.html keeps a public static file readable but not executable.
  • chmod 700 ~/.ssh keeps a private directory owner-only.

Use the Chmod Calculator to convert rwx choices into octal values and copy-ready commands.

How umask works

umask removes permissions from the maximum default modes. New files usually start from 666, and new directories start from 777. That is why execute bits are common on directories but not on newly created regular files.

  • umask 022 removes write for group and others.
  • umask 027 removes public access and limits group write.
  • umask 077 makes new files and directories owner-only.

Use the Umask Calculator to preview file and directory results before changing shell or service defaults.

Common umask results

Umask New files New directories Common use
0022 / 022 644 / -rw-r--r-- 755 / drwxr-xr-x Standard public-readable files and traversable directories.
0002 / 002 664 / -rw-rw-r-- 775 / drwxrwxr-x Shared group workspaces where group write is expected.
0027 / 027 640 / -rw-r----- 750 / drwxr-x--- Limited group access with no public access.
0077 / 077 600 / -rw------- 700 / drwx------ Private owner-only files and directories.

rwx to octal reference

Octal rwx Meaning
0---No permissions.
1--xExecute only.
2-w-Write only.
3-wxWrite and execute.
4r--Read only.
5r-xRead and execute.
6rw-Read and write.
7rwxRead, write, and execute.

Common chmod values

Mode Typical meaning
755Owner can write; group and others can read and execute.
644Owner can write; group and others can read a regular file.
700Owner-only directory or private executable script.
600Owner-only private file such as a secret or key material.
777Everyone can read, write, and execute. Avoid on shared systems.

Safe file and directory defaults

When you need files 644 and directories 755 after a bad recursive permission change, apply different modes to files and directories instead of running one broad command over everything.

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

Chmod vs umask FAQ

Is umask the same as chmod?

No. chmod changes permissions on existing files or directories, while umask controls default permissions for newly created files and directories.

Why does umask 022 create 644 files and 755 directories?

New files usually start from 666 and new directories start from 777. umask 022 removes write permission for group and others, resulting in files 644 and directories 755.

Does umask change existing files?

No. umask only affects files and directories created after the umask is set. Use chmod to change files or directories that already exist.

What is the difference between chmod 755 and umask 022?

chmod 755 sets an existing file or directory to rwxr-xr-x. umask 022 controls future creation defaults, usually producing files 644 and directories 755.

Should I use chmod 777?

Usually no. chmod 777 grants read, write, and execute access to everyone, which is risky on shared or public systems.

Does chmod change file ownership?

No. chmod changes permission bits. Use chown when you need to change the user or group owner.