Terminal Shortcut Practice

How to use
STARTSTOP
*Toggle input mode: ctrl + shift + alt + space
PRE
NEXT
Exclude this question from the list
Restore excluded questions
Get a URL for the current exclusions
https://command-lab.com
Copy
Guide mode
Repeat mode

*Recommended browser: Google Chrome

PUSH ENTER
If you enjoy this site, please share it — it keeps us motivated to keep improving!

Terminal Commands: Full List (17 commands)

Every Terminal command used in the practice above, listed in full, with a short explanation of what each one does. Find one you want to learn, then type it out in the practice above until your fingers remember it.

Create file

Terminal — Create file
Action Command What it does
Create an empty file with the name "index.txt" touch index.txt Enter Creates a new empty file with the given name. If a file with that name already exists, it only updates the timestamp without changing the contents. Useful when you want to prepare a file — such as an HTML file — before writing anything into it.
Create an empty file called "style.css" touch style.css Enter Creates a new empty file with the given name. Use it after moving into the css directory, to set up an empty style.css stylesheet file there.
Create an empty file with the name "script.js". touch script.js Enter Creates a new empty file with the given name. Use it when you want to first prepare an empty script.js file before you start writing JavaScript.

Show file contents

Terminal — Show file contents
Action Command What it does
Display the contents of the file "command_lab.txt" cat command_lab.txt Enter Displays the contents of the specified file directly in the terminal. Use it to quickly check what's inside a text file without opening an editor. Note that long files will scroll past the visible screen.

Create directory

Terminal — Create directory
Action Command What it does
Create a directory "css" mkdir css Enter Creates a new directory (folder) with the given name. Use it when you want to organize files by type — such as CSS or JS files — by first setting up a container folder for them.
Create a directory called "js" mkdir js Enter Creates a new directory with the given name. Use it to set up a dedicated js folder when you want to keep JavaScript files separate from CSS files.

Change directory

Terminal — Change directory
Action Command What it does
Move to the "css" directory cd css Enter Moves into the specified directory, switching the location (current directory) where subsequent commands are executed. Use it to move into the css folder you just created, for example, when you want to keep working inside it.
Move up one level cd .. Enter Moves up one level from the current directory to its parent directory. The ".." represents the parent directory, and this is commonly used to move back after navigating deep into a folder structure.

Show path

Terminal — Show path
Action Command What it does
Display the path of the current directory (current directory) pwd Enter Displays the absolute path of the directory you're currently working in. Use it to check where you are after moving around repeatedly with cd and losing track of your current location.

List directory contents

Terminal — List directory contents
Action Command What it does
Check the contents of the current directory l s Enter Lists the files and folders contained in the current directory. It's run frequently between operations to confirm a file exists, or that it was created or moved to the intended location.

Clear terminal

Terminal — Clear terminal
Action Command What it does
Clear the terminal screen clear Enter Clears everything displayed on the terminal screen, giving you a blank slate. Use it when accumulated command output makes the screen hard to read, so you can reset the view.

Rename file

Terminal — Rename file
Action Command What it does
Change "index.txt" to the file name "index.html". mv index.txt index.html Enter Renames a file using the move command, with the syntax "mv old-name new-name" — here changing index.txt to index.html. This is the standard way to rename a file, such as when changing its extension.
Make a copy of "command_lab.txt" with the filename "practice.txt" cp command_lab.txt practice.txt Enter Creates a copy of the specified file under a different name using the copy command, with the syntax "cp source destination." The original file remains untouched — useful when you want a separate practice copy.

Move file

Terminal — Move file
Action Command What it does
Move "script.js" to "js" directory mv script.js js Enter Moves a file to another directory using the move command, with the syntax "mv file target-directory" — here moving script.js into the js folder. Use it when you want to reorganize where a file lives without changing its name.

Copy directory

Terminal — Copy directory
Action Command What it does
Copy the "css" directory with the name "css2" cp -r css css2 Enter Copies an entire directory, contents included, by adding the -r option to the copy command. Directories can't be copied without this option, so -r is used when you want to back up a whole folder or reuse it as a template.

Delete file

Terminal — Delete file
Action Command What it does
Delete "command_lab.txt" rm command_lab.txt Enter Deletes the specified file. It's removed immediately without going through a trash bin, so this can't be undone — be careful. Use it to clean up files you no longer need.

Delete directory

Terminal — Delete directory
Action Command What it does
Delete the "css2" directory rmdir css2 Enter Deletes the specified empty directory. rmdir can only remove directories that are empty, so it will error out if files remain inside. Use it to tidy up empty folders you no longer need.
Back to top