Permissions and Processes
  1. Permissions. Ch. 9.
    1. Permissions are set for
      1. Users
      2. Groups, which are just lists of users.
        1. Each user has a primary group.
        2. Each user may be in any number of other groups.
      3. Everyone else (other).
    2. Users and groups have both text and numeric names.
    3. id command.
    4. Users
      1. Users and groups are defined in /etc/passwd and /etc/group.
      2. The administrator is root, and has uid 0.
      3. Many users are really programs or services, but are needed to assign permission.
    5. Primary group.
      1. Traditionally, all users belonged to a group called “users.”
      2. Current Linux practice is to create a one-user group for each user.
    6. File permissions
      1. Each file is owned buy a user and belongs to one group.
      2. Three things you can do to a file: read, write, execute.
        For a directory, “execute” means “search.”
      3. Three parties who can be permitted: the owner, the file's group, everyone else.
      4. These are listed as a group of nine characters, rwxrwxrwx
        1. Order is user (owner), group, other (everyone).
        2. Only show the permissions present: rwxr-x---
        3. The ls command adds a file type character in front, -dlcb
        4. ls -l
      5. Can also be represented in a 9-bit number, usually given in octal. rwxr-x--- is 0750
      6. Changed with chmod
        1. chmod newperm fn1...
        2. Octal number.
        3. Symbolic part+permission, part-permission, parts ugo, or a.
        4. +permission, -permission (assumes a).
        5. comma-separated list.
      7. umask
        1. Show or set.
        2. Set of permissions which are masked off by default.
        3. Default for file creation, also effects default on chmod.
      8. Special permissions
        1. Three left bits, or u+s, g+s, +t
        2. Set-uid, set-gid: For executable files, process becomes owned by file owner (or is in the files group).
        3. Sticky: obsolete for files. For directories, limits non-owner changes.
      9. Changing the ownership of a file chown
        1. Changes the ownership of a file.
        2. You generally have to be the administrator to do this.
      10. Changing group, chgrp. Recent chown can do both.
    7. Becoming another user
      1. The su command.
        1. Allows switch to a specified user, usually root.
        2. Requires the credentials of assumed user.
      2. The sudo command.
        1. Perform a specific action as a specific user, as configured.
        2. Requires the credentials of the starting user.
    8. Changing password: passwd.
  2. Processes
    1. Use ps to list processes.
      1. ps shows the processes related to the current terminal session.
      2. ps x shows process which are owned by our user.
        1. If you have an ssh session on Sandbox, there will be a few.
        2. If you're using the GUI, many more: all the stuff running all those windows.
      3. Process state
        RRunning or ready to run
        SSleeping, waiting for a slow event: kb or network
        DUninterruptible sleep, waiting for a fast event: disk
        TStopped by a control signal, waiting for another process to wake it up.
        ZZombie: dead, waiting for parent to collect exit status.
        <High priority
        NLow priority
      4. ps aux shows all processes.
        Note: No O/S distinction between “services” and “applications”.
    2. top shows the process dynamically in order of activity.
    3. Starting a GUI process from the command line.
    4. Starting xlogo and killing it.
    5. Starting xlogo in the background.
      1. Using ps to see it.
      2. Back to foreground.
    6. Putting it to sleep.
    7. Move to background.
    8. Reasons to start a GUI from the command line.
      1. Might not be in the menus.
      2. Might have command-line options.
      3. Might operate on a file in the current directory.
    9. Kill it with kill.
      1. With the process id.
      2. With the job number.
      3. Need to own the process or be superuser.
    10. Can kill with a specific signal.
      1. kill -1 4971
      2. kill -QUIT 4971
      3. Most signals terminate by default.
      4. Actual effect is determined by the program.
        1. May be ignored.
        2. Programmer may specify any particular action. This is called “catching the signal”
        1HUPHang-up. Indicates a logout. Also used to ask daemons to reload configuration
        2INTWhat ^C sends.
        3QUITQuit request
        9KILLTerminates, and cannot be caught or ignored.
        11SEGVSegmentation violation: illegal address use.
        15TERMDefault kill signal.
        18CONTContinue after a stop
        19STOPPuts the process to sleep, and cannot be caught or ignored.
        20TSTPWhat ^Z sends.
    11. killall name kills all programs running name.
    12. pstree shows the processes and who created what.