tutor:Users

From Dgiref
Jump to: navigation, search

Contents

User environment

/etc/skel

Contains the default environment files for new user acconts.

ls -a
.  ..  .bash_logout  .bash_profile  .bashrc
  • .bashrc - the basic bash configuration file may include a reference to the general /etc/bashrc configuration file and commands to run on the bash shell start, e.g. rm='rm -i'
  • .bash_logout - the file is executed during the bash shell exit.
  • .bash_profile - the bash startup environment file. Can contain the PATH directories.

/etc/bashrc

Is used for aliases and functions, on a system-wide basis.

  • assigns a value of umask to create the default permissions for newly created files.
  • assigns a prompt
  • includes settings from *.sh files in the /etc/profile.d

/etc/profile

Is used for system-wide environments and startup files.

/etc/profile.d/

Shell commands

useradd - Adding a new user

Options:

  • -d home directory
  • -s starting program (shell)
  • -p password
  • -g (primary group assigned to the users)
  • -G (Other groups the user belongs to)
  • -m (Create the user's home directory

Example: To add a new user with

  • a primary group of users
  • a second group mgmt
  • starting shell /bin/bash
  • password of xxxx
  • home directory of roger
  • create home directory
  • a login name of roger
useradd -gusers -Gmgmt -s/bin/shell -pxxxx -d/home/roger -m roger

usermod - Modifying existing user

Options:

  • -d home directory
  • -s starting program (shell)
  • -p password
  • -g (primary group assigned to the users)
  • -G (Other groups the user belongs to)

Example: To add the group 'others' to the user roger

usermod -Gothers roger

userdel - Deleting a user =

Options:

  • -r (remove home directory)

Example: To remove the user 'roger' and his home directory

userdel -r roger
Personal tools