Basic Linux Commands You Should Know
An organized list of essential Linux commands with their examples. You can use it to start learning Linux command line or use it as reference for future usage.
The real power of Linux lies in the terminal. With the correct Linux command, you can tweak, configure or change any aspect of your system.
Learning Linux has become synonymous to learning Linux commands and rightly so. Because you can use Linux entirely through commands and do so very effectively.
On Linux Handbook, you can find numerous commands explained with examples. But they are scattered across the website and it wonβt be easy for you to find it.
Essential Linux commands
This is why I created this Linux commands list that is more structured and organized. I have grouped the common Linux commands in categories. Even if you are absolutely new to Linux, you can start learning the commands by following their examples.
Basic file and directory operations
- Learn to list files in a directory with ls command
- Learn to copy a file with cp command
- Learn to rename files with mv command
- Learn to change directories with cd command
- Learn to create directories with mkdir command
- Learn to remove files and directories
File viewing commands
To view the contents of a file in Linux, you can use:
- Cat command to view files entirely in terminal
- Less command to view files one page at a time
- Head command to view the first few lines of a file
- Tail command to view the last few lines of a file
Know the file properties
Every file and directory has attributes like size, ownership, permissions etc. These Linux commands allow you to see the file attributes and change them.
- File command allows you to identify the type of a file
- With touch command, you can change the timestamps
- Change file permissions with chmod command
- Change group ownership with chgrp command
- Count number of lines, words with the wc command
- Know the file and directory size with du command
File text manipulation
Manipulating the text of a file to get what you want. Here are the commands:
- Grep command to find matching lines in files
- Cut and paste commands to treat text as columns
- Tr command converts characters
- Sort command lets you sort lines in text file
- Tee command to copy the file and see its output simultaneously
- Expand command converts tabs to spaces
User account management
Creating and managing users is an important job that you should not take lightly.
- Add new users with useradd command
- Modify existing users with usermod command
- Delete existing users with userdel command
- Also learn the concept of user ID (UID)
Group management
Group management is another important task for a sysadmin.
- Add new groups with groupadd command
- Delete existing groups with groupdel command
- Modify existing groups with groupmod command
- Change group ownership of files with chgrp command
Manage and monitor your system
Keep an eye on your system usage with these commands:
- Check disk space with df command
- Check memory usage with free command
- Shutdown command in Linux
- Use lsof command to find opened files by a process or user
- Create incremental backups with rsync command
- Check running processes with ps command
Basic networking commands
Here are some basic commands related to networking:
- Use dig and nslookup commands to get DNS information
- Use ping command to check if remote host is up
- Use curl command to download information from network
- Use scp command to copy files between remote hosts