Linux

  1. Home
  2. Computing & Technology
  3. Linux

Linux Newbie Administrator Guide

From Authors, for About.com

6.15 Management of user accounts and files permissions

useradd user_name

passwd user_name

(as root) Create a new account (you must be root). E.g., useradd barbara Don't forget to set up the password for the new user in the next step. The user home directory (which is created) is /home/user_name. You may also use an equivalent command adduser user_name.

ls -l /home/peter

useradd peter -u 503 -g 503

(as root). Create an account to match an existing directory (perhaps from previous installation). If the user ID and the group ID (shown for each file) were both 503, I create an account with a matching user name, the user ID (UID) and the group ID (GID). This avoids the mess with changing the ownership of user files after a system upgrade.

userdel user_name

Remove an account (you must be a root). The user's home directory and the undelivered mail must be dealt with separately (manually because you have to decide what to do with the files). There is also groupdel to delete groups.

groupadd group_name

(as root) Create a new group on your system. Non-essential on a home machine, but can be very handy even on a home machine with a small number of users.

For example, I could create a group "friends", using

groupadd friends

then edit the file /etc/group, and add my login name and the names of my friends to the line that lists the group, so that the final line might look like this:

friends:x:502:stan,pete,marie

Then, I can change the permissions on a selected file so that the file belongs to me AND the group "friends".

chgrp friends my_file

Thus, the listed members of this group have special access to these files that the rest of the world might not have, for example read and write permission:

chmod g=rw,o= my_file

The alternative would be go give write permission to everybody, which is definitely unsafe even on a home computer.

groups

List the groups to which the current user belongs. Or I could use groups john to find to which groups the user john belongs.

usermod

groupmod

(as root) Two command-line utilities to modify user accounts and groups without manual editing of the files /etc/passwd /etc/shadow /etc/group and /etc/gshadow. Normally non-essential.

userconf

(as root) Menu-driven user configuration tools (password policy, group modification, adding users, etc). Part of linuxconf package, but can be run separately.

passwd

Change the password on your current account. If you are root, you can change the password for any user using: passwd user_name

chfn

(="change full name"). Change the information about you (full name, office number, phone number, etc). This information is displayed when the finger command is run on your login_name.

chage -M 100 login_name

(= "change age"). Set the password expiry to 100 days for the user named login_name .

quota username

setquota username

quotaon /dev/hda

quotaoff /dev/hda

quotastats

A set of commands to manage user disk quotas. Normally not used on a home computer. "Disk quota" means per-user limits on the usage of disk space. The commands (respectively) display the user quota, set the user quota, turn the quota system on the for a given filesystem (/dev/hda in the above example), turn the quota system off, display quota statistics. "Typical" Linux distros I have seen set on default: no limits for all users, and the quota system is off on all filesystems.

kuser

(as root, in X terminal) Manage users and groups using a GUI. Nice and probably covering most of what you may normally need to manage user accounts.

chmod perm filename

(=change mode) Change the file access permission for the files you own (unless you are root in which case you can change any file). You can make a file accessible in three modes: read (r), write (w), execute (x) to three classes of users: owner (u), members of the group which owns the file (g), others on the system (o). Check the current access permissions using:

ls -l filename

If the file is accessible to all users in all modes it will show:

rwxrwxrwx

The first triplet shows the file permission for the owner of the file, the second for the group

* License

* Linux Newbie Administrator Guide Index

Explore Linux

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Linux

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Documentation
  5. Newbie Administrator Guide
  6. Linux Newbie Administrator Guide - 6.15 Management of user accounts and files permissions

©2009 About.com, a part of The New York Times Company.

All rights reserved.