Linux Cheat Sheet
Linux operating systems (OS) are frequently used by cybersecurity professionals. However, working in a Linux environment can be daunting for beginners. Most Linux OSs rely heavily on the terminal, which is the equivalent of a Window’s OS command line. Memorizing terminal commands and the various options that go with them is challenging. We here at Cyberkraft have developed a Linux cheat sheet to serve as a quick reference guide.
What Certifications Require Knowledge of Linux Commands?
Many CompTIA certifications require knowledge of Linux. The CompTIA A+, Network+, Security+, CySA+, PenTest+, and CASP+ all require proficiency with Linux terminal commands. The level of proficiency required for the exam depends on the certification. The A+ certification would require only a basic understanding of Linux commands, while CASP+ would require near mastery. Learning Linux commands is a great way to score easy points in these exams.
How Can I Use This Linux Cheat Sheet if I Don’t Have a Linux Device?
The most practical way of practicing Linux commands is to work with a Linux OS, also referred to as a Linux distribution. Most Linux distributions are open source, which means they are available for free. Once you download a Linux distribution, you can either install it on a standalone computer, or, you could deploy it within a virtual machine (VM). We’ve listed the most popular and easily accessible Linux distributions below.
If you are unfamiliar with using VMs or installing a distribution, consider taking our course on “How to Build a Cybersecurity Home Lab”. This course will teach you everything you need to create Virtual Machine and install a Linux distribution within a VM. The course also includes all of the software needed to install a Linux distribution and much more for only $5. Learn more by clicking here.
Popular Linux Distributions
Kali Linux: Kali is specially designed open source Linux distribution for professional penetration testers and cybersecurity professionals. Kali Linux includes numerous cybersecurity and penetration testing tools. Kali Linux is the best choice if you are seeking to use Linux for penetration testing, ethical hacking, or cybersecurity. Click here to download the latest version of Kali Linux.
Debian: Debian is an excellent Linux operating system. It is the foundation of other OS, such as Ubuntu. Debian is ideal for servers and Debian supports many PC architectures and each version of it can be used for a long time. Debian is used extensively by government, non-profit organizations and commercial businesses. Click here to download a Debian distribution.
Ubuntu: This Linux distribution is based on Debain and mainly composed of free and open source software. Ubuntu includes built-in firewall and antivirus software, which makes Ubuntu the most widely used open-source OS for the development and deployment of code. Download Ubuntu here.
Linux Cheat Sheet
We’ve organized the Linux cheat sheet by command category for easy reference. You can also download the full cheat sheet as a PDF. The commands are categorized as file commands, search commands, networking commands, process commands, and Visual Display Editor (VDI) editing commands.
Basic Linux Cheat Sheet – Common Commands#Common_Commands
|ls||List||Lists the current directory and files|
|ls -R||List sub directories||Lists files in sub directories also|
|ls -a||List hidden files||Lists the current directory including hidden files|
|ls -al||List details||Includes details: file size, permissions, owner|
|Cd location||Change directory||Changes directory to a specified location|
|cd ..||Move up one level||Navigates to the parent directory|
|cd ~ or cd||Home||Navigates to the home directory|
|cd /||Root directory||Navigates to the root directory|
|touch filename||Create file||Creates a file with the designated filename|
|cat filename||Display file contents||Displays the content of the designated file|
|cat file1 file2 > file3||Combine files||Combines two files (files 1 and 2) into one file (file 3)|
|mv file “new file path”||Move file||Moves a file to the designated file path|
|mv filename new_file_name||Move and rename file||Moves a file and renames it|
|sudo||Superuser do||Execute any command with superuser privileges|
|rm filename||Delete file||Deletes the designated file|
|man||Help||Shows the help text for a command|
|history||Command history||Displays previously used commands|
|clear||Clear terminal||Clears all inputs from the terminal|
|mkdir directoryname||Make directory||Creates a new directory|
|Rmdir directoryname||Delete directory||Deletes a directory|
|mv||Rename directory||Renames a directory|
|pr -x||Divide file||Divides the file into x columns|
|lpr filename||Print file||Prints a file|
|lp -# filename||Number of copies||Prints multiple copies of a file|
|lp –P printername||Specify printer||Prints to a specific printer|
|apt-get filename||Install||Installs the specified file using the advanced packaging tool (APT)|
|locate file||Search||Searches the index for a specified file|
|grep pattern files||Pattern search||Searches for a specified pattern in designated files|
|grep -r||Recursive search||Searches the current directory and all subdirectories|
|grep -i||Case insensitive search||Finds files regardless of the case used to search|
|find /directory/ -name name||Find files in a directory||Locates specified files in a specific directory|
File Permission Commands
|ls -l||List permissions||Lists current permissions r=read w=write x=execute -=no permissions|
|Chown user||Change owner||Changes ownership of the file or directory to the inputted user|
|Chown user:group filename||Change owner and group||Changes the user as well as the group for a file or directory|
|SSH username@ip-address or hostname||Perform remote login using SSH||Secure Shell (SSH) is an encrypted means of remotely accessing a device|
|put file||File upload||Uploads a file to a remote computer using SSH|
|get file||File download||Download a file from a remote computer using SSH|
|quit||Logout||Logs out of the SSH session|
|ping hostname or ping ipaddress||Ping a device||Uses Internet Control Messaging Protocol (ICMP) pings to assess network connectivity|
|ip a||List IP information||Lists current internet protocol information such as ipv4 and ipv6 address, ethernet adapter used, and MAC addresses. Color coded for fun!|
|ifconfig||List IP information||Traditional way to list IP address information|
|bg||Background||Sends a current process to the background|
|fg||Foreground||Brings a background process to the foreground|
|top||List processes||List details on all active processes|
|ps||Process status||Lists the status of the current process including the process identification (PID), which is a typically a five digit number.|
|kill PID||Kills a process||Kills a process by targeting the PID|
|nice process||Priority start||Starts a process with priority|
|renice –n process||Set priority||Changes the priority level of an already running process. Useful is running multiple applications.|
|df||List free disk space||Lists the amount of free disk space on your machine|
|free||List RAM usage||Shows the amount of RAM in-use and available|
Visual Display Editor (VI) Editing Commands
|i||Insert||Insert characters at the cursor’s location|
|a||Insert after cursor||Write characters after the cursor’s location|
|A||Insert at end||Inserts characters at the end of the line|
|ESC||Exit inset mode||Terminates insert mode|
|u||Undo||Undos the last change. Very useful!|
|U||Undo all||Undo all changes to the entire line|
|o||Open new line||Opens a new line and enters insert mode|
|dd||Delete line||Deletes an entire line|
|3dd||Delete 3 lines||Deletes the 3 previous lines|
|D||Delete after cursor||Delete contents of the line after the cursor|
|C||Delete and insert||Similar to D but also enters insert mode|
|dw||Delete word||Delete a word at the cursor’s location|
|4dw||Delete 4 words||Deletes four words. Why 4? Why not!|
|cw||Change word||Changes a word|
|x||Delete character||Deletes a character at the cursor|
|r||Replace character||Replaces a single character at the cursor|
|R||Overwrite||Overwrite characters from cursor onward|
|s||Substitute character||Substitutes one character under the cursor then enters insert mode|
|S||Substitute line||Substitutes an entire line and begins to insert at the beginning of the next line|
|~||Change case||Changes the case of a single character|
Download a Free Copy of Our Linux Commands Cheat Sheet
Download your free copy of this cheat sheet here.
Save this PDF as a quick reference guide.
Cyberkraft Course “How to Build a Cybersecurity Home Lab”
If you’re interested in learning Linux but you don’t know how to get started, consider taking our course on “How to Build a Cybersecurity Home Lab”. This course will teach you how to download and install your own Linux distribution using a virtual machine. This way, you’ll be able to learn Linux for free anytime. The course can even teach you how to set up your own virtual network.
The course is only $5, so take a moment to check it out by clicking this link.
Become a Linux Expert With Our CompTIA Linux+ Course
The CompTIA Linux+ Certification is the World’s Premier Linux certification. It teaches the core competencies demanded by the industry’s hiring managers. Linux+ certified professionals are expected to earn an average yearly salary of $79,000 per year according to PayScale.com.
Our Linux+ Course teaches you everything you need to ace your Linux+ exam on the first attempt. Plus, we’ll help you get hired with our career assistance program.