CNT-2311-Chapter 7 Notes
Linux Usernames
Consist of any combination of upper and lowercase letters, numbers and many punctuation symbols.
User names must begin with a letter and are case sensitive
Usernames may consist of 32 characters but may truncate a username to only 8 characters.
Users
Users are defined not by their name but by a UID (User Id).
First hundred IDs saved for system use.
To remove user accounts use the following userdel commands
userdel -r causes system to remove all files from user home directory
userdel -f -r forces the system to remove all files
To find files owned by a certain User use the find command
find / -uid 529, this should list all files owned by that UID.
Useradd
useradd username is the simplest command to add a user.
-c comment parameter passes public information like phone number or real name
-d home-dir specify an accounts home directory
-e YYYY-MM-DD expiration date for the account to be disabled
-f inactive days set the number of day an account is disabled after a password expires
-g default group Set the default group
-G group Adds additional groups, multiple groups can be add with commas.
-s Sets default shell login for the user.
-p encrypted-password uses a pre-encrypted password for the user to the system
Example
- useradd -d /home4/roger -g project4 -G project1, project4 -s /bin/tcsh sally
- passwd pwnd
Passwd
Passwd is much easier to use to set or change a passwd for a user.
passwd commands
-k indicates system should update an expired account
-l locks an account by prefixing the encrypted password with an exclamation mark
-u unlocks an account by removing the prefixed exclamation mark
-d removes the password from an account
-S displays account information about the password
Many passwd parameters can only be run in root.
usermod
Usermod and useradd are very similar, a very noteable difference is that Usermod allows you to edit existing accounts.
usermod allows -m parameter to be run with -d. This changes a user directory and moves the files to that new directory.
usermod allows you to change a users login name with the -l parameter, IE usermod bilbo -l bbaggins. bilbo > bbaggins
Groups
Groups are a collection of accounts mainly for security reasons.
Every file on a Linux system is associated with a specific group and different permissions can be assigned to various members of that group.
Group membership is controlled through /etc/group file.
Each user has a primary group that is set in the /etc/passwd file.
To change from one group to another type newgrp (desired group).
Adding Groups
The groupadd command is used to add new groups
group [-g GID [ -o]] [-r] [-f]
-g specifies desired GID
-r Creates a sub-500 GID
-f Force creation
Example
- groupadd project3
To delete groups use the groupdel command.
System Log Files
The traditional system logger is syslogd, often installed from a package called sysklogd.
To manually log data you would use the logger command the following are syntax used with logger
-i Records the loggers process ID number
-s Echos data to a standard error
-d Causes the logger to use datagrams instead of stream
-f filename command to log the contents of a file.
-p pri Speciffy prority.
System Time
To set the system time you will have to use the data parameter with a combination of the following syntax
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY}[.ss]]
By default date assumes you are trying to set local time. If you want to set the universal include the -u or -utc.
-r or --show will display the set time for the hardware clock
--set and --date=newdate sets the hardware clock manually
--systohc sets the hardware clock based on the software clock
--hctosys sets the software clock based on the hardware clock
--UTC or --localtime will tell the hardware clock hold that specific time.