Terminal Tips: 5 ways to navigate with ease
How many times have you been in Terminal and wished you could navigate around with a little more ease? In this Terminal tip, we will show you 5 must-know tips for working with Terminal.app. 1. Change your current directory
If you want to change the current directory you're in, just type: cd /change/to/dir. For example, if I wanted to change the directory to my Desktop, I would type: cd ~/Desktop .
2. List files and folders in the current directory
Now that you're in a directory, you might want to get a listing of what's there. To see this, just type ls.
3. See which directory you're in
If you've navigated your way into an unknown land, typing pwd will display a path listing to the directory you're in.
4. End a running script/program
If you're running a program/script (for example: ping google.com) then you might think you have to close the Terminal window to exit. That's not true. To stop a running script or program, just press control + C.
5. Clean up your mess
If you have several of commands on the screen and want to "freshen-up" your Terminal window, typing clear will remove all commands you have typed up to that point, leaving you with a clean slate.
Want more tips and tricks like this? Visit TUAW's Mac 101 and Terminal Tips sections.
Share
Categories
How many times have you been in Terminal and wished you could navigate around with a little more ease? In this Terminal tip, we will show...
Add a Comment
There's also the Bash cd alias: cdots (which uses TAB completion).
(See the links on http://codesnippets.joyent.com/posts/show/1690 )
#1 is going to be confusing for anyone who slightly benefits from this post.
~ is a short cut for your home directory
$ cd /Users/yourshortname/Desktop
is the same as
$ cd ~/Desktop
but the best trick is left out, and should be #1 of the "must know":
$ man `thing you want to learn about'
you missed my favorite
open .
which opens a finder window for the directory you are currently in. Helpful when you want to send a file via email or use the finder's open with... dialog.
hrm, maybe I missed it..(# 6 above).
September 29 2008 at 8:08 PM Report abuse Permalink rate up rate down Replyopen
will open any file using whatever the default app for that type is. For instance, if the file is a PDF, it will be opened with Preview (or Adobe Acrobat Reader, if that's your default).
ls -alrt
shows the file list in reverse chronological order with the latest files at the bottom of the list
helpful if you have a large directory and need to see which files changed last
Whoa! All change... I typed that last post - old style... Now New Style TUAW!
I like it guys, well done
And a few more...
1) use semi-colon ; to enter multiple commands, one of my favourites is "clear;ls"
2) "pwd" will print working directory in case you get lost in a deep path
3) "cd" on it's own will return you to your home directory
4) "ls -a" will also show hidden files
5) "ls -al" will also show hidden files in long format
6) "open ." will open the current directory in a finder window
7) TAB will autocomplete a path for you. e.g from your home folder try "cd Des"then TAB. "cd Desktop" will be filled in (if not, see below...)
8) If there are multiple possible matches, there will be a system beep, pressing TAB again will list all matches. e.g. try "cd D" then press TAB. Beep. Now press tab again, Desktop/ Documents/ Downloads/ are listed.
9) Tip 8 works when you're entering any bit of a path. E.g. try "cd Library/P" then press TAB twice. Usual beep plus a list of things that start with P inside Library.
10) Remember that everything is case sensitive, so "p" is not the same as "P"
Nice feature is the ability to drag a folder or item from the finder to the terminal window to get it's unix path. Try cd (drag and drop a folder from the finder.)
September 29 2008 at 5:10 PM Report abuse Permalink rate up rate down ReplyA few more tips:
1) Even easier than "clear": just hit Ctrl-L to clear the Terminal screen.
2) Typing "!!" then enter will repeat the last command you typed.
3) Up/down arrows scroll through your command history.
4) Ctrl-W = delete previous word
5) Ctrl-U = delete entire line
6) Ctrl-K = delete from cursor to end-of-line
7) As mentioned in the article, "ls" will list files in a directory. "ls -l" [that's a lowercase L] will give you a long format listing.
Why use the 'clear' command when you can just press command-k to clear the scrollback? All clear does move the prompt to the top.
September 29 2008 at 4:02 PM Report abuse Permalink rate up rate down ReplyI think a better/quicker alternative to #5 is simply âK, which clears the scrollback.
September 29 2008 at 4:00 PM Report abuse Permalink rate up rate down ReplyHot Apps on TUAW
Deals of the Day
more deals- Altec Lansing Octiv Duo iDock for $48 + free shipping
- Used Apple iMac 17" Core 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
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



14 Comments