Linux command cheat sheet

13 May 2023 5 minutes Author: Lady Liberty

Linux cheat sheet: commands for beginners

Terminal and text commands are the main way to control the Linux operating system, especially when it comes to the server. Although the word “terminal” scares beginners, believe me, everything is much simpler. Today we have prepared a cheat sheet with basic commands for you – bookmark it and increase your productivity hundreds of times. A command is the name of a program that a user enters in the terminal to perform a specific task. Commands can have additional data and parameters.
Sometimes it is difficult to recall some Linux terminal commands, and it is a good practice to save them on your computer or on paper as a cheat sheet. This list is not exhaustive, but it contains the most commonly used commands. Linux commands can seem intimidating at first glance if you are not used to using a terminal. There are many commands to perform operations and processes on a Linux system. Whether you’re new to Linux or an experienced user, having a list of common commands at your fingertips will be helpful.This guide will provide you with commonly used Linux commands with syntax and examples.

You can keep this Linux command cheat sheet on your desk. We are confident that you will quickly master these commands if you have just recently started learning them, and you will soon become a Linux expert. Commands are divided into different sections depending on their use. Links to the PDF and PNG versions of this cheat sheet are at the end of the post. We’ve grouped the Linux commands in the following sections for easier understanding. At first glance, the list may seem very difficult to memorize, but memorization comes with practice! The more often you use certain commands, the faster you will memorize them.

Basic Linux commands

ls

Lists with all files  in the current directory

ls -R

Also shows files in subdirectories

ls -a

Also displays hidden files

ls -al

Lists files and directories with detailed information

cd or cd ~

Go to the HOME directory

cd ..

Move up a level

cd

To navigate to a specific directory

cd /

Switch to the root directory

cat > filename

Create a new file

cat filename

Displays the contents of the file

cat file1 file2 > file3

Combines two files and saves the result

mv file “new file path”

Moves files to a new location

new_file_name

Renames a file to a new name

sudo

Allows users to run programs with root

rm filename

Delete a file

man

Provides background information about the team

history

Provides a list of all previous commands

clear

Cleaning the terminal

mkdir directoryname

Creates a new directory in the current

rmdir

Delete a catalog

mv

Rename the catalog

pr -x

Splits a file into x columns

pr -h

Assigns a file header

pr -n

Marks the file with line numbers

lp -nc , lpr c

Prints “c” copies of a file

lp-d lp-P

Specifies the name of the printer

apt-get

Command to install and update packages

mail -s ‘subject’

Command to send an email

mail -s “Subject”

Command to send an email with an attachment

Permission commands for files

ls -l

To show the file type and access rights

r

Permission to view

w

Permission to record

x

Execute the authorization

-=

No authorization

Chown user

To change the ownership of a file/directories

Chown user:group filename

change the user and group for a file or directory

Team Change environment

echo $VARIABLE

To display the change value

env

Displays all environmental variables

VARIABLE_NAME= variable_value

Create a new variable

Unset

Deleting a variable

export Variable=value

Set the value of the environment variable

User management commands in linux

sudo adduser username

Add a new user

sudo passwd -l ‘username’

Change user password

sudo userdel -r ‘username’

Change user password

sudo usermod -a -G GROUPNAME USERNAME

Add a user to a group

sudo deluser USER GROUPNAME

Change the directory to “dirname”

finger

Shows information about all users

finger username

Provides information about a specific user

Command to connect to the network

SSH username@ip-address or hostname

Log in to a remote Linux machine via SSH

Ping hostname=”” or =””

Ping and analyze network

dir

Display files in the current directory r

cd “dirname”

Change the directory to “dirname”

put file

Download a “file” from a local to a remote computer

get file

Download a “file” from a remote

quit

Log out of the system

Command for processing

bg

Switching a process to the background

fg

Starting a stopped process in the foreground

top

Detailed information about all active processes

ps

Display the status of processes

ps PID

Provides status to a specific process

pidof

Gives the process identifier (PID) of the process

kill PID

Killing the process

nice

Starts a process with a specified priority

renice

Changes the priority of an already running process

df

Provides free hard disk space on your system

free

Provides free RAM on your system

VI Commands for editing

i

Paste with cursor

a

Write after the cursor

A

Write at the end of the line

ESC

End insert mode

u

Undo the last change

U

Undo all changes for the entire row

o

Open a new line (switches to insert mode)

dd

Delete a line

3dd

Delete 3 lines

D

Delete the contents of a string after the cursor

C

Delete the contents of the line after the cursor

dw

Delete the word

4dw

Delete 4 words

cw

Change the word

x

Delete a character near the cursor

r

Replace a character

R

Overwrite characters starting with the cursor

s

Replace one character under the cursor

S

Replace the entire line and start inserting

~

Change the case of a single character

Other related articles
Found an error?
If you find an error, take a screenshot and send it to the bot.