header image
Home arrow How Tos arrow LUG How Tos arrow How To User & File Permissions
How To User & File Permissions Print
Jul 12, 2008 at 09:38 AM
Linux User & File Permissions
Impress tutorial is here.
Image

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
Image

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
Image

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
Image

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
Image

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
Image

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

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
Image

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

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
Image

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
Image

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
Image

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

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
Image

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
Image

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
Image

EC_LUG -Eau Claire Linux users group is an informal group of Linux and open source software enthusiasts.

We meet each Thursday at 7 p.m. at Dooley's Pub, 442 Water Street, Eau Claire, Wisconsin

Linux 101:
What's All The Fuss? video...

Mac vs. PC: How Would Linux Fit?
video1...

video2...
video3...

Linux User GroupsLug Link Logo