Linux, with its robust command-line interface, empowers users and administrators to harness the full potential of their systems. Whether you’re a Linux newcomer or a seasoned pro, this Linux Commands Cheatsheet will serve as your comprehensive reference, complete with clear definitions and practical examples, to navigate the world of Linux commands efficiently.
Introduction to Linux Commands
Linux commands are text-based instructions for interacting with a Linux-based operating system. They are a powerful way to perform tasks, manage files, and control processes efficiently.
Navigating the File System
Learn how to navigate the Linux file system:
pwd: Print Working Directory
Display the current directory.
pwd
cd: Change Directory
Change the current working directory.
cd /path/to/directory
ls: List Directory Contents
List files and directories in the current directory.
ls
File and Directory Operations
Perform common file and directory operations:
touch: Create Empty File
Create an empty file.
touch filename
mkdir: Create Directory
Create a new directory.
mkdir dirname
cp: Copy Files and Directories
Copy files or directories.
cp source destination
mv: Move or Rename Files and Directories
Move or rename files and directories.
mv oldname newname
rm: Remove Files and Directories
Remove files and directories.
rm filename
Viewing and Manipulating File Content
Manage file content efficiently:
cat: Concatenate and Display File Content
Display the content of a file.
cat filename
more and less: Page Through File Content
View file content page by page.
more filename
head and tail: Display the Beginning or End of a File
Show the beginning or end of a file.
head filename tail filename
nano and vim: Text Editors for File Editing
Edit files using text editors.
nano filename
vim filename
File Permissions and Ownership
Manage file permissions and ownership:
chmod: Change File Permissions
Modify file permissions.
chmod permissions filename
chown: Change File Ownership
Change file ownership.
chown user:group filename
Working with Processes
Control and monitor processes:
ps: Display Running Processes
List running processes.
ps
kill: Terminate Processes
Terminate a process.
kill process_id
top and htop: Monitor System Activity
Monitor system resource usage.
top
htop
Package Management
Manage software packages:
apt: Debian and Ubuntu Package Manager
Install, update, and remove packages.
sudo apt install package
yum: Red Hat and CentOS Package Manager
Manage packages on Red Hat-based systems.
sudo yum install package
Networking Commands
Control and troubleshoot network connections:
ping: Test Network Connectivity
Check network connectivity to a host.
ping hostname
ifconfig and ip: Network Interface Configuration
Configure network interfaces.
ifconfig
ip addr
ssh: Secure Shell Connection
Connect to remote systems securely.
ssh user@hostname
netstat and ss: Network Statistics
Display network statistics.
netstat
ss
Searching and Filtering Text
Search and manipulate text:
grep: Search Text
Search for text patterns in files.
grep pattern filename
find: Search for Files and Directories
Search for files and directories.
find /path/to/search -name filename
sed and awk: Text Manipulation
Edit and manipulate text using sed
and awk
.
sed 's/old/new/' filename
awk '{print $1}' filename
File Compression and Archiving
Compress and archive files:
tar: Create and Extract Archives
Create and extract compressed archives.
tar -czvf archive.tar.gz directory
gzip and gunzip: Compress and Decompress Files
Compress and decompress individual files.
gzip filename
gunzip filename.gz
System Information and Management
Gather system information and manage resources:
uname: Display System Information
Display system information.
uname -a
df and du: Disk Usage
Check disk usage on your system.
df -h
du -sh /path/to/directory
free: Memory Usage
View system memory usage.
free -m
Conclusion
Linux commands are the backbone of Linux administration and everyday usage. This cheatsheet provides you with essential commands and their definitions, along with practical examples to help you navigate and master the Linux command-line interface. Whether you’re a beginner or an experienced user, these commands will empower you to efficiently manage your Linux system.