16 Essential Commands Every Developer Should Know

16 Essential Commands Every Developer Should Know
Table of Contents
ls
Lists the contents of a directory.
-
Syntax:
ls [options] [path] -
Common Options:
-l— long format (detailed list)-a— include hidden files (.prefix)-h— human‑readable sizes (with-l)
-
Example:
# List everything, including hidden files, in long format ls -lah
cd
Changes your current directory.
-
Syntax:
cd [directory] -
Quick Tips:
cdalone takes you to your home folder.cd -jumps back to the previous directory.
-
Example:
# Move into the “projects” folder inside your home cd ~/projects
pwd
Prints the full path of your current working directory.
-
Syntax:
pwd -
Example:
# Show where you are in the filesystem $ pwd /home/dhruvdankhara/projects
mkdir
Creates new directories.
-
Syntax:
mkdir [options] directory_name -
Common Options:
-p— create parent directories as needed
-
Example:
# Create a nested path in one go mkdir -p ~/projects/blog/images
touch
Creates an empty file or updates a file’s “last modified” timestamp.
-
Syntax:
touch [options] file_name -
Example:
# Create a new file or update timestamp touch todo.txt
rm
Removes (deletes) files.
-
Syntax:
rm [options] file_name -
Common Options:
-i— prompt before each removal
-
Example:
# Ask before deleting each file rm -i old_log.txt
rm -r
Recursively removes directories and their contents.
-
Syntax:
rm -r [options] directory_name -
Common Options:
-f— force removal without prompts
-
Example:
# Force‑delete a folder and everything inside it rm -rf /tmp/my_temp_folder
cp
Copies files or directories.
-
Syntax:
cp [options] source destination -
Common Options:
-r— recursive (for directories)-i— prompt before overwrite
-
Example:
# Copy entire “assets” folder to “backup_assets” cp -r assets backup_assets
mv
Moves or renames files and directories.
-
Syntax:
mv [options] source destination -
Common Options:
-i— prompt before overwrite
-
Example:
# Rename file or move to another folder mv draft.txt published/draft.txt
cat
Displays the contents of a file.
-
Syntax:
cat [options] file_name -
Common Options:
-n— number all output lines
-
Example:
# Show file with line numbers cat -n script.sh
cat >
Redirects your input into a file (overwriting existing content).
-
Syntax:
cat > file_name -
How It Works:
- Run
cat > notes.txt. - Type your text.
- Press
Ctrl + Dto save and exit.
- Run
-
Example:
$ cat > README.md # My Project This is a quick summary. (Ctrl+D)
nano
A simple command-line text editor.
-
Syntax:
nano [options] file_name -
Basic Shortcuts (at bottom of editor):
Ctrl + O— save file (Write Out)Ctrl + X— exit nanoCtrl + K— cut line
-
Example:
# Open or create “config.env” nano config.env
ping
Checks connectivity to a host by sending ICMP echo requests.
-
Syntax:
ping [options] host -
Common Options:
-c <count>— send only<count>pings
-
Example:
# Ping google.com 4 times ping -c 4 google.com
curl
Transfers data from or to a server.
-
Syntax:
curl [options] URL -
Common Options:
-O— save to a file named like the remote file-I— fetch only HTTP headers
-
Example:
# Download image.jpg and save it locally curl -O https://example.com/image.jpg
wget
Non‑interactive network downloader.
-
Syntax:
wget [options] URL -
Common Options:
-c— continue partial downloads-q— quiet (no output)
-
Example:
# Continue downloading a large file if interrupted wget -c https://example.com/bigfile.zip
clear
Clears the terminal screen.
-
Syntax:
clear -
Tip:
- Use
Ctrl + Las a shortcut in most terminals.
- Use
-
Example:
# Wipe the slate clean clear