How to view permissions from the command line

Learn how to view permissions from the command line in both Linux and Windows systems. This is a useful skill for troubleshooting and managing your files and directories.

Viewing Permissions from the Command-Line

  • File permissions may be viewed using ls -l
How to view permissions from the command line
  • Four symbols are used when displaying permissions:
    • r: permission to read a file or list a directory’s contents
    • w: permission to write to a file or create and remove files from a directory
    • x: permission to execute a program or change into a directory and do a long listing of the directory
    • -: no permission (in place of the r, w, or x)

Examining Permissions

The ls -l command displays, among other information, the permissions of the file. The first character of the long listing is the file type. The next nine characters are the permissions, explained in succeeding pages.

File Permissions

Each of the standard permission types can be used to a restrict access for the file’s user, access for the file’s group, and access for everyone else.

Permissions on files for any particular user category are as follows:

read permission means the contents of the file can be examined with a command such as cat or less.
write permission means the file can be edited and saved.
execute permission means the shell will attempt to execute the file when its name is entered as command.

Permissions on directories for any particular user category are as follows:

Directory Permissions

read permission means the contents of the directory can be listed with ls.

write permission means that files may be created or deleted in that directory. In practice, execute permission is also required for these operations to succeed.

execute permission for a directory, sometimes called search permission, grants two capabilities: 1) the user can change into that directory; and 2) if the user has read permission, the user can do a long listing of the directory (read permission without execute permission permits a listing, but not a long listing).

A file may be removed by anyone who has write permission to the directory in which the file resides regardless of the ownership or permissions on the file itself.

2 thoughts on “How to view permissions from the command line”

Leave a Comment