If you’re new to Linux, mastering the command line might seem like a daunting task. But don’t worry—once you get familiar with a few basic commands, you’ll find that it’s a powerful way to interact with your system. Here’s a curated list of 50 basic Linux commands that every user should know to navigate and control the system like a pro.
1. pwd – Print Working Directory
Displays the current directory you are in. This is helpful when you get lost in the depths of your file system.
Example:
pwd
2. ls – List Directory Contents
Shows the files and directories within your current location. Add options to customize the output (like ls -la
to show hidden files).
Example:
ls -la
3. cd – Change Directory
Allows you to move between directories. Use cd ..
to move up one level or provide a full path to switch to a specific folder.
Example:
cd /var/www/html
4. touch – Create Empty Files
The easiest way to create a file without any content. Useful for placeholders or quick testing.
Example:
touch newfile.txt
5. cat – Concatenate and Display File Content
Combine files and show their contents. Perfect for reading smaller files right in the terminal.
Example:
cat file.txt
6. cp – Copy Files or Directories
Copies files or directories from one location to another. Add -r
for directories.
Example:
cp source.txt destination.txt
7. mv – Move or Rename Files
Move files or directories to a new location, or rename them.
Example:
mv oldname.txt newname.txt
8. rm – Remove Files or Directories
Deletes files or directories. Use with caution—once gone, it’s hard to recover files! Use -r
for directories.
Example:
rm -r directory_name
9. mkdir – Make a New Directory
Create new directories with this command. Add the -p
option to make parent directories if they don’t exist.
Example:
mkdir -p /home/user/newdir
10. rmdir – Remove Empty Directories
Deletes directories only if they are empty. If not, use rm -r
.
Example:
rmdir emptydir
11. echo – Display Text or Variables
Use echo
to print a string of text or the value of a variable to the terminal.
Example:
echo "Hello World"
12. nano – Simple Text Editor
Nano is a beginner-friendly text editor. It runs in the terminal and is ideal for quick edits.
Example:
nano file.txt
13. vi – Advanced Text Editor
Vi is a powerful, feature-rich text editor. It’s often a bit more complex, but ideal for seasoned users.
Example:
vi file.txt
14. chmod – Change File Permissions
Modifies the read, write, and execute permissions for files and directories.
Example:
chmod 755 script.sh
15. chown – Change File Owner
Change the ownership of files and directories. You can also assign groups.
Example:
chown user:group filename
16. find – Search for Files
Search for files within a directory structure. This command is highly customizable with parameters like -name
or -type
.
Example:
find /home -name "*.log"
17. grep – Search Text Patterns
Extract specific lines from files based on patterns. Perfect for filtering log files.
Example:
grep "error" logfile.txt
18. man – Manual Pages
Shows the manual for a command, offering in-depth explanations of usage and options.
Example:
man ls
19. ps – Process Status
Displays information about active processes.
Example:
ps aux
20. kill – Terminate a Process
Kill a process by specifying its PID (Process ID).
Example:
kill 1234
21. top – System Monitor
A real-time process viewer that displays system resource usage like CPU and memory.
Example:
top
22. df – Disk Space Usage
Reports available disk space on your file systems.
Example:
df -h
23. du – Estimate File Space Usage
Shows the disk usage of files and directories. Add -h
for human-readable output.
Example:
du -h /home/user
24. free – Memory Usage
Displays the amount of free and used memory in the system.
Example:
free -m
25. uname – System Information
Print detailed system information. Add -a
to get all system details.
Example:
uname -a