Hey there, Linux enthusiasts and command-line conquerors! If you’re new to the world of Linux or just looking for a quick refresher, you’ve come to the right place.
In this post, I’m going to share a handy Linux command cheatsheet that covers all the basic commands you need to know to navigate and manage your Linux system like a pro.
So, let’s get started!
Navigating the File System 🗂️
pwd: Print the current working directory.
cd [directory]: Change the current working directory to the specified directory. For example,
cd Documentschanges to the “Documents” directory.
cd ..: Move up one directory level.
cd ~: Change to the home directory.
ls: List the contents of the current directory.
ls -l: List the contents of the current directory in long format, including file permissions and ownership.
ls -a: List all files and directories, including hidden ones.
File and Directory Management 📁
mkdir [directory]: Create a new directory with the specified name.
rmdir [directory]: Remove an empty directory.
rm [file]: Remove a file. Use the
-roption to remove a directory and its contents recursively (e.g.,
rm -r directory).
cp [source] [destination]: Copy a file or directory from the source to the destination. Use the
-roption to copy directories.
mv [source] [destination]: Move or rename a file or directory.
touch [file]: Create a new empty file or update the timestamp of an existing file.
File Viewing and Editing 📄
cat [file]: Display the contents of a file.
less [file]: View the contents of a file one page at a time.
head [file]: Display the first 10 lines of a file. Use the
-noption to specify a different number of lines (e.g.,
head -n 5 file).
tail [file]: Display the last 10 lines of a file. Use the
-noption to specify a different number of lines.
nano [file]: Open a file in the nano text editor.
vi [file]: Open a file in the vi text editor.
User and System Information 🧑💻
whoami: Display the username of the current user.
id: Display information about the current user, including user ID and group ID.
uname -a: Display detailed system information, including the kernel version and architecture.
df -h: Display disk space usage in human-readable format.
free -h: Display memory usage in human-readable format.
top: Display a dynamic, real-time view of running processes and system resources.
Permissions and Ownership 🔒
chmod [permissions] [file/directory]: Change the permissions of a file or directory. Permissions can be specified using numeric or symbolic notation (e.g.,
chmod 755 fileor
chmod u+x file).
chown [user]:[group] [file/directory]: Change the ownership of a file or directory to the specified user and group.
umask: Display or set the default file permissions for newly created files and directories.
Networking and Connectivity 🌐
ifconfig: Display network interface configuration information.
ping [hostname/IP]: Test network connectivity to a specified hostname or IP address.
- `ssh [user
]@[hostname/IP]`: Connect to a remote system via SSH (Secure Shell) using the specified username and hostname/IP address.
scp [source] [user]@[hostname/IP]:[destination]: Securely copy files or directories between the local system and a remote system over SSH.
wget [URL]: Download a file from the specified URL.
Archiving and Compression 🗜️
tar -cvf [archive.tar] [file/directory]: Create a tarball (tar archive) of the specified file or directory.
tar -xvf [archive.tar]: Extract the contents of a tarball.
gzip [file]: Compress a file using gzip compression.
gunzip [file.gz]: Decompress a gzip-compressed file.
zip [archive.zip] [file/directory]: Create a zip archive of the specified file or directory.
unzip [archive.zip]: Extract the contents of a zip archive.
Searching and Finding 🔍
find [path] -name [pattern]: Find files and directories in the specified path that match the given pattern.
grep [pattern] [file]: Search for a pattern in a file. Use the
-roption to search recursively in directories.
locate [pattern]: Find files and directories on the system that match the given pattern.
System Control and Monitoring 🖥️
ps: Display information about currently running processes.
kill [PID]: Terminate a process with the specified process ID (PID).
sudo [command]: Execute a command with superuser (root) privileges.
reboot: Reboot the system (requires root privileges).
shutdown -h now: Shut down the system immediately (requires root privileges).
Wrapping Up 🎁
And that’s a wrap! This handy Linux command cheat sheet should give you a solid foundation for navigating and managing your Linux system.
Of course, there are many more commands and options to explore, but these basics will get you started on your Linux journey.
Remember, practice makes perfect, so don’t be afraid to open up your terminal and start experimenting. With a little time and effort, you’ll become a Linux command-line wizard in no time!
Thanks for reading, and happy Linux-ing! 🐧🎉
Tired of Being a Linux n00B?
But wait, that’s not all!
If you want to become a true Linux ninja, you’ve got to check out my new e-book called “Shell Samurai – Master the Linux Command Line.” 📚🥷
This e-book is jam-packed with tips, tricks, and techniques that will help you master the Linux command-line like a samurai.
Whether you’re a beginner or an experienced user, Shell Samurai has something for every Linux user.
What are you waiting for?
Grab your copy of “Shell Samurai – Master the Linux Command Line” today and start your journey to becoming a Linux command line master!
Click the link below to grab your copy, and use coupon code KERNEL for 20% off:
Thanks for reading, and happy Linux-ing! 🐧🎉