Setting file permissions in Linux
posted by Michael Olafusi , on ,
All files in Linux have permissions set (or unset) for user, group and other users. It’s indicated as –rwxrwxrwx or similar.
To display a file’s permission settings, type ls -l filename
The first character indicates the filetype e.g. ordinary file, directory…
The next 3 characters indicate the permission for the file owner (user), then next 3 for users in the owner’s group and the last 3 for other users.
r = Read w = Write x = Execute
Easiest way to change a file’s permission is to use chmod u/g/a +/- rwx filename e.g. chmod a+w file.txt to give everyone write permission on the file, file.txt
You can also use numeric arguments and common ones are –
chmod 400 to give only read permission to owner
chmod 600 to give read and write permission to owner
chmod 644 to give everyone read permission and the owner write permission
chmod 775 to give everyone read + execute, owner + group read write execute permissionchmod 777 to give everyone read write exceute permission