Basic Linux Commands

9/14/2023 Updated: Finished initial version of the linux cheatsheet.

Directory and Navigation

  • pwd (Print Working Directory): Displays the current directory’s full path.
  • ls (List): Lists files and directories in the current directory.
  • cd (Change Directory): Used to change the current working directory.
  • mkdir (Make Directory): Creates a new directory.
  • rmdir (Remove Directory): Deletes an empty directory.

File Operations

  • touch: Creates an empty file.
  • cp (Copy): Copies files or directories.
  • mv (Move): Moves files or directories, also used for renaming.
  • rm (Remove): Deletes files or directories.

File modifying

  • nano: A simple text editor for the terminal.
  • vim: A powerful and extensible text editor.
  • sed (Stream Editor): Edits text using scripts.
  • awk: A versatile text processing tool for data extraction and manipulation.

File display

  • cat (Concatenate): Displays or combines the content of files.
  • grep (Global Regular Expression Print): Searches for text within files.
  • find: Searches for files and directories.
  • more and less: Display the content of a file one page at a time.
  • head and tail: Display the beginning or end of a file.

File comparing and Sorting

  • cmp: Compares two files byte by byte.
  • diff: Compares and displays differences between files.
  • sort: Sorts lines in a text file.

File Compressing and Archiving

  • tar (Tape Archive): Create, extract, and manage tar archives.
  • zip and unzip: Create and extract ZIP archives.

File Transfer and Remote Access

  • scp (Secure Copy Protocol): Copies files securely over SSH.
  • rsync: Syncs files and directories locally or remotely.
  • ssh (Secure Shell): Connects to remote systems securely.
  • sftp (Secure File Transfer Protocol): Securely transfers files over SSH.

Process and System Management

  • ps (Process Status): Lists running processes.
  • top and htop: Dynamic process monitoring.
  • kill: Terminates processes.
  • pkill: Terminates processes by name.
  • shutdown: Shuts down the system.
  • reboot: Reboots the system.
  • systemctl: Controls systemd services.
  • exit: Exit the current shell session.

User and Group Management

  • useradd and adduser: Add user accounts.
  • passwd: Change user passwords.
  • userdel and deluser: Delete user accounts.
  • groupadd and addgroup: Add user groups.
  • groupdel and delgroup: Delete user groups.

Package Management

  • apt (Advanced Package Tool): Package management for Debian-based systems.
  • yum and dnf: Package management for Red Hat-based systems.
  • pacman: Package management for Arch Linux.

Network Operations

  • ping: Tests network connectivity.
  • ifconfig and ip: Configure network interfaces.
  • netstat and ss: Display network statistics.
  • nc (Netcat): Networking utility for reading and writing data across networks.
  • curl: Transfers data with URLs.
  • iptables: Manages firewall rules.
  • ufw: Uncomplicated Firewall configuration.
  • ip address: Displays network interface information.

File and System Information

  • stat: Displays file or file system status.
  • lsblk: lists storage device information in Linux.
  • df: Displays disk space usage.
  • free: Displays system memory usage.
  • uname: Displays system information.
  • neofetch: Displays system information.
  • finger: Provides information about user accounts.
  • man: Displays manual pages for commands.
  • echo: Displays text or variables.

System Information and Utilities

  • clear: Clears the terminal screen.
  • whoami: Displays the current username.
  • whatis: Displays a brief description of a command.
  • uname: Displays system information.
  • chmod (Change Mode): Modifies file/directory permissions.
  • chown (Change Owner): Changes file/directory ownership.
  • history: Displays command history.
  • ln: Creates links between files.
  • cal: Displays a calendar.
  • sudo: Executes commands with superuser privileges.
  • su: Switches user context.
  • resolvectl status: Displays DNS configuration.
  • shred: Securely delete files, making them difficult to recover.