Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › Command Line

Linux Commands: 60 Essential Utilities With Syntax and Safe Examples

By Freedom251 Team · · 10 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

These 60 Linux commands cover navigation, file management, text processing, searching, permissions, storage, archives, networking-by-transfer, and process control. The examples follow GNU Coreutils 9.11 conventions where applicable. Start with read-only commands, quote paths that contain spaces, and inspect a command’s help before using options that delete data, change ownership, write disks, or signal processes.

Before running commands

Use man COMMAND for the full local manual and COMMAND --help for a concise option list. A vertical bar (|) sends one command’s output to another. > overwrites a file, while >> appends; 2> redirects standard error. && runs the next command only when the previous command succeeds. The shell expands * to matching names and ? to one character, so quote patterns when you want a command to receive them literally.

As an Amazon Associate I earn from qualifying purchases.

cd, history, alias, export, source, jobs, fg, bg, and help are shell-dependent builtins, not part of the 60 standalone utilities below. Options and availability can differ between GNU/Linux, BSD, BusyBox, and other systems.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Navigate and identify files

pwd — show your current directory

Syntax: pwd [OPTION]. Example: pwd. It prints the absolute path of the shell’s working directory. Use it before a relative path when you are unsure where a command will act.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

ls — list directory contents

Syntax: ls [OPTION]... [FILE].... Example: ls -lah /var/log. -l shows metadata, -a includes dotfiles, and -h uses readable units. Listing is read-only, but remember that a trailing slash and shell glob can select different paths.

cd — change directory

Syntax: cd [DIR]. Example: cd ~/Documents. It is a shell builtin, so behavior and options depend on your shell. cd - returns to the previous directory; cd alone goes to your home directory.

tree — display a directory tree

Syntax: tree [OPTION] [DIR]. Example: tree -L 2 project/. -L 2 limits output to two levels. Install it separately if your distribution does not provide it; it only reads directory contents.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

mkdir — create directories

Syntax: mkdir [OPTION]... DIRECTORY.... Example: mkdir -p project/src. -p creates missing parents and does not complain when they already exist. Creating a directory changes the filesystem but does not remove existing data.

rmdir — remove empty directories

Syntax: rmdir [OPTION]... DIRECTORY.... Example: rmdir old-empty-dir. It refuses non-empty directories, making it safer for beginners than recursive removal.

touch — create a file or update timestamps

Syntax: touch [OPTION]... FILE.... Example: touch notes.txt. If the file exists, its access and modification times are updated; otherwise an empty file is created.

file — identify file type

Syntax: file [OPTION]... FILE.... Example: file archive.tar.gz. It examines content and metadata rather than trusting a filename extension.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

stat — show detailed status

Syntax: stat [OPTION]... FILE.... Example: stat report.pdf. Output includes size, inode, permissions, ownership, and timestamps; it is useful for diagnosing unexpected file changes.

readlink — print a symbolic-link target

Syntax: readlink [OPTION]... FILE.... Example: readlink -f current. -f resolves the complete canonical path, following links and existing components. A broken link may not resolve.

Copy, move, link, and delete

cp — copy files or directories

Syntax: cp [OPTION]... SOURCE... DIRECTORY. Example: cp -r config/ config.backup/. -r recurses into directories. Confirm the destination before using recursive copies, and consider -i to ask before overwriting.

mv — move or rename

Syntax: mv [OPTION]... SOURCE... DEST. Example: mv draft.txt final.txt. Within one filesystem this usually changes directory entries rather than copying data. Use -i for overwrite prompts; moving to an existing destination can replace it.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

rm — remove files or directories

Syntax: rm [OPTION]... FILE.... Example: rm -- report.tmp. -- ends options so a filename beginning with a hyphen is treated as a name. rm -r descends into directories and rm -f suppresses prompts; rm -rf is high risk and can irreversibly delete large trees.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

ln — create links

Syntax: ln [OPTION]... TARGET LINK_NAME. Example: ln -s /opt/app/current app-current. -s creates a symbolic link; without it, ln creates a hard link when allowed. Relative symlink targets are interpreted relative to the link’s directory.

install — copy and set attributes

Syntax: install [OPTION]... SOURCE DEST. Example: install -m 755 script.sh ~/bin/script.sh. -m 755 sets executable permissions while copying, commonly for deployment scripts.

shred — overwrite before removal

Syntax: shred [OPTION]... FILE.... Example: shred -u temporary-secret.txt. -u removes the file after overwriting. It is high risk and cannot guarantee secure erasure on journaling filesystems, SSDs, snapshots, or copied data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

truncate — change a file’s length

Syntax: truncate OPTION... FILE.... Example: truncate -s 0 app.log. Setting size to zero discards the file’s contents while keeping the inode; extending a file creates sparse or zero-filled space depending on the filesystem.

unlink — remove one named file

Syntax: unlink FILE. Example: unlink old-link. It removes exactly one directory entry and does not accept recursive options, but deletion is still irreversible without a backup.

Read, transform, and combine text

cat — print or concatenate files

Syntax: cat [OPTION]... [FILE].... Example: cat README.md. Multiple files are emitted in order. Avoid using it for huge files when less is more suitable.

tac — print lines in reverse order

Syntax: tac [OPTION]... [FILE].... Example: tac events.log. It reverses line order, useful for seeing the newest line first in a log.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

less — page through text

Syntax: less [OPTION] FILE. Example: less /var/log/syslog. Search with /pattern, press n for the next match, and press q to quit. It reads without modifying the file.

head — show the beginning

Syntax: head [OPTION]... [FILE].... Example: head -n 20 data.csv. -n 20 prints the first 20 lines, useful for checking a file’s format before processing it.

tail — show the end or follow a file

Syntax: tail [OPTION]... [FILE].... Example: tail -f app.log. -f keeps reading as new lines arrive; press Ctrl+C to stop following.

wc — count lines, words, and bytes

Syntax: wc [OPTION]... [FILE].... Example: wc -l access.log. -l counts newline characters (normally lines); -w and -c count words and bytes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

nl — number lines

Syntax: nl [OPTION]... [FILE].... Example: nl -ba script.sh. -ba numbers blank as well as nonblank lines, useful when discussing exact script locations.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

cut — extract fields or character ranges

Syntax: cut OPTION... [FILE].... Example: cut -d, -f1 users.csv. -d, sets a comma delimiter and -f1 selects the first field. This is not a full CSV parser for quoted commas.

paste — merge corresponding lines

Syntax: paste [OPTION]... [FILE].... Example: paste names.txt emails.txt. It places lines side by side, separated by tabs by default.

sort — order lines

Syntax: sort [OPTION]... [FILE].... Example: sort -n scores.txt. -n compares numeric values rather than text order. Use -f for case-insensitive sorting or -r to reverse it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

uniq — collapse adjacent duplicates

Syntax: uniq [OPTION]... [INPUT [OUTPUT]]. Example: sort names.txt | uniq -c. -c prefixes counts. Because duplicates must be adjacent, sort first when you want a complete frequency count.

tr — translate or delete characters

Syntax: tr [OPTION]... SET1 [SET2]. Example: tr '[:lower:]' '[:upper:]' < title.txt. Character classes provide locale-aware sets; quote them so the shell does not reinterpret punctuation.

sed — transform a text stream

Syntax: sed [OPTION]... {script}. Example: sed 's/old/new/g' file.txt. The substitution replaces every old match on each line in the output stream; without -i, the original file is unchanged.

awk — process fields and records

Syntax: awk 'PROGRAM' [FILE].... Example: awk -F, '{print $1}' users.csv. -F, sets the field separator. Awk treats whitespace, delimiters, and records according to its program, so validate input assumptions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

echo — print text

Syntax: echo [OPTION]... [STRING].... Example: echo "$HOME". Variable expansion occurs inside double quotes. For predictable escape handling and formatting, prefer printf.

printf — print formatted text

Syntax: printf FORMAT [ARGUMENT].... Example: printf '%sn' "$USER". The format controls newlines and interpretation, making it safer than relying on implementation-specific echo behavior.

tee — duplicate input to screen and files

Syntax: tee [OPTION]... [FILE].... Example: make 2>&1 | tee build.log. -a appends instead of overwriting. Writing to protected locations may require sudo on the tee side of a pipeline.

Search files, commands, and text

grep — search text patterns

Syntax: grep [OPTION]... PATTERNS [FILE].... Example: grep -Rni 'timeout' config/. -R recurses, -n shows line numbers, and -i ignores case. Quote regular expressions and patterns that contain shell metacharacters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

find — search directory trees

Syntax: find [PATH]... [EXPRESSION]. Example: find . -type f -name '*.log'. Tests such as -type and -name select entries; actions such as -delete mutate them. Put the starting path and expression exactly where intended.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

xargs — build commands from input

Syntax: xargs [OPTION] [COMMAND [INITIAL-ARGS]]. Example: find . -name '*.tmp' -print0 | xargs -0 rm --. The null-delimited pair -print0/-0 handles spaces and newlines safely, but this example still deletes files; review the find results first.

which — show a command path

Syntax: which [OPTION]... COMMAND.... Example: which python3. It reports a path found through the shell’s command search, where supported. Shell builtins and aliases may not appear as ordinary executable files.

whereis — locate binaries, sources, and manuals

Syntax: whereis [OPTION]... FILE.... Example: whereis bash. It searches standard locations for related executable, source, and manual paths.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

locate — search a filename database

Syntax: locate [OPTION]... PATTERN.... Example: locate ssh_config. Results come from a prebuilt database, so a recently created or removed file may not appear until the database is updated. It may not be installed by default.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Permissions, ownership, and identity

chmod — change access permissions

Syntax: chmod [OPTION]... MODE FILE.... Example: chmod 640 secrets.txt. Numeric mode gives owner read/write, group read, and no permissions to others. Recursive -R changes an entire tree and is high risk; verify the path first.

chown — change owner and group

Syntax: chown [OPTION]... [OWNER][:[GROUP]] FILE.... Example: sudo chown -R app:app /srv/app. -R recurses and often requires elevation. Symlink handling and whether the link or target is changed depend on options and platform, so read the local manual before applying it broadly.

chgrp — change group ownership

Syntax: chgrp [OPTION]... GROUP FILE.... Example: chgrp developers shared.txt. You generally need to own the file and belong to the target group, or use appropriate privileges. Recursive changes can affect access for many users.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

umask — set the default permission mask

Syntax: umask [-p] [-S] [mode]. Example: umask 027. It subtracts permissions from newly created files and directories; it does not change existing objects. As a shell setting, its persistence depends on where your shell startup files define it.

id — show numeric identity and groups

Syntax: id [OPTION]... [USER]. Example: id alice. Output includes user ID, primary group, and supplementary groups, which helps diagnose permission failures.

whoami — print the effective username

Syntax: whoami. Example: whoami. Check it after switching users or using privilege tools so you know which account a command will affect.

who — list logged-in users

Syntax: who [OPTION]... [FILE|ARG1 ARG2]. Example: who. It reports sessions and terminals from the system’s user-accounting data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

groups — display group memberships

Syntax: groups [OPTION]... [USERNAME].... Example: groups "$USER". Use it to check whether your account belongs to a group that grants access to a file, device, or service.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

sudo — run a command with elevated privileges

Syntax: sudo [OPTION] COMMAND. Example: sudo systemctl restart nginx. It runs only when your account is configured in the system’s privilege policy. Read the complete command before authenticating; elevation does not make a destructive command reversible.

Storage, archives, and raw data

df — report free filesystem space

Syntax: df [OPTION]... [FILE].... Example: df -h /. -h uses readable units. Check the filesystem containing a path, because another mount may have a different capacity.

du — estimate file and directory usage

Syntax: du [OPTION]... [FILE].... Example: du -sh ~/Downloads. -s summarizes and -h formats units. It measures directory contents, which can differ from allocated space shown by df.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

tar — create or extract archives

Syntax: tar [OPTION]... [FILE].... Example: tar -czf backup.tgz project/. -c creates, -z uses gzip compression, and -f names the archive. Before extraction, list contents with tar -tzf backup.tgz; archives can contain absolute or traversal paths.

gzip — compress or decompress gzip data

Syntax: gzip [OPTION]... [FILE].... Example: gzip -k large.log. -k keeps the original while creating the compressed file. Without it, gzip normally replaces the input with a .gz file.

zip — create ZIP archives

Syntax: zip [OPTION]... ZIPFILE FILE.... Example: zip -r site.zip public/. -r includes a directory tree. The utility may need separate installation on a minimal system.

unzip — extract ZIP archives

Syntax: unzip [OPTION] archive.zip. Example: unzip site.zip -d site/. -d chooses the destination directory. Inspect untrusted archives first and avoid extracting over sensitive locations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

dd — copy and convert raw data

Syntax: dd [OPERAND].... Example: dd if=/dev/zero of=test.img bs=1M count=100. This creates a 100 MiB test image from zeros. if is input, of output, bs block size, and count the number of blocks. A wrong of, especially a disk device, can destroy data; verify every operand and use a noncritical path for practice.

Processes, jobs, and execution

ps — report running processes

Syntax: ps [OPTION].... Example: ps aux | grep '[n]ginx'. The bracket trick prevents grep from matching its own command line. Output commonly includes process ID, CPU, memory, owner, and command.

top — display a live process view

Syntax: top [OPTION]. Example: top. It refreshes CPU, memory, load, and process information interactively. Press q to quit; availability and interactive keys can vary.

kill — send a signal to a process

Syntax: kill [OPTION]... PID.... Example: kill -TERM 1234. -TERM requests a graceful stop, allowing cleanup. Confirm the PID with ps first; -KILL is a last resort because it cannot be caught or handled, and signaling the wrong process can interrupt critical services.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A beginner-safe operating checklist

  • Run pwd, then inspect targets with ls -la, find, or stat before changing anything.
  • Quote variables and paths: rm -- "$file" protects spaces and names beginning with a hyphen.
  • Prefer rmdir over recursive removal, cp -i/mv -i before overwrites, and a dry listing before archive extraction.
  • Treat recursive chmod/chown, rm -rf, shred, dd, and kill as high-risk operations.
  • Use sudo only for the specific command that needs it, and re-check ownership and permissions afterward with id, stat, or ls -l.
  • Remember that pipelines can hide failures unless you inspect each stage or enable your shell’s pipeline-error option; redirecting output can overwrite files immediately.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Command LineGNU CoreutilsLinuxLinux commandsLinux tutorialShell

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.