Home     Blog

How to List Unix Users

List Logged In Unix Users

Unix has many commands to list users who are logged in.

These commands include ‘w,’ ‘who,’ and ‘users:’


$ w
9:51PM up 99 days, 5:39, 2 users, load averages: 0.83, 0.90, 0.90
USER TTY FROM LOGIN@ IDLE WHAT
will p0 c-66-164-235-73. 8:11AM - w
spencer p3 c-66-164-235-73. 8:26PM 1:24 pine

$ who
will ttyp0 Jul 26 08:11 (66.164.235.73)
spencer ttyp3 Jul 26 20:26 (66.164.235.73)

$ users
spencer will

List All Unix Users

To list all users on a Unix system, even the ones who are not logged in, look at the /etc/password file.how to list unix users How to List Unix Users


$ cat /etc/passwd
...
george:*:1009:1009:George Washington:/home/george:/usr/bin/bash
tom:*:1016:1016:Thomas Jefferson:/home/tom:/usr/bin/bash
al:*:1017:1017:Alexander Hamilton:/home/alex:/usr/bin/bash
...

Use the ‘cut’ command to only see one field from the password file.

For example, to just see the Unix user names, use the command “$ cat /etc/passwd | cut -d: -f1.”


$ cat /etc/passwd | cut -d: -f1
...
george
tom
al
...

Or to only see the GECOS field (i.e. the account holder’s real name), try this:


$ cat /etc/passwd | cut -d: -f5
...
George Washinton
Thomas Jefferson
Alexander Hamilton
...

Note that users will also see Unix system accounts such as “root,” “bin,” and “daemon” in the /etc/passwd file. These system accounts are not Unix users.

VN:F [1.9.17_1161]
Rating: 10.0/10 (4 votes cast)
How to List Unix Users, 10.0 out of 10 based on 4 ratings
Follow Will.Spencer on

Comments (3)

 

  1. Robert Williams says:

    ls /home also works if the users you are interested in have a home directory

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
  2. sri harsha says:

    what are the user commands in unix?

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
  3. David Van Doren says:

    Can I change a users home directory by editing passwd

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply

Related Posts

  • How to Change a Unix Password

    To change your Unix password, use the `passwd` command.  Unless you are the “root” user, you will need to know your current password to set a new one.  If you have forgotten your current password, you will need to contact the “root” user to have your password reset. Here is an example of the user [...]...


  • Where to Find a Unix Tutorial

    Unix has many dedicated fans who have written quite a few excellent Unix tutorials for beginning users. Here are a few of the better Unix tutorials: Unix Tutorial for Beginners Unix: The Bare Minimum Introduction to Unix commands Unix Tutorial UNIXhelp for Users Unix Tutorial and Command Reference Unix Tutorial...


  • How to Copy a Directory from DOS to UNIX

    DOS and Unix are both well-seasoned operating software. While they don’t have a graphical user interface, they definitely suffice for those who like barebones, efficient software. For those who still have DOS files on their PC and would like to switch them over to UNIX, here are some tips. Even though DOS and Unix are [...]...


  • Unix Scripts

    A Unix script is a program which is written in a programming language built into one of the Unix shells. If you can type commands into the Unix shell, you can write a shell script. A shell script can be as simple as a text file containing a list of commands. Let’s say that you [...]...


  • Unix Shell

    A Unix shell is the program which reads user input from the command line and executes actions based upon that input. There are two general families of Unix shells, the Bourne family and the C family. The Bourne shell was the original Unix shell. The C shell was the first competing Unix shell. tcsh is [...]...