Classmate S

just for fun

Friday, September 29, 2006

linux下对用户的管理

查找UID>999的所有用户的信息

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

nobody:x:65534:65534:nobody:/nonexistent:/bin/sh

sunzhe:x:1000:1000:sunzhe:/home/sunzhe:/bin/bash

debian中,不同的UID段代表不同类型的用户。

IDs 0-99 are for system accounts.

IDs 100-999 are for user-installed programs and daemons, such as Postfix, Fetchmail, gdm, dictd, and so on.

IDs 1000-29999 are ordinary user accounts.

IDs 30000-65533 are reserved, according to the Debian policy manual, but you may use them however you like.

ID 65534 is user “nobody,” an account with no rights or permissions.

sunzhe@debian:~$ id sunzhe

显示如下

uid=1000(sunzhe) gid=1000(sunzhe) groups=1000(sunzhe),20(dialout),24(cdrom),25(floppy),29(audio),44(video),46(plugdev)

useradd -m newusername 添加新用户

passwd -e username 使现有密码过期

passwd username 设置密码

useradd -D 显示新建用户的默认配置

adduser username 这个命令从头配置各项,感觉比useradd好用一些

finger username 查看指定用户的配置

usermod -l a b 将用户b的登录名改成a

usermod -u 1200 a aid改成1200

usermod -d /server1/home/a/ -m a ahome文件夹转移

userdel username 删除用户但不删该用户的home文件夹

userdel -r username 全部删掉

ps U username(or UID) 查找所有运行进程

kill PID 杀掉进程

passwd -l username 锁住帐号

passwd -u username 解锁

groupadd newgroup 增加一个组

groupadd -r newgroup 增加一个系统组

su root身份运行

exit 返回

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home