Changing Passwords in a Batch
On a large system, there might be times when a large number of users and
their passwords need some attention. The super user can change passwords in
a batch by using the chpasswd command, which accepts input as a
name/password pair per line in the following form:
Click here to view code image
matthew@seymour:~$ sudo chpasswd username:password
Passwords can be changed en masse by redirecting a list of name and
password pairs to the command. An appropriate shell script can be
constructed with the information gleaned from Chapters 11 and 12 ,
“Command-Line Master Class, Part 1” and “Command-Line Master Class,
Part 2,” combined with information on writing scripts from Chapter 14,
“Automating Tasks and Shell Scripting.”
However, Ubuntu also provides the newusers command to add users in a
batch from a text file. This command also allows a user to be added to a
group, and a new directory can be added for the user, too.
Granting System Administrator Privileges
to Regular Users
On occasion, it might be necessary for regular users to run a command as if
they were the root user. They usually do not need these powers, but a user
might require such abilities on special occasions—for example, to temporarily
access certain devices or run a command for testing purposes.
There are two ways to run commands with root privileges. The first way is
useful if you are the owner of both the super user account (an enabled root
account) and a regular user; the second way is useful if you are a regular user
but are not privileged to access all super user functions. (This might happen
on a large, multiuser network with senior and junior administrators as well as
regular users.) Let’s look at each.
Temporarily Changing User Identity with the su
Command
This first scenario requires the existence of a root account, which is not
enabled by default on Ubuntu systems and is not generally recommended in
the Ubuntu community. However, there are times when it makes sense.