Monday, March 18, 2024

Linux Prompt Cheatsheet: 45 Commands that Every Technologist Should Know

3 min read
(Updated: Friday, March 22, 2024)

The Linux command line (often referred to as shell, terminal, console, prompt) is a text interface to your computer running one of the Linux operating systems.

Navigating the command line might seem like a maze at first glance, but it's really the key to unleashing the true power of your Linux system. This cheat sheet we've put together isn't just a list of commands; think of it as your handy guide through the wilderness of system management and troubleshooting, a companion for both beginners itching to explore and experts needing a quick reference.

We are compiling a fairly comprehensive list that covers various categories, including file management, system monitoring, network commands, and others, to serve as a foundational reference for you. This cheat sheet aims to provide a balanced mixture of commands - from the most commonly used to those that are crucial for specific troubleshooting and system management tasks.

File Management

  • ls: Lists files and directories within the current directory.
  • cd <directory>: Changes the current directory to the specified one.
  • pwd: Displays the current directory path.
  • cp <source> <destination>: Copies files or directories.
  • mv <source> <destination>: Moves files or directories, also used for renaming.
  • rm <file>: Deletes a file. Use -r for directories.
  • mkdir <directory>: Creates a new directory.
  • rmdir <directory>: Deletes an empty directory.
  • find: Searches for files and directories.
  • touch <file>: Creates a new file or updates the timestamp of an existing file.

System Monitoring and Management

  • top: Displays an interactive list of running processes.
  • ps: Shows a snapshot of current processes.
  • free: Shows memory usage.
  • df: Displays disk space usage for file systems.
  • du: Shows the disk usage of files and directories.
  • htop: An interactive process viewer (more detailed than top).

Network Commands

  • ping <host>: Checks connectivity to a host.
  • ifconfig: Displays or configures network interfaces. (ip a in newer systems)
  • netstat: Displays network connections, routing tables, and interface statistics.
  • ss: Another utility to investigate sockets.
  • wget <URL>: Downloads files from the internet.
  • curl <URL>: Transfers data from or to a server.

File Permissions

  • chmod <permissions> <file>: Changes the file's mode.
  • chown <user>:<group> <file>: Changes the file owner and group.
  • umask: Sets the default permission for new files and directories.

Text Processing

  • grep <pattern> <files>: Searches for a pattern in files.
  • sed: Stream editor for filtering and transforming text.
  • awk: An entire programming language designed for text processing.

Archive and Compression

  • tar: Creates and extracts tar archives.
  • gzip <file>: Compresses or decompresses files.
  • zip, unzip: Compress and decompress zip files.

Package Management (Debian/Ubuntu)

  • apt-get update: Updates the package list.
  • apt-get upgrade: Upgrades all upgradable packages.
  • apt-get install <package>: Installs a new package.
  • apt-get remove <package>: Removes a package.

Package Management (RHEL/CentOS/Fedora)

  • yum check-update: Checks for available package updates.
  • yum update: Updates all upgradable packages.
  • yum install <package>: Installs a new package.
  • yum remove <package>: Removes a package.

General

  • echo text: Displays a line of text.
  • which <command>: Shows the full path of (shell) commands.
  • man <command>: Displays the manual page for the command.

This cheat sheet covers essential commands but is by no means exhaustive. Each command comes with a plethora of options and nuances, best explored through their manual pages (man command).

And remember, the true power of Linux lies in combining these commands using pipes (|) and redirections (>, <) to perform complex tasks efficiently.

You might want to check these out ↘

How Your Database Stands Up to the Ultimate Reliability Check: ACID rules

How Your Database Stands Up to the Ultimate Reliability Check: ACID rules

For IT professionals in database management, grasping the core principles that protect our digital transactions is essential. Today, we're exploring the ACID model, a pivotal framework for ensuring transaction reliability and security. This goes beyond mere theoretical knowledge; it's vital for the smooth operation of diverse systems, from financial processes to social media platforms. We'll delve into the ACID principles and their critical role in real-world applications.
Convert String to Date: The Java Ways

Convert String to Date: The Java Ways

Converting strings to dates in programming is a common task that's more complex than it seems. This challenge is rooted in the wide range of date formats and the specifics of time zones. Converting a String to a Date in Java can be done in several ways, depending on the Java version you're using and whether you are incorporating external libraries. Below are the primary methods used in different versions of Java and through some commonly used external libraries.
Cookbook: How to Effectively Revert a Git Commit

Cookbook: How to Effectively Revert a Git Commit

As a software engineer, encountering situations where recent changes need to be undone is not uncommon. It may be due to errors, or in some cases just need a significant rework. When such scenarios arise while using Git as your version control system, there’s a few approaches that can help revert those changes effectively. Let’s take a closer look.
Technology
Trending
Contact Us

Stay ahead of the curve
on software insights and technology trends.