'ls -n' opens password file for reading

Ubben Greg bink at aplcen.apl.jhu.edu
Tue May 16 13:00:43 AEST 1989


In article <1622 at auspex.auspex.com> guy at auspex.auspex.com (Guy Harris) writes:
> he didn't say anything about "ls" without the "-n" flag or with other
> flags.  I presume he has a legitimate reason for wanting to do an "ls
> -n" on a system with either "/etc/passwd" or "/etc/group" missing.... 

Speaking of "ls -n" ... (INFORMATION ARTICLE)
For Bourne shell programmers, the following script magnifies the
speed difference between using "ls -n" and "ls -l" on System V:

	mkdir a && cd a		# Build playpen
	# Create a lot of files with different owners to make ls work hard
	sed 's/:.*//; s/.*/chown & & >&/' /etc/passwd | sh -
	timex ls -l		# Really slow (might want to >/dev/null)
	timex ls -n		# Much faster (though less portable)
	cd .. && rm -fr a	# Clean up (be careful)

You can instead just try LS on one of the more popular parents of home
directories for the same effect.  For this reason, I never use "ls -l"
in scripts when I don't need the actual owner or group names.

					-- Greg Ubben
					   bink at aplcen.apl.jhu.edu



More information about the Comp.bugs.sys5 mailing list