16 Terminal commands every user should know

Jesus Vigo curates a list of entry-level operational commands aimed at understanding and using Terminal.

Image: Apple

Terminal, or the command line interface (CLI), is considered by many to be the Holy Grail of computer management. At one time the CLI was the only way to accomplish anything on a computer; then, the CLI gave way to the graphical user interface (GUI) as the popularity of PCs increased. The purists among us often prefer to use the CLI as a means of manipulating the computer and getting it to perform tasks instead of using a mouse to get things done.

So who's right?

There's no right or wrong per se — only convenience. As the GUI has changed the way we work, many people still use the command line for its ability to control nodes, automate tasks, and even configure features that are only accessible through the CLI.

I try to learn as much about the CLI for any particular OS I manage in an effort to work smarter, not harder and also to learn multiple ways of accomplishing the same tasks. After all, the more you know, the better you'll be at your job. With this in mind, I present these basic Terminal commands to introduce some of the Terminal's features and to provide a working understanding of the app.

SEE: 20 Terminal shortcuts developers need to know

1. Change Directory

Command: cd

What it does: Changes the directory of the command line path.

Example: cd "path/to/directory/" (Figure A)

Figure A

Image: Jesus Vigo/TechRepublic

2. Listing Directory

Command: ls

What it does: Lists the contents of a directory.

Example: ls "path/to/directory/" (Figure B)

Figure B

Image: Jesus Vigo/TechRepublic

3. Open files

Command: open

What it does: Opens a file.

Example: open "filename" (Figure C)

Figure C

Image: Jesus Vigo/TechRepublic

4. Copy a file to another directory

Command: cp

Example: cp "filename" "newfilename" (Figure D)

Figure D

Image: Jesus Vigo/TechRepublic

5. Move a file

Command: mv

Example: mv "filename" "path/to/new/file/location" (Figure E)

Figure E

Image: Jesus Vigo/TechRepublic

6. Renaming a file

Command: mv

Example: mv "path/to/filename" "path/to/newfilename" (Figure F)

Figure F

Image: Jesus Vigo/TechRepublic

7. Create a directory

Command: mkdir

Example: mkdir "path/to/new/directory" (Figure G)

Figure G

Image: Jesus Vigo/TechRepublic

8. Remove an empty directory

Command: rmdir

Example: rmdir "path/to/directory" (Figure H)

Figure H

Image: Jesus Vigo/TechRepublic

9. Remove nested directories

Command: rm -R

Example: rm -R "/path/to/root/directory" (Figure I)

Figure I

Image: Jesus Vigo/TechRepublic

10. Execute commands with superuser privileges

Command: sudo

Example: sudo "command" (Figure J)

Figure J

Image: Jesus Vigo/TechRepublic

11. List actively running computer processes

Command: top

Example: top (Figure K)

Figure K

Image: Jesus Vigo/TechRepublic

12. Quit sub-screen and return to Terminal

Command: q

Example: After executing a command, such as "top" to view active processes, press "q" to exit. (Figure L)

Figure L

Image: Jesus Vigo/TechRepublic

13. Clear the Terminal screen of all previous commands

Command: Clear

Example: clear (Figure M)

Figure M

Image: Jesus Vigo/TechRepublic

14. Get help for a command

Command: help

Example: help "command" (Figure N)

Figure N

Image: Jesus Vigo/TechRepublic

15. Get one-line description for a command

Command: whatis

Example: whatis "command" (Figure O)

Figure O

Image: Jesus Vigo/TechRepublic

16. Show manual page for a command

Command: man

Example: man "command" (Figure P)

Figure P

Image: Jesus Vigo/TechRepublic

The "exit" command

A special note goes out to the "exit" command, which closes the Terminal session.

Command: exit

Example: exit (Figure Q)

Figure Q

Image: Jesus Vigo/TechRepublic

What are your go-to Terminal commands?

While this article is more focused at those new to OS X or perhaps coming from another OS such as Windows, I hope that even experienced users will be able to reinforce their knowledge base.

What Terminal commands do you use most often? What Terminal commands would you add to this list? We'd love to hear from you!

Also see


Jesus Vigo is a Network Administrator by day and owner of Mac|Jesus, LLC, specializing in Mac and Windows integration and providing solutions to small- and medium-size businesses. He brings 15 years of experience and multiple certifications from seve...

Editor's Picks