DEV Community

Josh
Josh

Posted on

Linux Permissions

View file permissions:

ls -l file.txt
ls -ld mydir/ # Checks permissions on directory
ls -lR mydir/ # List permissions of files in dir
Enter fullscreen mode Exit fullscreen mode

Set Ownership

chown root:root file.txt
chown -R root:root mydir/  # Makes everything in mydir to be owned by root
Enter fullscreen mode Exit fullscreen mode

Examples of permissions and what they mean:

-rw-rw-r-- 1 root root  0 Dec 10 05:38
#
# - this is a regular file.
# rw- represent the owner's permissions.
# rw- group.
# r-- others.
Enter fullscreen mode Exit fullscreen mode

Permissions:

r (read): 4
w (write): 2
x (execute): 1
Enter fullscreen mode Exit fullscreen mode

Examples:

chmod 777 file.txt
chmod 650 file.txt
Enter fullscreen mode Exit fullscreen mode

Top comments (0)