Monday man page: ls
There are two kinds of Mac folk: them that finds this "Terminal" thing strangely fascinating, and them what considers it the worst kind of wicked magic, not to be trifled with. Here at TUAW we've got all kinds, and for anyone who might be curious about the power and possibilities of the command line, we're going to provide some weekly quick tips and suggestions for introductory use. Always keep in mind, though, that the damage you can do from Terminal is effectively unlimited, especially with administrative access. Best to play around in a 'dummy' account until you have your sea legs.Even before we start, an explanation of the title: 'man pages' are the BSD UNIX manuals, already tucked away on your Mac. You can type "man command" in Terminal for a detailed (not to say overwhelming) rundown on any command-line tool. As we've mentioned before, an excellent intro to Terminal in Tiger can be found over at the O'Reilly Mac Dev Center. We also posted about Unix for the Beginning Mage, an amusing beginner's guide to the plumbing under Mac OS X.
Our fine feathered friend today is 'ls' -- the UNIX directory list command. Read on for more...The 'ls' command will, in basic form, list the contents of a directory. Type 'ls ~/Desktop' sans quotes in Terminal, and get a readout of the files on your Desktop:
Last login: Mon Dec 18 00:02:44 on ttyp1"Cool beans," you say, "but can't I do that from the Finder?" Yes; but with some options, 'ls' can:
Welcome to Darwin!
MTR-iMac-242:~ miker$ ls ~/Desktop
Desktop 20060904 MacHeist ?? Bundle Receipt.pdf
Desktop 20061217 TuneTalk.JPG
- list ALL the files in a directory: 'ls -a ~/Desktop' -- great for finding mystery files; C.K. posted about this a while back
- give a detailed readout including permissions: 'ls -l' -- or combine with above for all the invisibles and all the permissions: 'ls -la'
- see the otherwise-hard-to-find ACLs for a directory or file: 'ls -e'
- sort the file list by modification date, most recent first: 'ls -t'
Share
Source: http://www.hmug.org/man/1/ls.php
Categories
There are two kinds of Mac folk: them that finds this "Terminal" thing strangely fascinating, and them what considers it the worst kind of...
Add a Comment
Suggestions noted: next week, a special Xmas Monday man page on dig, host and nslookup.
December 19 2006 at 12:07 AM Report abuse Permalink rate up rate down ReplyMichael:
It'd be cool for you to do one on dig next. If more people know about it and nslookup (actually what I usually use), I can pretend there are more people who will want to learn more about DNS in general and troubleshoot their own issues :)
Ahhh yes, "ls -alh --color=auto" is what I aliased ls to be on my old linux systems. I tried that on the mac (recent switcher) and obviously was disappointed. I didn't even think about researching the BSD equivalent. Thanks for the -G info.
I vote for a detailed review on the "Dig" command. That thing can be powerful in scripting.
little more fitting to what ls --color=auto does (for bash users...
in your ~/.bash_profile
if [ "$TERM" == "xterm-color" ]; then
alias ls='ls -G'
fi
wow, three comments in one story. I really need to gather my thoughts a little better prior to posting :-)
The BSD backbone is one of the reasons I moved back to an Apple computer after almost 20 years. I do not go a day without accessing the command line.
December 18 2006 at 12:00 PM Report abuse Permalink rate up rate down ReplyNarco: sorry to hear it. Most likely there was something else wonky on your machine...
Ryan: I'd put you in the 'fascinated' category, or possibly the 'jaded' category.
""ls --color=auto" is my personal favorite, and what "ls" is aliased to on all my systems (dunno what the BSD equivalent is)."
ls -G
Well if there's a coincidence like none other this would be it. After having to repair a busted iMac G5 today (wouldn't boot) I scoured the internet searching for this very command! How odd!
Seriously, tuaw, stop reading my mind. First, an Apple Store in Scotland - now this!
I had my first brush with Terminal yesterday when I tried to delete a 20GB text file that would Kernel Panic every time I tried to delete it. I had lots of help, of course.
Long story short, the hard drive won't boot up. That's the end of my Terminal days.
Fishes,
narco.
What about the mac folk that has at least a dozen terminal windows open at a time, and spends his 8 hour work day there?
December 18 2006 at 11:48 AM Report abuse Permalink rate up rate down ReplyHot Apps on TUAW
Deals of the Day
more deals- Used Apple iMac 17" Core 2 Duo 1.83GHz for $430 + $28 s&h
- Lounge Deluxe Stand for iPhone / iPod touch for $28 + $8 s&h
- Brookstone Surround-Sound Earbuds for $14 + $7 s&h
- Refurbished Skullcandy Tokidoki Smokin' Buds Mic'd Headset for $5 + $2 s&h
- Stitchway Backup Battery for iPod / iPhone for $5 + free shipping
- Used Apple MacBook Pro 2.4GHz 15" LED Laptop for $1,030 + $29 s&h
Software Updates
more updates- EFI Firmware Update brings Lion Internet Recovery to 2010-model Macs
- OS X Lion 10.7.3 released with Safari 5.1.3, Wi-Fi bug fix
- Aperture updated to 3.2.2, addresses Photo Stream issue
- Apple updates Keynote to address Lion issues
- Google Search app gets new look on iPad
- Apple releases Apple TV Software Update 4.4.3



19 Comments