Master linux: The top 100 commands you absolutely need to know

Votre note nous aide à améliorer nos contenus ! Partagez votre avis.

The Linux operating system stands as a pillar of modern computing infrastructure, renowned for its stability, security, and open-source flexibility. While graphical user interfaces (GUIs) have improved significantly over the years, the true power of linux resides in the Command Line Interface (CLI). For system administrators, developers, and IT professionals, the terminal is not just a tool it is the primary environment for executing complex tasks with precision.

Unlocking the full potential of a Linux system requires more than just knowing how to navigate a desktop environment. It demands a command of the fundamental instructions that control the kernel and the software layers above it. Whether you are managing a fleet of remote servers, debugging a critical application, or automating deployment pipelines, mastering these commands is non-negotiable.

This guide provides a comprehensive overview of the 100 most essential Linux commands. These tools will transform the way you interact with your system, moving you from a passive user to a proficient administrator capable of troubleshooting and optimizing any Linux environment.

Understanding the linux command line

At its core, a linux command is a specific instruction entered into a terminal (or shell) that tells the operating system to perform a distinct task. These tasks range from simple file manipulations to complex network configurations and process management.

Unlike a GUI, where options are limited to what is presented on the screen, the command line offers granular control over every aspect of the system. Commands can be chained together, scripted, and scheduled, providing a level of versatility that point-and-click interfaces simply cannot match.

Why proficiency matters

Before examining the specific commands, it is important to understand the strategic advantages of mastering the CLI:

  • Operational efficiency: Command-line operations are often significantly faster than navigating through multiple windows and menus. A single line of code can perform a task that might take ten clicks in a GUI.
  • Automation capabilities: Commands are the building blocks of shell scripting. By combining these instructions, administrators can automate repetitive tasks such as backups, updates, and system monitoring.
  • Deep system control: The CLI provides access to configuration files and system settings that are often hidden or inaccessible via graphical tools. This level of access is crucial for deep troubleshooting and performance tuning.
  • Professional independence: In many enterprise environments, particularly cloud infrastructure and headless servers, there is no graphical interface. Proficiency with the command line ensures you can work effectively in any server environment, regardless of the configuration.

File and directory management

Navigating the filesystem is the most fundamental skill in Linux administration. These commands allow you to create, move, delete, and organize the data structure of your server.

Basic navigation and manipulation

  • ls: Lists the contents of a specific directory. It is arguably the most frequently used command.
  • cd: Changes the current working directory, allowing you to navigate the file hierarchy.
  • pwd: Prints the working directory, displaying the full path of your current location.
  • mkdir: Creates a new directory.
  • rmdir: Removes an empty directory.
  • rm: Removes files or directories. This is a powerful command that should be used with caution, especially with the recursive force flags (-rf).
  • cp: Copies files or directories from a source to a destination.
  • mv: Moves files or directories. This command is also used to rename files.

Advanced file operations

  • find: Searches for files within a directory hierarchy based on various criteria such as name, size, or modification date.
  • locate: Finds files by name using a pre-built database, which is often faster than find but potentially less current.
  • touch: Updates the access and modification timestamps of a file. It is commonly used to create an empty file if one does not exist.
  • stat: Displays detailed status information about a file or file system, including inode numbers and exact timestamps.
  • file: Determines the file type based on its content rather than its extension.
  • basename: Strips directory and suffix from filenames, useful in scripting.
  • ln: Creates links between files. Hard links point to the same data on the disk, while symbolic links (symlinks) act as shortcuts.

Disk usage and filesystem

  • df: Reports file system disk space usage.
  • du: Estimates file space usage, showing the size of directories and their contents.
  • lsblk: Lists information about all available or specified block devices (storage devices).
  • mount: Mounts a file system, making it accessible to the user.
  • umount: Unmounts a currently mounted file system.

Permissions and user management

Linux is a multi-user operating system, making permission management critical for security. These commands allow administrators to control who can access, modify, or execute files.

  • chmod: Changes the file mode bits (permissions) of a file or directory.
  • chown: Changes the file owner and group.
  • chgrp: Changes the group ownership of a file.
  • id: Prints real and effective user and group IDs.
  • whoami: Displays the username of the current effective user.
  • who: Shows who is currently logged into the system.
  • su: The substitute user command, used to switch to another user account (often root).
  • sudo: Executes a command as another user, typically the superuser, following security policies.
  • passwd: Updates a user’s authentication tokens (changes passwords).
  • groups: Prints the groups a user is a member of.

Text manipulation and analysis

Configuration files and logs in Linux are primarily text-based. Being able to read, search, and edit text streams efficiently is a core competency for any administrator.

Viewing content

  • cat: Concatenates and displays file content to the standard output.
  • tac: Displays file content in reverse order (last line first).
  • less: Allows backward and forward movement through a file. It is essential for viewing large log files without loading the entire file into memory.
  • more: A simpler file viewer that allows distinct paging through text.
  • head: Outputs the first part of files (default is 10 lines).
  • tail: Outputs the last part of files. Using tail -f allows you to follow a log file in real-time as it is written.

Editing and processing

  • cut: Removes sections from each line of files.
  • grep: Searches for patterns within a file. It is an incredibly powerful tool for filtering output and finding specific configuration settings.
  • sed: A stream editor for filtering and transforming text.
  • awk: A domain-specific language designed for text processing and typically used as a data extraction and reporting tool.
  • wc: Prints newline, word, and byte counts for each file.
  • sort: Sorts lines of text files.
  • uniq: Reports or omits repeated lines; typically used in conjunction with sort.
  • diff: Compares files line by line.
  • cmp: Compares two files byte by byte.
  • strings: Prints the strings of printable characters in files, useful for analyzing binary files.

 

Process management

System performance relies on the efficient management of running applications and services. These commands help you monitor system load and control processes.

  • ps: Reports a snapshot of the current processes.
  • top: Provides a dynamic, real-time view of a running system, including CPU and memory usage.
  • htop: An interactive process viewer that serves as a more user-friendly alternative to top.
  • kill: Sends a signal to a process (usually to terminate it) based on its Process ID (PID).
  • pkill: Signals processes based on name and other attributes.
  • jobs: Lists active jobs in the current shell session.
  • fg: Moves a background job into the foreground.
  • bg: Resumes suspended jobs in the background.
  • nice: Runs a program with modified scheduling priority.
  • renice: Alters the scheduling priority of running processes.

System administration

These commands are the daily drivers for maintaining the health and configuration of the operating system itself.

System information and monitoring

  • uptime: Tells how long the system has been running, along with load averages.
  • uname: Prints system information, such as the kernel name and version.
  • hostname: Shows or sets the system’s host name.
  • dmesg: Prints or controls the kernel ring buffer, useful for diagnosing hardware and boot issues.
  • free: Displays the amount of free and used memory in the system.
  • vmstat: Reports virtual memory statistics.
  • iostat: Reports Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.

Service and power management

  • systemctl: Introspects and controls the state of the “systemd” system and service manager. This is the modern standard for service management.
  • service: Runs a System V init script; an older method for managing services but still relevant on some systems.
  • journalctl: Query and display logs from systemd.
  • shutdown: Brings the system down in a safe, secure way.
  • reboot: Restarts the system.
  • crontab: Maintains crontab files for individual users, used to schedule periodic background jobs.
  • at: Queues jobs for later execution.
  • time: Runs programs and summarizes system resource usage.

Networking

In a connected world, managing network interfaces and troubleshooting connectivity is essential.

Connectivity and transfer

  • ping: Sends ICMP ECHO_REQUEST to network hosts to test reachability.
  • curl: A tool to transfer data from or to a server, supporting various protocols.
  • wget: A non-interactive network downloader.
  • scp: Securely copies files between hosts on a network.
  • rsync: A fast, versatile, remote (and local) file-copying tool.
  • ssh: OpenSSH SSH client (remote login program).
  • ftp: Internet file transfer program.

Configuration and diagnostics

  • ip: Shows or manipulates routing, network devices, interfaces, and tunnels. This replaces the deprecated ifconfig.
  • ifconfig: Configures a network interface (legacy).
  • ss: Investigates sockets. It is the modern replacement for netstat.
  • netstat: Print network connections, routing tables, and interface statistics (legacy).
  • traceroute: Prints the route packets take to the network host.
  • nslookup: Queries Internet name servers interactively.
  • dig: DNS lookup utility, often preferred over nslookup for its detailed output.
  • nmap: Network exploration tool and security / port scanner.
  • tcpdump: Dumps traffic on a network.

Compression and archiving

Managing disk space often involves compressing log files or packaging applications for deployment.

  • tar: An archiving utility used to store multiple files in a single file (an archive), often called a “tarball.”
  • zip: Packages and compresses (archives) files.
  • unzip: Lists, tests, and extracts compressed files in a ZIP archive.
  • gzip: Compresses or expands files using Lempel-Ziv coding (LZ77).
  • gunzip: Decompresses files created by gzip.
  • bzip2: A block-sorting file compressor.
  • bunzip2: Decompresses files created by bzip2.
  • xz: Compresses files with a high compression ratio.
  • unxz: Decompresses .xz files.
  • 7z: A file archiver with a high compression ratio.

Miscellaneous utilities

These tools improve quality of life and productivity within the terminal environment.

  • alias: Defines or displays aliases (shortcuts for commands).
  • history: Displays the command history list with line numbers.

Strategies for mastery

Memorizing 100 commands is a significant undertaking, but mastery comes through application rather than rote memorization. To truly integrate these tools into your workflow, consider the following strategies:

Consistent practice
Begin with the file management and permission commands. These are the most frequently used and will build your muscle memory. Force yourself to perform tasks via the terminal that you would normally do via a GUI.

Leverage documentation
Linux has built-in documentation. If you are unsure about the flags or syntax of a command, use the manual pages. For example, typing man ls will provide a complete manual for the list command. This is often the most accurate source of information for your specific distribution.

Real-world application
Apply these commands to concrete projects. Set up a web server, configure a firewall, or write a script to automate your backups. Practical application cements knowledge and reveals the nuances of how commands interact with one another.

Conclusion

This guide to the top 100 Linux commands provides a robust foundation for anyone looking to excel in system administration or development. The Linux command line is a sophisticated environment where clarity, precision, and power converge. By mastering these commands, you gain not just the ability to execute tasks, but the capacity to understand and control the intricate workings of your operating system. Continue to explore, experiment, and refine your skills to unlock the full potential of your Linux environment.

Plus de Systalink

Best Cloud Tool

How to choose the perfect cloud tool for your business

Virtual Phone Numbers

Master Online Virtual Phone Numbers