Menu

Linux File Permissions: Use chmod Without Breaking Access
📰

Linux File Permissions: Use chmod Without Breaking Access

DEV Community: beginners·Nate·about 3 hours ago
#hCn5O36H
#devtobeginners#devto#dev#chmod#owner
Reading 0:00
15s threshold

A Permission denied error does not always mean the file needs broader permissions. The cause might be a parent directory, the file’s owner, or an access control that chmod does not change. Before reaching for chmod 777 , identify which user needs access and what operation they need to perform.

Read the mode before changing it

Start by checking the file, its owner, and the directory itself:

ls -l report.txt ls -ld /srv/www/site stat -c '%a %A %U:%G %n' report.txt

Enter fullscreen mode

Exit fullscreen mode

In ls -l output, the first character identifies the object type ( - for a regular file, d for a directory). The next nine characters describe permissions for the owner, group, and others, in that order. For example:

-rw-r--r-- 1 alice developers 128 Nov 11 10:00 report.txt

Enter fullscreen mode

Exit fullscreen mode

Here, Alice can read and write the file; members of the group and other users can read it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.