50 Essential Linux Commands that You Should Know
In this blog post, I will list 50 essential Linux commands you need to know to manage Linux systems effectively. These commands will help you perform various tasks efficiently. This post is a follow-up to my previous blog post: 90 frequently used Linux Commands. However, it’s designed to provide you with a carefully categorized list of essential Linux commands.
Navigating the Linux command line interface can be a daunting experience. With so many commands and their varying functionalities, it can be challenging to know where to start. However, learning the basic commands is essential.
This article divides the essential Linux commands into several categories, such as navigation, file management, text processing, scheduling, and so on, making it easier for you to learn and understand Linux. By mastering these commands, you will be well on your way to becoming a proficient Linux user!
Image source: wallhaven.
While I have provided a brief description of each command, it is important that you research each command further to fully understand its capabilities and how it can be utilized in your workflow. However, to assist you in your research, I have hyperlinked most of the commands to onsite and offsite blog posts and other pages containing more detailed information.
I hope this list will serve as a valuable resource to enhance your Linux skills and increase your efficiency when working with the command line:
Table of Contents
Navigation
- pwd – Print working directory: This shows the current directory you are in.
- ls – List files and directories: Lists the files and directories in the current directory.
- cd – Change directory: Changes the current directory.
- history – Displays the history of previously executed commands.
- clear – Clear the screen: Clears the terminal screen.
File and Directory Management
- mkdir – Make directory: Creates a new directory.
- rmdir – Remove directory: Deletes a directory.
- cp – Copy file/directory: Copies files or directories.
- mv – Move file/directory: Moves files or directories.
- rm – Remove file: Deletes a file.
- touch – Create a file: Creates a new empty file.
- find – Searches for files and directories.
- grep – Searches for a pattern in a file.
- head – Shows the first 10 lines of a file.
- tail – Shows the last few lines of a file.
Text Manipulation
- cat – Concatenate files: Displays the contents of a file.
- less – Display output one screen at a time: Shows the output of a command one screen at a time.
- awk – Manipulate and analyze text files: Manipulates and analyzes text files.
- sed – stream editor for filtering and transforming text: perform text transformations on an input stream.
- vi (or vim) – a text editor for creating and editing text files. Ref card pdf: 1 | 2 | 3
- nano – a text editor used to create and edit text files. Ref card pdf: 1. Also see Ubuntu’s Nano help page.
- emacs – a highly customizable text editor for text editing and document preparation tasks.
- echo – Print to the screen: Displays text on the screen.
Compression and Archiving
- tar – Archive files: Compresses and archives files.
- gzip – Compress files: Compresses files. (and gunzip)
- zip – Compress files into a zip archive: Compresses files into a zip archive. (and unzip)
Permissions and Ownership
- sudo – This command is used to execute a command with elevated privileges.
- su – This command is used to switch to another user account in the current shell session.
- umask – This command is used to set the default file creation permissions for new files and directories.
- chmod – Change file permissions: Changes the permissions of a file.
- chown – Change file owner: Changes the owner of a file.
System Information
- ps – Show the running processes: Displays the running processes on the system. Also, see pstree.
- top – Show the system status: Displays the system status. Also, see htop, btop, and atop.
- free – Show the system memory usage: Displays the memory usage of the system.
- df – Show the disk space usage: Displays the disk space usage of the system.
- du – Show the disk usage of a file or directory: Displays the disk usage of a file or directory.
- which – Show the location of a command: locate the executable file associated with a given command.
- man – Show the manual for a command: Shows the manual page for a command.
- Also, see uptime, vmstat, iotop, sar, dstat, last, lastlog and w.
Networking
- ip – Used to view and manage network interfaces and routing tables.
- ss – Used to view network sockets and their related information.
- dig – Used to query DNS (Domain Name System) servers for DNS-related information.
- ping – Test network connectivity: Tests the network connectivity to a host.
- ssh – Connect to a remote system: Connects to a remote system over SSH.
- scp – Copy files to/from a remote system: Copies files to/from a remote system.
- rsync – remote sync: A file synchronization tool for Unix/Linux systems.
- curl – Transfer data from a server: Transfers data from a server using various protocols.
- wget – Download files from the web: Downloads files from the web.
- More networking commands: 60 Linux Networking commands and scripts.
Text Processing
- sort – Sort lines of text: Sorts the lines of text in a file.
- uniq – Show unique lines of text: Displays only the unique lines of text in a file.
- diff – Show differences between files: Compares two files and shows the differences.
- cut – Cut out specific sections of a file: Extracts specific columns from a file.
- paste – Merge lines of files: Merges lines from multiple files.
Scheduling
- crontab – Schedule commands to run at specific times: Schedules commands to run automatically.
- at – Schedules a one-time task to be executed at a specific time in the future.
- anacron – Executes commands periodically (ex, daily, weekly, and monthly), especially for systems not running 24/7.
- batch – Schedules commands to be executed when system load levels permit.
Becoming familiar with Linux commands
Linux commands cheat sheet. Source: wallhaven.
We’ve covered 50 essential Linux commands that every Linux user should know. These commands are categorized into different groups, such as File Management, Text Processing, System Information, Permissions and Ownership, Networking, Scheduling, and Process Management.
By learning and mastering these commands, you will be able to manage Linux systems, perform tasks efficiently, and automate tasks.
However, it’s important to remember that learning Linux commands is not a one-time thing. It requires consistent practice and experience. The more you use these commands, the more you will become familiar with them and the more efficient you will become at performing tasks.
Building experience with Linux commands is vital because it allows you to develop a deeper understanding of the system. When you encounter a problem, you can diagnose the issue and resolve it quickly. You will also be able to customize the system to your needs and automate tasks to save time and increase efficiency.
Building experience with Linux commands
Linux file system hierarchy. Source: wallhaven.
To build experience with Linux commands, there are a few things you can do. First, try to use the command line interface as much as possible. This will give you practice with the commands and allow you to see the output of commands in real time. You can also experiment with different command options and arguments to see how they work.
Another way to build experience with Linux commands is to work on real-world projects. For example, you could create a shell script to automate a task that you perform regularly. This will give you practice with the commands and also help you to automate tasks to save time.
Other related blog posts and reading:
- Mastering Linux Administration: 20 Powerful Commands to Know.
- 90 frequently used Linux Commands.
- 60 Linux Networking commands and scripts.
- Get Started with Linux: Top 10 Commands for New Users.
- Bash cheat sheet (awesome cheatsheets).
- Bash-Cheat-Sheet B (RehanSaeed).
Summary
In conclusion, Linux commands are an essential tool for managing Linux systems. By learning and mastering these commands, you can perform tasks efficiently, automate, and customize the system to your needs. However, it’s important to build experience with Linux commands by using the command line interface, experimenting with different options and arguments, and working on real-world projects. With practice and experience, you will become more proficient at using Linux commands and easily handle more complex tasks.
Of course, these are just some of the many commands available in Linux. Whether you’re an experienced Linux user or just starting out, mastering even more commands will help you manage systems and servers more efficiently and perform a wide range of tasks. Happy Linux-ing!
Feel free to add any additional commands in the comments.
For example:
useradd
andusermod
:The
useradd
command is used to create a new user account. When used with appropriate options, it can set the user’s home directory, shell, user ID, group ID, and other properties. For example, the commandsudo useradd -m -s /bin/bash john
creates a new user account called “john” with a home directory and sets the default shell to bash.The
usermod
command is used to modify an existing user account. It can be used to change the user’s home directory, default shell, user ID, group ID, and other properties. For example, the commandsudo usermod -a -G www-data john
adds the user “john” to the “www-data” group, giving them access to web server files and directories.It’s important to note that both of these commands require root privileges to run, which means they must be run with the
sudo
command or as the root user.One thing that has always baffled me is how to find the groups a user is part of. Then I figured out groups username was how and I felt like such a `tard. next thing you know I’ll forget what dcpromo does in Windows…ugh
Prompted by this article, I read up on the difference between CTRL-C and CTRL-Z. The latter will suspend a task on the command line rather than aborting it, after which you can resume it in the foreground with
fg
, or in the background withbg
.I compared the
/boot/
directories in the file system structure image shown and on my Raspberry Pi OS Bookworm (as well as it’s alternative/boot/firmware/
directory) and found no matches. Is the screenshot out of date, or just related to a different Linux flavour?