Linux Commands : The most effective part of the Linux operating system is the command line terminal. But for beginners, the total quantity of commands available might be frightening. This Linux cheat sheet commands reference was developed because even experienced users occasionally forget a command.
It’s quite helpful to have a comprehensive list of Linux commands that have been sorted by category for situations like these. The list can then be quickly checked whenever you forget the specific syntax of a command.
We’ll provide you a selection of the most useful Linux commands in this guide. Even though they are some of the most helpful orders, they are difficult to remember.
Contents
Basic Linux Commands
Command
Description
ls
Lists all files and directories in the present working directory
ls -R
Lists files in sub-directories as well
ls -a
Lists hidden files as well
ls -al
Lists files and directories with detailed information like permissions,size, owner, etc.
cd or cd ~
Navigate to HOME directory
cd ..
Move one level up
cd
To change to a particular directory
cd /
Move to the root directory
cat > filename
Creates a new file
cat filename
Displays the file content
cat file1 file2 > file3
Joins two files (file1, file2) and stores the output in a new file (file3)
mv file "new file path"
Moves the files to the new location
mv filename new_file_name
Renames the file to a new filename
sudo
Allows regular users to run programs with the security privileges of the superuser or root
rm filename
Deletes a file
man
Gives help information on a command
history
Gives a list of all past commands typed in the current terminal session
clear
Clears the terminal
mkdir directoryname
Creates a new directory in the present working directory or a at the specified path
rmdir
Deletes a directory
mv
Renames a directory
Basic Linux Commands
Administration Commands in Linux
Command
Description
whoami
See which user you are currently logged in as
sudo
Execute a command with root permissions
sudo apt install
Install a package on Debian based systems
sudo dnf install
Install a package on Red Hat based systems
sudo apt remove
Remove a package on Debian based systems
sudo dnf remove
Remove a package on Red Hat based systems
reboot
Reboot the system
poweroff
Shut down the system
Administration Commands in Linux
View, Create, Edit, and Delete Files and Directories in Linux
Command
Description
mkdir
Create a new directory
touch
Create a new, empty file, or update the modified time of an existing one
cat > file
Create a new file with the text you type after
cat file
View the contents of a file
grep
View the contents of a file that match a pattern
nano file
Open a file (or create new one) in nano text editor
vim file
Open a file (or create new one) in vim text editor
rm or rmdir
Remove a file or empty directory
rm -r
Remove a directory that isn’t empty
mv
Move or rename a file or directory
cp
Copy a file or directory
rsync
Synchronize the changes of one directory to another
View, Create, Edit, and Delete Files and Directories in Linux
Find and Locate Files in Linux
Command
Description
locate
Quickly find a file or directory that has been cached
find
Seach for a file or directory based on name and other parameters
Find and Locate Files in Linux
File Permission commands in Linux
Command
Description
ls -l
to show file type and access permission
r
read permission
w
write permission
x
execute permission
-=
no permission
Chown user
For changing the ownership of a file/directory
Chown user:group filename
change the user as well as group for a file or directory
File Permission commands in Linux
Environment Variables commands in Linux
Command
Description
echo $VARIABLE
To display value of a variable
env
Displays all environment variables
VARIABLE_NAME= variable_value
Create a new variable
Unset
Remove a variable
export Variable=value
To set value of an environment variable
Environment Variables commands in Linux
Networking commands in Linux
Command
Description
SSH username@ip-address or hostname
login into a remote Linux machine using SSH
Ping hostname="" or =""
To ping and Analyzing network and host connections
dir
Display files in the current directory of a remote computer
cd "dirname"
change directory to “dirname” on a remote computer
put file
upload ‘file’ from local to remote computer
get file
Download ‘file’ from remote to local computer
quit
Logout
Networking commands in Linux
VI Editing Commands in Linux
Command
Description
i
Insert at cursor (goes into insert mode)
a
Write after cursor (goes into insert mode)
A
Write at the end of line (goes into insert mode)
ESC
Terminate insert mode
u
Undo last change
U
Undo all changes to the entire line
o
Open a new line (goes into insert mode)
dd
Delete line
3dd
Delete 3 lines
D
Delete contents of line after the cursor
C
Delete contents of a line after the cursor and insert new text. Press ESC key to end insertion.
dw
Delete word
4dw
Delete 4 words
cw
Change word
x
Delete character at the cursor
r
Replace character
R
Overwrite characters from cursor onward
s
Substitute one character under cursor continue to insert
S
Substitute entire line and begin to insert at the beginning of the line