How to View File and Folder Permissions in Ubuntu Linux Command Line

Last updated on

To View Permissions

To list permission of each file in a directory, in this example /var:

ls -l /var


total 48
drwxr-xr-x   2 root root   4096  Feb  8  06:25 backups
drwxr-xr-x  13 root root   4096  Oct 22  00:29 cache
drwxrwxrwt   2 root root   4096  Aug 13  17:32 crash

To list file permissions for filename.txt:

ls -l filename.txt


-rw-r--r-- 1 root root 0 Jan 29  2018 filename.txt

To list directory permissions for /var:

ls -ld /var


drwxr-xr-x 15 root root 4096 Apr 23 12:03 /var

To list permissions files in a folder including hidden files.

ls -la /var

To list file permissions in a folder with human readable file size:

ls -lh /var


total 52K
drwxr-xr-x  2 root root   4.0K Apr  9 08:52 backups
drwxr-xr-x 11 root root   4.0K Jan 29  2018 cache
drwxrwxrwt  2 root root   4.0K Apr 27  2019 crash

Changing Permissions

Single File or Folder

To change permissions of file to 644 for example:

sudo chmod 664 foo.txt

To change permissions of directory to 755 for example:

sudo chmod 755 /path/to/directory/

All Files

To change all files recursively to 644.

sudo find /path/to/directory/ -type f -exec chmod 644 {} \;

All Folders

To change all directories recursively to 755.

sudo find /path/to/directory/ -type d -exec chmod 755 {} \;

Changing Owner/Group

Change Owner/Group of a File

sudo chown username:groupname filename.txt

Change Owner/Group of All Files/Directories

To change the owner and group of all files and directories recursively within a directory.

sudo chown -R username:groupname /path/to/directory/*

To change the owner and group of a directory, and all the files and directories within it recursively.

sudo chown -R username:groupname /path/to/directory*

Permission Groups

Each file and directory has three user based permission groups:

  • owner – The Owner permissions apply only the owner of the file or directory, they will not impact the actions of other users.
  • group – The Group permissions apply only to the group that has been assigned to the file or directory, they will not effect the actions of other users.
  • all users – The All Users permissions apply to all other users on the system, this is the permission group that you want to watch the most.

Permission Types

Each file or directory has three basic permission types:

  • read – The Read permission refers to a user’s capability to read the contents of the file.
  • write – The Write permissions refer to a user’s capability to write or modify a file or directory.
  • execute – The Execute permission affects a user’s capability to execute a file or view the contents of a directory.

Numeric Meanings

0No access.
1–xExecute access.
2-w-Write access.
3-wxWrite and execute access.
4r–Read access.
5r-xRead and execute access.
6rw-Read and write access.
7rwxRead, write and execute access.

Common File Permissions


Common Directory Permissions

1 Star2 Stars3 Stars4 Stars5 Stars 5.00 (3 votes)

Let me know in the comments if this helped. Follow me on Twitter, Facebook and YouTube.

p.s. I increased my AdSense revenue by 68% using AI 🤖. Read my Ezoic review to find out how.

2 replies

newest oldest
Notify of
21 days ago

I’m really struggling here.
All my files have 777 permissions. I cannot figure out how to view/open the files.

Everytime I try to open them in windows it will say there is no program to view.
In Ubuntu terminal I can’t seem to view it in any way.
Any ideas?
Thank you