Linux File Permissions and Ownership
Posted on June 1, 2024 (Last modified on June 8, 2024) • 1 min read • 196 wordsUnderstand file permissions and ownership in Linux, including how to view, change, and manage permissions and ownership using chmod, chown, and groups.
File permissions and ownership are fundamental concepts in Linux. This guide covers how to view, change, and manage file permissions and ownership using chmod
, chown
, and groups.
Use ls -l
to view file permissions and ownership.
ls -l filename
Permissions are displayed as rwx
(read, write, execute).
Use chmod
to change file permissions.
chmod 755 filename
Permissions can be set using numeric or symbolic modes.
Change permissions using symbolic mode.
chmod u+x filename
chmod g-w filename
chmod o+r filename
Use chown
to change file ownership.
chown user:group filename
Use chgrp
to change the group ownership.
chgrp groupname filename
Use groupadd
to create a new group.
sudo groupadd groupname
Use usermod
to add a user to a group.
sudo usermod -aG groupname username
Understanding and managing file permissions and ownership are crucial for system security and administration. Practice using chmod
, chown
, and managing groups to effectively control access to files and directories in Linux.