Filed under: Terminal Tips
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.
Get a WordPress.com Blog
![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 1)
GMAN said 3:06PM on 9-29-2008
Aw man..
Thats too basic.. no Trick here...
Reply
andy said 3:24PM on 9-29-2008
there really be NOTHING else going on.
This post is moronic.
ls ?
Reply
Gianni said 4:00PM on 9-29-2008
I think a better/quicker alternative to #5 is simply ⌘K, which clears the scrollback.
Reply
scott said 4:02PM on 9-29-2008
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.
Reply
CaptSaltyJack said 4:04PM on 9-29-2008
A 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.
Reply
Paul E. Ester said 5:11PM on 9-29-2008
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.)
Reply
colm said 5:38PM on 9-29-2008
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"
Reply
UnusualAspect said 5:57PM on 9-29-2008
Whoa! All change... I typed that last post - old style... Now New Style TUAW!
I like it guys, well done
Reply
Gordon Werner said 7:57PM on 9-29-2008
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
Reply
np0x said 8:08PM on 9-29-2008
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.
Reply
np0x said 8:09PM on 9-29-2008
hrm, maybe I missed it..(# 6 above).
r.brick said 11:47PM on 9-29-2008
open
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).
joe said 2:42AM on 10-01-2008
#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'
Reply
carlo said 8:44AM on 10-04-2008
There's also the Bash cd alias: cdots (which uses TAB completion).
(See the links on http://codesnippets.joyent.com/posts/show/1690 )
Reply