Linux File Permissions

Linux file permissions control who can read, write or execute a file. This is one of the first things to check when a script does not run, a service cannot read a file, or a user cannot access a directory.

View permissions

ls -l

A typical output line looks like this:

-rwxr-xr-- 1 user group 1234 file.sh

The first character shows the type of item. The next three groups show permissions for the owner, group and others.

Permission meanings

  • r means read
  • w means write
  • x means execute

For directories, execute permission means the user can enter or traverse the directory.

Useful checks

ls -ld /path/to/directory
ls -l /path/to/file

Before changing permissions, check who owns the file and which user or service is trying to access it.

Leave a Comment