List /home directories in a file

Hi, i was looking at a unix paper i found and one of the tasks was to create a file called 'usernames' that contains a list of all directories in /home. This file should be located in the /home/userinfo directory.

How would i go about doing this without changing directories from the home directory /root?

ls /home

or, if you want information on who owns the directories in /home:

ls -l /home

However, this only tells you which users have home directories. And, in some cases, there may be directories here for users without accounts.

You may try to view the output of the /etc/passwd file for a more accurate list of user accounts.

try..

-bash-3.2$ awk -F: '{print $6}' /etc/passwd > /home/userinfo/usernames
/root
/bin
/sbin

or as for the exercise

ls -1 /home > /home/userinfo/usernames