List /home directories in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting List /home directories in a file
# 1  
Old 08-25-2009
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?
# 2  
Old 08-25-2009
Code:
ls /home

or, if you want information on who owns the directories in /home:
Code:
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.
# 3  
Old 08-25-2009
try..
Code:
-bash-3.2$ awk -F: '{print $6}' /etc/passwd > /home/userinfo/usernames
/root
/bin
/sbin

or as for the exercise

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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

List the directories, having given pattern in the directories name, sorted by creation date

It is for HP-Unix B.11.31. Requirement: 1. List the directories, having given pattern in the directories name, sorted by creation date. Example: Directories with name "pkg32*" or "pkg33*" 2. On the output of 1. list the directories by creation date as sort order, with creation date... (2 Replies)
Discussion started by: Siva SQL
2 Replies

2. Shell Programming and Scripting

Looping inside directories based on a file which contains file directory list

Hi All, Please help. I have got a file which contains a listing of a file and some directories after it, one by one. I am calling this file xyz.txt here file1 dir1 dir2 dir3 dir4 file2 dir5 dir6 dir7 dir8 file3 dir9 dir10 dir11 dir12 (6 Replies)
Discussion started by: Piyush Jakra
6 Replies

3. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

4. HP-UX

Home directories in packages

Hi, At my new company they use HP-UX on all the servers. They use Serviceguard to provide different packages, which are treated as if they where seperate systems. Therefore people log into packages instead of Host, and even the home directories live in the package. Now there are a different... (4 Replies)
Discussion started by: michas
4 Replies

5. Shell Programming and Scripting

how to list of file in home dir ?

I want to print all list of file in the home dir of the user in $i with full bath an owner and group and permissions (1 Reply)
Discussion started by: testman84
1 Replies

6. Shell Programming and Scripting

How to list all the directories, sub directories in a mount along with size in ascending order?

Hi , I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In a particular mount, have to list all the directories and sub directories along with size of the directory and sub directory in ascending order. Please help me in this regard and many... (4 Replies)
Discussion started by: nmakkena
4 Replies

7. UNIX for Dummies Questions & Answers

UNIX home directories

Hi All, Could someone help, am a complete beginner when it comes to UNIX. However I have been tasked with investigating automatic creation of UK unix home directories. Is someone able to help? Thanks in advance! (7 Replies)
Discussion started by: zainster
7 Replies

8. Solaris

How to backup /home directories?

I know that how to backup the home directories in sun sparc server. Firstly, umount the filesystem, Secondly, fsck the filesystem, Thirdly, ufsdump the filesystem. Anybody know how to type the full command line backup the /home directory? (1 Reply)
Discussion started by: kingsan
1 Replies

9. UNIX for Dummies Questions & Answers

Delete old home directories

I have a script that deletes obselete users from /etc/passwd then moves their home directories to another location. After 30 days, I need to delete the home directories that were moved to the new location. I would appreciate any ideas on how to delete the directories after the 30 days? (2 Replies)
Discussion started by: munch
2 Replies

10. UNIX for Dummies Questions & Answers

list directories on a file system

how can i see the list of directories, mounted on a filesystem? example, to show the list of directories mounted on / for aix (8 Replies)
Discussion started by: yls177
8 Replies
Login or Register to Ask a Question