CNT-2311-Chapter 7 Notes: Difference between revisions

From ITCwiki
Jump to navigation Jump to search
Line 80: Line 80:


To change from one group to another type newgrp (desired group).
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

Revision as of 10:13, 24 March 2011

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

  1. useradd -d /home4/roger -g project4 -G project1, project4 -s /bin/tcsh sally
  2. 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

  1. groupadd project3