Junior — Middle
How to manage file permissions in Linux?
sobes.tech AI
Answer from AI
In Linux, file permissions are managed using three types of rights: read (r), write (w), and execute (x), which are assigned to three categories of users:
- File owner
- Group to which the file belongs
- All other users
To view permissions, the command ls -l is used, for example:
-rw-r--r-- 1 user group 1234 May 10 12:00 file.txt
To change permissions, the chmod command is used, for example:
chmod u+x file.sh # Add execute permission for the owner
chmod go-r file.txt # Remove read permission from group and others
To change the owner and group, the chown and chgrp commands are used:
chown newuser file.txt
chgrp newgroup file.txt
Thus, managing permissions allows controlling who and how can interact with files in the system.