Mastering the Linux command line unlocks powerful capabilities for system navigation, file management, software installation, and system monitoring. Whether you're a beginner or an experienced user, understanding these essential commands is crucial. Here’s a structured guide to the fundamental Linux commands every user should know.
The sudo command allows authorized users to perform tasks that require administrative rights. Prefixing a command with sudo grants temporary elevated permissions.
Example:
bash
CopyEdit
sudo apt update
To check if your user has sudo privileges:
bash
CopyEdit
groups <username>
Displays the full path of the current directory.
bash
CopyEdit
pwd
Lists files and directories within the current directory.
Examples:
Basic listing:
bash
CopyEdit
ls
Detailed view with hidden files:
bash
CopyEdit
ls -lha
List specific file types (e.g., Python files):
bash
CopyEdit
ls *.py
Navigates between directories.
Examples:
bash
CopyEdit
cd Downloads # Move to a subdirectory
cd - # Return to the previous directory
cd ~ # Go to the home directory
Outputs the contents of a file to the terminal.
Examples:
bash
CopyEdit
cat filename.txt # Display file
cat -n filename.txt # Display with line numbers
Allows scrolling through file contents.
bash
CopyEdit
less /var/log/syslog
Searches for specific patterns within files.
bash
CopyEdit
lscpu | grep "MHz"
A user-friendly command-line text editor.
Examples:
bash
CopyEdit
nano filename.txt # Open or create file
Moves or renames files and directories.
Examples:
bash
CopyEdit
mv file.txt /destination/ # Move
mv oldname.txt newname.txt # Rename
Copies files or directories.
Examples:
bash
CopyEdit
cp file.txt /destination/ # Copy file
cp -r dir1/ dir2/ # Copy directory recursively
Deletes files or directories.
Examples:
bash
CopyEdit
rm file.txt # Remove file
rm -r directory/ # Remove directory
Creates new directories.
bash
CopyEdit
mkdir new_directory
Manages software packages.
Examples:
bash
CopyEdit
sudo apt update # Update package lists
sudo apt install package_name # Install package
sudo apt upgrade # Upgrade installed packages
Displays real-time system metrics and processes.
bash
CopyEdit
htop
Shows available and used memory.
bash
CopyEdit
free -m
Displays system messages, useful for debugging hardware issues.
bash
CopyEdit
sudo dmesg
Checks the reachability of a host.
Examples:
bash
CopyEdit
ping google.com
ping 8.8.8.8
Shows the IP addresses assigned to the machine.
bash
CopyEdit
hostname -I
Downloads or uploads data using various protocols.
bash
CopyEdit
curl http://example.com/file.txt -o file.txt
Lists previously executed commands.
bash
CopyEdit
history
Runs a command from history using its number.
bash
CopyEdit
!117
Finds commands matching a pattern.
bash
CopyEdit
history | grep "apt"
Familiarity with these Linux commands enhances efficiency and control over your Linux environment. Regular use and practice will make these tools second nature, empowering you to leverage the full potential of the Linux command line.
If you’re still having trouble, consider reaching out to Support.Com for a personalized solution to all technical support issues.