您的位置:首页 > 其它

ubuntu中查看所有的用户信息

2013-06-09 10:53 239 查看
What is the command to list users in ubuntu?. In this tutorial i’ll share How to List all users in ubuntu via command line. you can easily list users in ubuntu using the cat command as follows:

$ cat /etc/passwd



OR you can view per page ,use following commands

less /etc/passwd
more /etc/passwd



Output :

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
...........
.........


All fields are separated by a colon (:) symbol. Total seven fields exists. The first field is username. It is used when user logs in. It should be between 1 and 32 characters in length

you can also list only usernames with command awk , type these command in terminal :

awk -F':' '{ print $1}' /etc/passwd



Here’s example outputs of command above:

root
daemon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
.....
.....
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: