Table of Contents
Introduction
As a Linux user, you must have struggled with remembering all the important commands at some point in time.
Don’t fret! Most of us have.
There are thousands of Linux commands. Though those Linux commands satisfy different use cases and improve user convenience, It is difficult to remember all those commands at the same time.
The brighter side is that a majority of Linux users accomplish their work by just using a set of most commonly used Linux commands. Even so, having a Linux commands cheat sheet is an industry best practice you should adopt.
Here’s a cheat sheet for you.
What is Linux?
LINUX is an operating system or kernel that is freely available under an open-source license. Its feature set is quite similar to that of UNIX. It was initially used for computers, but its use later on expanded to underpin systems for phones, cars, web servers, and even networking gear.
Following are some of the features of the Linux operating system:
- Secure: Linux offers user security via authentication features such as password protection, restricted access to particular files, and data encryption.
- Hierarchy in File System: Linux’s hierarchical file system offers a standard file structure for arranging system and user data.
- Multiprogramming: Linux is a multiprogramming system, which implies that several programs may execute at the same time.
- Supports Many Users: Linux is a multiuser system, which implies that many users may use system resources such as memory/ram/application applications at the same time.
Linux Commands
Linux-based operating systems have made their way into a variety of linked devices, from our homes and vehicles to our workplaces, due to their open-source nature and the possibility for minimal OS footprint. Evolution does not have to be a straight line, as Linux developers have shown over and over again.
Over the next several decades, Linux may evolve into something entirely new, becoming the operating system of choice for an array of products and services that we can’t even envision presently.
A. Linux Commands Cheat Sheet: Basic Linux Commands
ls | List all the files and directories in the current working directory |
ls -a | List the hidden files as well |
ls -R | List files in the present working directory as well as the subdirectories thereof |
ls -S | List files sorted by file size |
ls -al | List all the files and directories along with their details |
pwd | Display the present working directory |
mkdir ABC | Make a directory ABC |
rmdir | Deletes a directory |
rm [file_name] | delete a file |
mv [ file_1] [file_2] | Rename a file from [file_1] to [file_2] |
cp [file_1] [file_2] | Copy contents of [file_1] to [file_2] |
cd ABC | Go to the directory ABC |
Cd or cd ~ | Change the present working directory to the home directory |
Cd / | Move to the root directory |
touch [file_1] | Create a new file [File_1] |
more [file_1] | Show the contents of the file [File_1] |
cat [file_1] >> [file_2] | Append contents of one file to another |
head [file_1] | Show the first 10 lines of the file [file_1] |
tail [file_1] | Show the last 10 lines of the file [file_1] |
pr -x | To Divide a file into x columns |
pr -h | To assign a header to the file |
B. Linux Commands Cheat Sheet: File Permission Commands
- U- User
- G- Group
- W- World
ls -l | Show file type and access permission |
r | Denotes read permission |
w | Denotes write permission |
x | Denotes execution permission |
-= | Denotes no permission |
Chown user | Changes ownership of a file/directory |
Chown user: group filename | Changes the user as well as the group for a file or directory |
C. Linux Commands Cheat Sheet: Networking Commands
ping host | Send an ICMP echo request to the host |
Whois [domain] | Displays “who is” information for the requested domain |
Dir | To display files in the current directory of a remotely connected computer |
put file | To send a file from your computer to the remote computer |
get file | To get the file from a remote computer to your computer |
SSH username@ip-address or hostname | Log in to a remote Linux machine using SSH |
ip a | Display all IP addresses and network interfaces |
D. Linux Commands Cheat Sheet: Process Commands
ps | Displays running processes |
ps -ef | Displays all running processes on the system |
bg | Send a process to the background |
fg | Retrieve and run a process in the foreground |
ps | Process status – running or stopped |
ps PID | Process status of the process with the given ID |
pidof | Displays process id of a process |
renice | Assigns a new priority to an already running process |
nice | A new process with a given priority starts |
kill PID | Kills the process with the given ID |
program & | Start the given program in the background with no output display |
killall process_name | Kill all processes with name process_name |
E. Linux Commands Cheat Sheet: VI Editing Commands
i | To Insert at the cursor |
a | To write after the cursor |
A | To write at the EOL |
Esc | To exit insert mode |
u | Undo |
U | Undo all the changes to the line |
o | Open a new line to write |
x | To delete a character at the cursor |
r | To replace a character |
Frequently Asked Questions
A cheat sheet is a concise collection of notes to aid memory through a quick reference. A Linux cheat sheet contains a list of useful Linux commands that every Linux user can use and keep handy.
Linux provides a text-based terminal interface for users to interact with it. Linux commands enable a user to accomplish several simple and advanced tasks through the Linux terminal by executing such commands.
You can list all the commands using the compgen shell built-in.
compgen –c | more lists every command you can run.
-a lists all the aliases
-b lists built-ins
-k lists all the keywords
-A function lists all the functions you can run
-A function –back lists all of these
The most common commands one can use every day are as follows:
cd: It is used for navigating between the directories
ls: Lists all the files and directories in the current working directory
mkdir: Creates a new directory
pwd: Displays the present working directory
cp: Copies file from the present working directory to another directory
mv: Renames as well as moves files
rmdir: Deletes a directory
touch: Creates a blank new file
locate: Locates a file you are looking for
df: Information on system’s disk space
A terminal is a text-based interface that users can utilise to work on a computer. It is also known as a command line or a console in different technical jargons. Any command that can be executed on such an interface is called a terminal command.
Linux uses a lot of symbols to communicate different meanings. Here’s a list of special characters used in Linux along with their meaning.
F. Additional Linux Commends
~ | denotes Home directory. |
. | denotes Current Directory |
.. | denotes Parent Directory |
* | denotes Character Sequence Wildcard |
/ | denotes a slash or a Path Directory Separator |
# | denotes Trim Strings or Comments |
? | denotes a Single character wildcard |
[] | denotes Character set wildcard |
< | denotes input redirection |
> | denotes output redirection |
| | denotes a pipe |
; | denotes a shell command separator |
& | hides the output of a command |
Key Takeaways
If you are keen to start working on the Linux commands for building projects and more, this Linux commands cheat sheet can be your guide.
Wish to build a bright future in Coding? Enrol in our Premium Courses!
Leave a Reply