Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm a software dev suddenly finding myself having to play SysAdmin.

Recently, I was given a box previously administered by somebody else, and this SysAdmin kind of just did what he wanted. My supervisor is given the box to SysAdmin, and it appears that the home directories for users are hidden everywhere in the box.

Needless to say, the answer to his problem is "hey intern!"

So, I was wondering if there was a way to find all of the home directories for all of the users on the box? The box I'm working on is RHEL 5.

share|improve this question
Welcome to the club! – mfinni Jul 31 '13 at 21:20
up vote 7 down vote accepted

Assuming all the users are local users (that is, there's no network directory service like LDAP, Active Directory, NIS, etc), then local users are probably all enumerated in /etc/passwd, which is a colon delimited file with the following fields:

username:password:uid:gid:name:home directory:shell

You can get just the usernames and home directories, if that's easier, like this:

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

Using Urgoll's suggestion of using the getent command, that's:

getent passwd | awk -F: '{print $1,$6}'
share|improve this answer
Even if the box uses ldap, active directory, NIS or whatever, your answer is mostly correct. The following command will output the aggregated content of all passwd sources and can be manipulated with awk: getent passwd – Urgoll Jul 31 '13 at 21:14
...except it won't, in some cases. Many backend directories implement a limit on result size of any query, so getent in some cases cannot enumerate all the available users. But for smaller environments, yeah, that works. – larsks Jul 31 '13 at 21:16

You're in luck! Everything you want in /etc/passwd :-)

For example:

jay:x:1000:1000:Jay Shah,,,:/home/jay:/bin/bash

Where jay is my username, 1000 is my uid/gid, /home/jay is my home directory, and /bin/bash is my shell.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.