viagra online vicodin online

Posts Tagged ‘Linux’

Adding Users with useradd

Friday, February 1st, 2008

If you need to add new users to a Linux system, use useradd -m to create a login name, home directory, and other environment variables, and use the passwd -e command to set the new password. The account is not active until you create a password.

This is the simplest invocation. The -m flag creates a home directory and copies in the files from /etc/skel:

# useradd -m

newusername

Under most circumstances, you should also specify the user’s full name, using the -c (comments) flag. Put four commas after the user’s name, to leave other parts of the comments field (office number, etc.) blank.

# useradd -m -c Grace Hopper,,,, ghopper

When adding a new user, newusername becomes the user’s login name. This must be a unique name. Next, run passwd -e. The -e flag expires the password at first login, forcing the user to change it:

# passwd -e ghopper
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

The user’s environment is created according to the defaults in /etc/default/useradd and /etc/skel/. You can display the useradd defaults:

# useradd -D

Any of the default values can be overridden at the command line—for example, the UID and shell:

# useradd -u 1500 -s tcsh ghopper

Or you can add to the default values—for example, adding additional group memberships:

# useradd -G users,cdrecord,dialout ghopper

Finding a User’s UID and GID

Friday, February 1st, 2008

If you want to know a quick way to check the UIDs of users and see what groups they belong to, ue the id command:

$ id carla
uid=1000(carla) gid=1000(carla) groups=1000(carla),20(dialout),24(cdrom),25(floppy),
29(audio),30(dip),44(video), 105(windows),432(usb),1001(cdrecording)

id has a few options:

-u Show the UID only.

-g Show the GID only.

-gn Show the user’s primary group name, instead of the GID.

Sorting Human Users from System Users

Friday, February 1st, 2008

Every Linux system has a bunch of system accounts (root, uucp, daemon, etc.) in addition to regular users. They’re all lumped together in /etc/password. How do you list your human users separately from system accounts?

Take advantage of Linux’s user identification (UID) numbering scheme and awk’s ability to sort by fields or columns. This is for a Debian or Slackware system:

$ awk -F: ‘$3 > 999 { print $0}’ /etc/passwd
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
carla:x:1000:1000::/home/carla:/bin/bash
foober:x:1001:1001::/home/test:/bin/false
bitchkat:x:1002:1002::/home/test2:/bin/bash
colby:x:1003:1003::/home/test3:/bin/bash

To show a subset use:

$ awk -F: ‘($3 >= 1000) &&($3 <=1005) { print $0}’ /etc/passwd

This is for a Red Hat or SuSE system:

$ awk -F: ‘$3 > 499 { print $0}’ /etc/passwd

To sort them alphabetically use:

$ awk -F: ‘$3 > 499 { print $0}’ /etc/passwd | sort

Maintaining UNIX Users – Part 1/2

Thursday, January 31st, 2008

The relevant UNIX account system configuration files are:

  • /etc/passwd
  • /etc/group
  • /etc/shadow

(more…)

Adderall Tramadol viagra online