|
How To User & File Permissions |
|
|
Jul 12, 2008 at 09:38 AM |
Linux User & File Permissions Impress tutorial is here.

Users and Groups o Each file has one user and one group o Stored as numbers + 0 – root + 1 – 499 reserved for system use + 500/1000+ – users (depending on distro) o ls -n vs. ls -l

User o “User” is owner of the file o Creator by default o Each “User” belongs to one or more “Groups” o Group of the same name as the User is default

Basic Permissions o Three basic permissions o Read – View a file + r o Write – Write to a file + w o Execute – Run a file (Program) + x

Basic Permissions o The 3 basic permissions are applied to: o User, Group, and Everyone + rwx rwx rwx o Shown as “-” if the permission is not granted + rw- rw- r-- o Can also be listed as an octal number: + 110→6 110→6 100→4 = 664

Example o We get this from the ls -l command: o User is byronh o byronh can read and write o Group is byronh o Members of byronh can read and write o Everyone else can read

File Type o First character is file type o - is a normal file

File Types o - – Normal file o d – directory o l – symbolic link o s – socket o p – pipe o c – character device o b – block device

Basic Permissions (directories) o Read and Write the same o Execute allows file contents to be listed

Advanced Permissions (programs) o SUID – set user id o Allow program to run with “User” permissions
o GUID – set group id o Allow program to run with “Group” permissions

Advanced Permissions (directory) o GUID – Newly created files have the same group as the directory o (instead of the user's default group) o Sticky bit – save text attribute o Anyone can create new files, but only users or groups can modify or delete

Overview o 0 – filetype “-”/d/l/p/c/b o 1 – User read “-”/r o 2 – User write “-”/w o 3 – User execute “-”/x/s/S o 4 – Group read “-”/r o 5 – Group write “-”/w o 6 – Group execute

Setting permissions o chmod [mode] file(s) [-R] o Changes permissions on file(s) o -R recurses through subdirectories

Setting Permissions 2 o [mode] as symbolic o 3 groupings: + ugoa – user/group/other/all (defaults to a) + - + = – remove/add/set equal to + rwxst – read/write/execute/SUID or GUID/sticky

Setting Permissions 3 o [mode] as numeric o 3 or 4 digits + Last 3 are permissions for User, Group, Other + First is optional and used for SUID/GUID/sticky + Number represents permissions as binary

Useful commands o chown – change owner/user and group of file o ls -l – long file listing o usermod -G group1,group2 user o Make user a member of group1 and group2

|