viagra online vicodin online

Archive for the ‘Users / Groups’ Category

Deleting a User

Friday, February 1st, 2008

If you need to delete a user, and you want to track down all the files that belong to the user, use userdel to delete the account, and use find to locate the files belonging to the user.

To delete a user:

# userdel aborg

The user cannot be logged in or running any processes for userdel to work.

userdel removes the user from all system account files (/etc/passwd, etc/shadow, /etc/group), but it does not touch files owned by the user. To remove the user’s home directory and mail spool, add the -r flag:

# userdel -r aborg

Other files, such as crontabs and data files outside the home directory, will have to be hunted down separately:

# find / -uid 1200

Adding Users with adduser

Friday, February 1st, 2008

If you want to use adduser instead of useradd, because it walks you through a complete new user setup—password, GECOS fields, and all, simply run adduser newusername and follow the prompts:

# adduser anitab
Adding user anitab…
Adding new group anitab (1008).
Adding new user anitab (1008) with group anitab.
Creating home directory /home/anitab.
Copying files from /etc/skel
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for anitab
Enter the new value, or press ENTER for the default
Full Name [ ]:
Room Number [ ]:
Work Phone [ ]:
Home Phone [ ]:
Other [ ]:
Is the information correct? [y/n] y

You can assign a UID, overriding the default:

# adduser —uid 1500 anitab

adduser’s defaults are configured in /etc/adduser.conf

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

Adderall Tramadol viagra online