Skip to Content

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.

Categories

Terminal Tips

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

*0 / 3000 Character Maximum

14 Comments

Filter by:
carlo

There's also the Bash cd alias: cdots (which uses TAB completion).

(See the links on http://codesnippets.joyent.com/posts/show/1690 )

October 04 2008 at 8:42 AM Report abuse rate up rate down Reply
joe

#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'

October 01 2008 at 2:41 AM Report abuse rate up rate down Reply
np0x

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.

September 29 2008 at 8:06 PM Report abuse rate up rate down Reply
2 replies to np0x's comment
np0x

hrm, maybe I missed it..(# 6 above).

September 29 2008 at 8:08 PM Report abuse rate up rate down Reply
aamartin

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).

September 29 2008 at 11:46 PM Report abuse rate up rate down Reply
Gordon Werner

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

September 29 2008 at 7:57 PM Report abuse rate up rate down Reply
UnusualAspect

Whoa! All change... I typed that last post - old style... Now New Style TUAW!
I like it guys, well done

September 29 2008 at 5:57 PM Report abuse rate up rate down Reply
UnusualAspect

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"

September 29 2008 at 5:37 PM Report abuse rate up rate down Reply
Paul E. Ester

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 rate up rate down Reply
CaptSaltyJack

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.

September 29 2008 at 4:04 PM Report abuse rate up rate down Reply
Scott Lembcke

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 rate up rate down Reply
Gianni

I think a better/quicker alternative to #5 is simply ⌘K, which clears the scrollback.

September 29 2008 at 4:00 PM Report abuse rate up rate down Reply
Buy an ad here

Hot Apps on TUAW

Tweets

© 2012 AOL Inc. All Rights Reserved.