File Permissions & Ownership

Manage who can access or modify files and directories.

1. chmod

chmod 755 file.sh

Changes file permissions (read, write, execute).

2. chown

chown user:group file.txt

Changes file ownership to user and group.

3. chgrp

chgrp groupname file.txt

Changes group ownership only.

4. umask

umask 022

Sets default permissions for new files.

5. ls -l

ls -l

Displays file permissions and ownership.

6. getfacl

getfacl file.txt

Shows Access Control List (ACL) for a file.

7. setfacl

setfacl -m u:john:rw file.txt

Sets ACL permissions for specific users.

8. sudo

sudo command

Runs commands as another user (typically root).

9. su

su - username

Switches to another user account.

10. passwd

passwd username

Changes a user’s password.

11. usermod

usermod -aG group user

Adds a user to a group.

12. id

id username

Shows user ID and group memberships.

13. groups

groups username

Lists all groups a user belongs to.

14. visudo

sudo visudo

Safely edits the sudoers file.

15. newgrp

newgrp group

Temporarily changes the current group ID.

16. stat

stat file.txt

Shows detailed metadata including permissions.