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.
pwdcd: Change Directory
Change the current working directory.
cd /path/to/directoryls: List Directory Contents
List files and directories in the current directory.
lsFile and Directory Operations
Perform common file and directory operations:
touch: Create Empty File
Create an empty file.
touch filenamemkdir: Create Directory
Create a new directory.
mkdir dirnamecp: Copy Files and Directories
Copy files or directories.
cp source destinationmv: Move or Rename Files and Directories
Move or rename files and directories.
mv oldname newnamerm: Remove Files and Directories
Remove files and directories.
rm filenameViewing and Manipulating File Content
Manage file content efficiently:
cat: Concatenate and Display File Content
Display the content of a file.
cat filenamemore and less: Page Through File Content
View file content page by page.
more filenamehead and tail: Display the Beginning or End of a File
Show the beginning or end of a file.
head filename tail filenamenano and vim: Text Editors for File Editing
Edit files using text editors.
nano filename
vim filenameFile Permissions and Ownership
Manage file permissions and ownership:
chmod: Change File Permissions
Modify file permissions.
chmod permissions filenamechown: Change File Ownership
Change file ownership.
chown user:group filenameWorking with Processes
Control and monitor processes:
ps: Display Running Processes
List running processes.
pskill: Terminate Processes
Terminate a process.
kill process_idtop and htop: Monitor System Activity
Monitor system resource usage.
top
htopPackage Management
Manage software packages:
apt: Debian and Ubuntu Package Manager
Install, update, and remove packages.
sudo apt install packageyum: Red Hat and CentOS Package Manager
Manage packages on Red Hat-based systems.
sudo yum install packageNetworking Commands
Control and troubleshoot network connections:
ping: Test Network Connectivity
Check network connectivity to a host.
ping hostnameifconfig and ip: Network Interface Configuration
Configure network interfaces.
ifconfig
ip addrssh: Secure Shell Connection
Connect to remote systems securely.
ssh user@hostnamenetstat and ss: Network Statistics
Display network statistics.
netstat
ssSearching and Filtering Text
Search and manipulate text:
grep: Search Text
Search for text patterns in files.
grep pattern filenamefind: Search for Files and Directories
Search for files and directories.
find /path/to/search -name filenamesed and awk: Text Manipulation
Edit and manipulate text using sed and awk.
sed 's/old/new/' filename
awk '{print $1}' filenameFile Compression and Archiving
Compress and archive files:
tar: Create and Extract Archives
Create and extract compressed archives.
tar -czvf archive.tar.gz directorygzip and gunzip: Compress and Decompress Files
Compress and decompress individual files.
gzip filename
gunzip filename.gzSystem Information and Management
Gather system information and manage resources:
uname: Display System Information
Display system information.
uname -adf and du: Disk Usage
Check disk usage on your system.
df -h
du -sh /path/to/directoryfree: Memory Usage
View system memory usage.
free -mConclusion
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.