keepcalculator

06 Numbers and Powers

Most Used Terminal Commands: The Essential List

Card No. 06·48032 · Updated · Standard formula, shown below

The most used terminal commands are ls, cd, pwd, cat, cp, mv, rm, mkdir, grep, and man. These ten form the core of daily work in any Unix-like shell (Linux, macOS, WSL) because they cover navigation, file inspection, file manipulation, and searching—the four tasks that make up the vast majority of command-line activity.

Why These Commands Dominate

The terminal is a text interface to your computer’s file system. Unlike a graphical file manager, it doesn’t show you icons; it shows you text. So the commands you use most are the ones that answer the most basic questions: Where am I? (pwd), What’s here? (ls), How do I get somewhere else? (cd), and What’s in this file? (cat). Once you can move around and look at things, you need to change things: copy (cp), move or rename (mv), delete (rm), and make new folders (mkdir). Searching within files (grep) and reading the manual (man) round out the essentials because they let you find information and learn new commands without leaving the terminal.

Navigation and Inspection

  • pwd – Prints the current working directory. It’s the first thing you run when you open a terminal and forget where you are.
  • ls – Lists files and directories. The most common variations are ls -l (long format with permissions, size, date) and ls -a (shows hidden files starting with a dot). Combine them: ls -la.
  • cd – Changes directory. cd .. goes up one level, cd ~ goes to your home directory, and cd - goes to the last directory you were in.

These three are the foundation. Without them, you’re lost. In fact, many terminal users run pwd and ls dozens of times per session without thinking about it.

File Operations: Copy, Move, Delete, Create

  • mkdir – Makes a new directory. Use mkdir -p to create nested directories in one go, e.g., mkdir -p projects/2024/reports.
  • cp – Copies files or directories. cp file1.txt backup.txt copies a file; cp -r folder/ backup_folder/ copies a directory recursively.
  • mv – Moves or renames. mv old.txt new.txt renames; mv file.txt /tmp/ moves. It’s the same command for both because renaming is just moving within the same directory.
  • rm – Deletes files or directories. rm file.txt deletes a file; rm -r folder/ deletes a directory and everything inside. Be careful: there is no trash can in the terminal. Once deleted, it’s gone.

These four commands are how you manage your filesystem from the command line. They are powerful and irreversible—especially rm—so always double-check the path before pressing Enter.

Viewing and Searching File Contents

  • cat – Prints the entire contents of a file to the screen. Good for short files. For longer files, use less (scrollable) or head/tail (first/last 10 lines).
  • grep – Searches for text within files. The most common use is grep "error" log.txt to find lines containing “error”. Add -i for case-insensitive, -r for recursive search in a directory, and -n to show line numbers.

These two are the workhorses of debugging and log analysis. If you’re a developer, grep will likely be your most-used command after ls and cd.

Getting Help: The man Command

The man command opens the manual page for any command. For example, man ls shows every option for ls. This is the single most important command to learn because it lets you discover all the other commands. When you’re stuck, man is your offline documentation. Many users also use --help (e.g., ls --help) for a quick summary, but man is more detailed.

Common Mistakes and How to Avoid Them

  • Deleting the wrong file – rm is permanent. Always use ls first to confirm the path, and consider using rm -i (interactive) which asks for confirmation.
  • Spaces in filenames – If a file name has spaces, you must quote it or escape the space: cd "My Documents" or cd My\ Documents.
  • Using cat on large files – cat dumps everything to the screen, which can flood your terminal. Use less instead for files longer than a screen.
  • Forgetting -r for directories – cp and rm fail without -r when dealing with directories. It’s a common error that produces confusing “omitting directory” messages.

How to Choose Which Commands to Learn Next

Once you master the ten above, the next set depends on your work. If you’re a developer, learn git commands (git status, git add, git commit, git push). If you’re a system administrator, learn ps (process list), kill, top or htop, and chmod. If you work with text files, learn sed and awk for stream editing and text processing. The key is to learn commands that solve real problems you’re facing, not to memorize a list.

Frequently Asked Questions

What is the difference between cp and mv?

cp creates a copy of a file, leaving the original in place. mv moves the file to a new location, removing the original. Think of cp as “duplicate” and mv as “cut and paste”.

How do I undo a rm command?

You can’t. There is no built-in undo for rm in most shells. That’s why it’s critical to use ls before deleting and to consider aliasing rm to rm -i or using a trash-cli tool that moves files to a recycle bin instead of deleting them permanently.

What does ls -la actually show?

It shows a long listing (-l) of all files including hidden ones (-a). The output includes file permissions, number of links, owner, group, size, last modification date, and the name. The first character of the permissions column indicates the type: - for a file, d for a directory, l for a symbolic link.

Why do I get “command not found”?

That error means the shell can’t find an executable with that name in your PATH. It could be a typo, the command isn’t installed, or it’s not in your PATH. Use which command to see if it exists and where it is. If it’s not installed, you may need to install it with your package manager (e.g., apt install on Debian/Ubuntu, brew install on macOS).

Is the terminal the same as the shell?

No. The terminal is the window that displays text and accepts input. The shell is the program that interprets your commands. Common shells are Bash, Zsh, and Fish. The commands you type are the same regardless of the shell, but the shell controls things like prompt appearance and scripting syntax.

How do I learn more commands quickly?

Use man for any command you want to explore. Also, many systems have a built-in tutorial: type help for a list of built-in shell commands, or search online for “Linux command cheat sheet”. Practice by using the terminal for everyday tasks instead of the file manager—you’ll naturally memorize the commands you use most.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →