- Creating a user
-
- The instructions listed here are the manual way to administer
users and groups. This is also the way I was taught to manage
users. It's helpful now, so you can see the files that are updated,
and the components withint those files that define the user or
group.
- The more accurate way and to help you not forget something
is completed with one of the add, delete and modify commands
listed below.
-
- Online Manpages:
- useradd
- userdel
- usermod
-
- groupadd
- groupdel
- groupmod
|
- Create the user:
- login as root
- > cd /etc
- > vi passwd file
- Make sure the user wasn't added previously.
- /user (where user is the users id - ie: widvlc)
- If none is found add the new user
- add a new entry on the last line
- userid:x:123:456:name:/home/userid:/bin/ksh
- 123 = user id (must be unique)
- 456 = group id (the primary group this user is part of)
- name = name of the user
- close and save (:wq!)
-
- Set up Password
- > vi shadow file
- add new entry on the last line
- userid::::::::
- 8 colons (:)
- userid is the id you defined in the passwd file (widvlc)
- close and save (:wq!)
- from the command line
- > passwd userid
- You'll be prompted to set a new password
- > cat shadow
- You'll see
- userid:jiberish:99999::::::
- jiberish = the encrypted password
- 99999 = machine date for when the password was created
-
- Set up the group
- > vi group file
- If the desired group does not exist in the file, add it on
the last line.
- groupname::gid:userid
- webadmin::456:widc1s,widvlc
- gid must be the unique group id number
- Other wise, add the user to the end of the line where the
group is defined.
- close and save (:wq!)
-
- Set up the users home directory
- typically created in /home/userid
- > cd /home
- > mkdir userid
- > chmod 755 userid
- this allows for world read) if you don't want that, set permissions
accordingly (750)
- > chown userid|group
|
|
Permissions
- Online Manpages
- chmod
- chown
- chgrp
|
- Set up in 3 levels
- user | group | world
- Each level contains 3 fields which define the permisson state.
- read - denoted by a 4
- write - denoted by a 2
- execute - denoted by a 1
- These are set with a number in the chmod command, but are
viewed in english.
- ie: rwx rwx rwx = read, write, execute for all 3 levels of
access.
- These numbers are added together to define the permission
state for that level of access.
- to set rwx = add all the numbers together 4+2+1 = 7
- to set r-x = add the numbers 4+0+1 = 5
- to set r-- = add the numbers 4+0+0 = 4
- to set --- = add the numbers 0+0+0 = 0
- Level designators:
- You can also use one of the level designators to set permisions.
- u - the users permission set
- g - the group permission set
- o - the world (or other) permission set
- a - all the permission sets
- If you use the level designators, you will also have to use
one of the operator parameters to define what you want to change
in the permission set.
- - (minus sign) - remove a permission
- + (plus sign) - add a permission
- = (equal sign) - assign permissions absolutely
- Permissions are indicated as follows:
- r - the file is readable
- w - the file is writable
- x - the file is executable
- - - the indicated permission is not granted
- s - the set-user-ID or set-group-ID bit is on,
and
- the corresponding user or
group execution bit is also on
- S - undefined bit-state (the set-user-ID bit
is on and the user execution bit is off)
- t - the 1000 (octal) bit, or sticky bit, is on
(see chmod(1)), and execution is on
- T - the 1000 bit is turned on, and execution
is off
|
|
Directory / File Attributes |
- In addition to the 3 levels of permissions seen on a files
attribute defines what kind of file or directory the item is.
When the ls -la command is used, this first character can be
one of the following:
- d (ie: drwxr-xr-x)
- The entry is a directory.
- D (ie: Drwxr-xr-x)
- The entry is a door.
- l (ie: 1rwxr-xr-x)
- The entry is a symbolic link.
- b (ie: brwxr-xr-x)
- The entry is a block special file.
- c (ie: crwxr-xr-x)
- The entry is a character special file.
- p (ie: prwxr-xr-x)
- The entry is a FIFO (or "named pipe") special file.
- s (ie: srwxr-xr-x)
- The entry is an AF_UNIX address family socket.
- - (ie: -rwxr-xr-x)
- The entry is an ordinary file.
|
|
Set permissions on a file or directory |
- For a directory
- > cd to the parent directory
> ls -la = list the details
of the contents of that directory
You'll see a list that looks like this:
- drwxr-x-r-x space
lastchngdate directoryname
- -rwxr-x-r-x space lastchngdate
filename
- d = identifies the entry as a directory
- > chmod 774 directory name
- this will set permissions for the directory to drwxrwxr--
-
- For a file
- > cd to the directory where
the file exists
- > chmod 700 filename
- this will set permissions for the file to rwx------
-
- To set execute permissions to a user, yet maintain the running
of the process as the user id that owns the file:
- the file must be owned by root
- > cd to the directory where
the file exists
- > chmod 4755 filename
- this will set permissions for the file to rwxrwxrsx
- the s defines the process permission
-
- To define permissions for a directory and all it's subordinate
contents:
- > cd to the parent directory
- > chmod -R 774 directory
name
- R = recursive
- r = hide the directory and it's contents (careful with this)
Using the Level Designators:
- If you want to use one of the letters to designate which
set of permissions you're working with, the chmod command is
defined as follows:
- > chmod -R g+r file.name
- R = recursive
- g+r = add read access to the group permission set.
Notes:
- Absolute changes don't work for the
set-group-ID bit of a directory. Instead, you must use the g+s
or g-s parameters.
|