The terminal command prompt allows you to interact with your computer's operating system using text-based commands instead of a graphical user interface (GUI). By typing specific instructions, you can move files, manage directories, and execute system tasks faster than clicking through folders. To get started, you simply need to open your system's command-line application—such as Terminal on macOS and Linux or Command Prompt/PowerShell on Windows.
What You'll Need
- A computer running Windows, macOS, or a Linux distribution.
- Basic administrative permissions (some commands require "Administrator" or "Sudo" access to function).
- A keyboard (mouse usage is minimal in the terminal).
Step-by-Step
- Open the Terminal Application
- Windows: Press the Windows key, type "cmd" or "PowerShell," and press Enter.
- macOS: Press Command + Space, type "Terminal," and press Enter.
- Linux: Press Ctrl + Alt + T (on most distributions).
- Identify Your Current Location
The terminal always operates within a specific folder (directory). To see where you are:
- On macOS/Linux, type
pwd(print working directory) and press Enter. - On Windows, the current path is usually displayed to the left of the blinking cursor.
- On macOS/Linux, type
- List Files and Folders
To see what is inside your current folder:
- On macOS/Linux, type
lsand press Enter. - On Windows, type
dirand press Enter.
- On macOS/Linux, type
- Change Directories (Navigate)
To move into a specific folder, use the
cd(change directory) command followed by the folder name:- Example:
cd Documentswill move you into the Documents folder. - To go back up one level (to the parent folder), type
cd ..and press Enter.
- Example:
- Create a New Folder
To create a directory without using a mouse:
- Type
mkdir FolderName(replace "FolderName" with your desired name) and press Enter.
- Type
- Create a Blank File
- On macOS/Linux, type
touch filename.txtand press Enter. - On Windows, type
type nul > filename.txtand press Enter.
- On macOS/Linux, type
- Delete a File
Warning: Files deleted via the terminal usually bypass the Recycle Bin or Trash and cannot be easily recovered.
- On macOS/Linux, type
rm filename.txtand press Enter. - On Windows, type
del filename.txtand press Enter.
- On macOS/Linux, type
- Clear the Screen
When the window becomes cluttered with old commands:
- Type
clear(macOS/Linux) orcls(Windows) and press Enter.
- Type
Common Mistakes
- Case Sensitivity: On macOS and Linux,
Documentsanddocumentsare different folders. Windows is generally case-insensitive, but it is good practice to match the casing exactly. - Spaces in File Names: If a folder is named "My Projects," typing
cd My Projectswill fail because the terminal thinks "Projects" is a separate command. Use quotation marks:cd "My Projects". - Forgetting the Space: Commands must be separated from their arguments by a space. Typing
cdDocumentsinstead ofcd Documentswill result in a "command not found" error. - Running Dangerous Commands: Never copy and paste a command from the internet (especially those starting with
sudo rm -rf) if you do not understand exactly what it does, as it can erase your entire hard drive.
Tips
- Use Tab Completion: You don't have to type full folder names. Type the first few letters and press the Tab key; the terminal will automatically complete the name for you.
- Command History: Use the Up and Down arrow keys on your keyboard to cycle through commands you have previously entered.
- Stop a Runaway Process: If a command is taking too long or seems frozen, press
Ctrl + Cto force the process to stop and return to the prompt. - Use Manuals: On macOS/Linux, if you aren't sure how a command works, type
manfollowed by the command (e.g.,man ls) to read the official manual.
Troubleshooting
- "Permission Denied" Error: This means your user account doesn't have the right to modify that file or folder. On macOS/Linux, you can prefix the command with
sudo(e.g.,sudo mkdir FolderName) and enter your password. On Windows, right-click the Command Prompt icon and select "Run as Administrator." - "Command Not Found": Check your spelling. Ensure there is a space between the command and the folder/file name. If the command is correct but still fails, the software associated with that command may not be installed or added to your system's "PATH" environment variable.
- Stuck in a Loop: If the terminal is printing text endlessly and won't let you type, press
Ctrl + Cto kill the current task. - Cannot Find a Folder: If
cdisn't working, typelsordirto verify the folder actually exists in your current location. You may need to move back a few levels usingcd ..first.
Frequently Asked Questions
Is the terminal the same as the Command Prompt?
Generally, yes. "Terminal" is the broad term for the interface, while "Command Prompt" and "PowerShell" are specific applications used on Windows, and "Zsh" or "Bash" are common shells used on macOS and Linux.
Can I accidentally delete my entire operating system?
While it is possible if you use administrative privileges (like sudo or Administrator mode) and a destructive command (like rm -rf /), the system usually has built-in protections to prevent this. However, you should always be cautious with deletion commands.
Why do some people prefer the terminal over the mouse?
The terminal is often faster for repetitive tasks, allows for automation via scripting, and provides access to powerful developer tools that do not have a graphical interface.
Does the terminal work the same on all computers?
No. Windows uses a different set of core commands (CMD/PowerShell) than macOS and Linux (Unix-based). While some commands like cd and mkdir are the same, many others differ.
How do I exit the terminal?
You can simply close the window with your mouse, or type exit and press Enter to close the session properly.