A couple of my items. Click to view more. I think you need something like this
 

 

2008-08-22

Linux : Creating & Managing Users Accounts Part 1

I’ve been asked here on my blog about creating user accounts and giving them access to folders such as /var/www or creating ftp users that link to a single folder. That was quite a while ago. Since then i have picked up quite a bit about user management and thought that i would let you in on my findings.

In Part 1 I’m going to show you how to add and manage user accounts. Learning these features has been a critical part of efficiently managing the 10+ Linux servers.

In order to create new logins, modify or delete users, you must already be logged in as sudo user. The sudo user login is the highest level (assuming you have the root account disabled) and only certain individuals should have access to a sudo account.

useradd - Adding a new user

Each user must belong to a primary group and for security or access purposes can belong to several secondary groups.

Options:

  • -d home directory
  • -s starting program (shell)
  • -p password
  • -g (primary group assigned to the users eg -gwww-data (note no space between the -g and www-data)
  • -G (Other groups the user belongs to eg -Gusers (note no space between the -g and users)
  • -m (Create the user’s home directory

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)

userdel - Deleting a user

Options:

  • -r (remove home directory)

Example: To remove the user ‘rebecca’ and his home directory

userdel -r rebecca

passwd - User’s Password

Options:

  • user’s name (Only required if you are root and want to change another user’s password)

Example: To change the password for the account you are currently logged in as…

  1. passwd
  2. Enter existing password
  3. Enter new password
  4. Enter new password again (to validate)

Example: To change the password for the user ‘mark’ (only you are logged in as a sudo user)…

  1. passwd mark
  2. Enter existing password (can be either marks’s password or sudoer’s password)
  3. Enter new password
  4. Enter new password again (to validate)

Where user and group information stored

User names and primary groups are stored in /etc/passwd. This file can be directly edited using the ‘vi’ editor, although this is not recommended. Format of the file is…

  • User name (normally all lower case)
  • Password (encrypted - only contains the letter ‘x’)
  • User ID (a unique number of each user)
  • Primary Group ID
  • Comment (Normally the person’s full name)
  • Home directory (normally /home/
  • Default shell (normally /bin/bash)

Each field is separated by a colon.

Passwords for each user are stored in /etc/shadow. This file should only be changed using the passwd command.

Group information is stored in /etc/group. This file can be directly edited using the ‘vi’ editor. Format of the file is…

  • Group name
  • Group password (hardly ever used)
  • Group ID
  • User names (separated by commas)

Each field is separated by a colon.

Default files

When a new user is created, the default files and directories that are created are stored in /etc/skel.

This directory can be modified to fit your needs. Modifications only effect new users and does not change anything for existing users.

su - Switch User

To switch to another user, use the su command. This is most commonly used to switch to the root account.

Example: To switch to root account…

  1. su
  2. Enter root’s passwd

Example: To switch to the user ‘rebecca’…

su rebecca

Enter Rebecca’s or the sudoer’s passwd

To return to original user, enter exit

Well there you go. In Part 2 I’m going to go over how to add users for the web folders including FTP users that are limited to their home folder.

Related Posts

This entry was posted on Friday, August 22nd, 2008 at 5:14 pm and is filed under Linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

 

recent projects

My Boy (1)

Title : My Boy (1)
Media: Canon EOS 350D DSLR, Adobe Lightroom, Photoshop
Description : A day out in the park with my world.

Tasmania Corrective Services Badge

Title : Tasmania Corrective Services Badge
Media: Adobe Illustrator, Stitch
Description : Badge for the Canine Drug Detection Unit

 

Webb Martin Consulting Website Concept 1

Title : Webb Martin Consulting Website Concept 1
Media: Blog/Website, flash, css, xhtml, php
Description : Website deisgn for Webb Martin Consulting

Webb Martin Website Design Concept

Title : Webb Martin Website Design Concept
Media: Wordpress, CSS, xhtml, php
Description : Concept website design for Webb Martin.

 

 

site tags

 

meta

About Jamie Le Souëf

Jamie Le Souef

I'm a 27 year old Freelance Front and Back end designer /developer from Melbourne, Australia. I'll put more about me in here once i get my about page done

Ajax CommentLuv Enabled 67885f39b533899c64b408034951e375

syndication & misc