Linux Command Line Cheat Sheet, Cheat Sheet of Linux skills

Typology: Cheat Sheet

2020/2021

Uploaded on 04/27/2021

amoda
amoda šŸ‡ŗšŸ‡ø

4.1

(13)

257 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Linux Command Line Cheat Sheet
More nano info at:
http://www.nano-e ditor.org/docs.php
Bash Comma nds
uname -a Show system and kernel
head -n1 /etc/issue Show distri bution
mount Show moun ted filesystems
date Show system date
uptime Show uptim e
whoami Show your u sername
man comman d Show manual for command
Bash Shortcuts
CTRL-c Stop current comma nd
CTRL-z Sleep pro gram
CTRL-a Go to start of line
CTRL-e Go to end of line
CTRL-u Cut from start of line
CTRL-k Cut to end of line
CTRL-r Search histo ry
!! Repea t last command
!abc Run last comman d starting with abc
!abc:p Print last command starting wi th abc
!$ Last argume nt of previou s command
!* All arguments of previo us command
^abc^123 Run previou s command, replacin g abc
with 123
Bash Variables
env Show envi ronment variable s
echo $NAME Output value of $NAME
variabl e
export
NAME =value
Set $NAME to val ue
$PATH Executable search path
$HOME Home dire ctory
$SHELL Current shel l
IO Redirection
command < file Read inp ut of command from
file
command > file Write output of command to file
command >
/dev/null
Discard ou tput of command
command >> file Append output to file
command1 |
command2
Pipe outpu t of command1 to
command2
Directory Opera tions
pwd Show curre nt directory
mkdir dir Ma ke directory dir
cd dir Cha nge directory to dir
cd .. Go up a directory
ls L ist files
ls Options
-a Show all (including hi dden)
-R R ecursive list
-r Reve rse order
-t Sor t by last modified
-S Sort by file size
-l Long li sting format
-1 One file per li ne
-m Comma-se parated output
-Q Quoted output
Search Files
grep pattern
files
Search for pattern in files
grep -i Case insensiti ve search
grep -r Recu rsive search
grep -v Inverted search
find /dir/ -
name name*
Find files starting with name in dir
find /dir/ -user
name
Find files ow ned by name in dir
find /dir/ -
mmin num
Find files mod ifed less than num
minutes ago in dir
wherei s
command
Find bina ry / source / manual for
command
locate file Fin d file (qui ck search of system
index)
File Operations
touch file1 Cr eate file1
cat file1
file2
Concatenate files and output
less file1 View and paginate file1
file file1 Get type of file1
cp file1 file2 C opy file1 to file2
mv file1 file2 Mo ve file1 to file2
rm file1 Dele te file1
head file1 Show first 10 lin es of file1
tail file1 Sho w last 10 lines of file1
tail -f file1 Ou tput last line s of file 1 as it
changes
Process Ma nagement
ps Show snap shot of processes
top Show real time proce sses
kill pid Kill proce ss with id pid
pkill
name
Kill proce ss with name name
killall
name
Kill all processes with names be ginning
name
Nano Shortcuts
Files
Ctrl-R Read file
Ctrl-O Save file
Ctrl-X Close file
Cut and Paste
ALT-A Start marking text
CTRL-K Cut marked text or line
CTRL-U Paste text
Navigate File
ALT-/ En d of file
CTRL-A Beginni ng of line
CTRL-E End of line
CTRL-C Show line num ber
CTRL-_ Go to line number
Search File
CTRL-W Find
ALT-W Fin d next
CTRL-\ Search an d replace
Screen Shortcuts
screen Start a screen session .
screen -r Resume a scre en session.
screen -
list
Show your cu rrent screen sessions.
CTRL-A Activate command s for screen.
CTRL-A c Create a ne w instance of terminal.
CTRL-A n Go to the next instance of terminal .
CTRL-A p Go to the previous instan ce of terminal .
CTRL-A " S how current instances of termin als.
CTRL-A A Rename the current in stance of
terminal.
File Permissions
chmod 775 file Change mode of file to 775
chmod -R 60 0
folder
Recursive ly chmod folder to 600
chown
user :group file
Change file owner to user an d
group to group
File Permission Numbers
The first digit is the own er permission, the secon d
the group and the third for everyone.
Calcul ate each of the three permissio n digits by
addin g the numeric values of the pe rmissions below .
4 read (r)
2 write (w)
1 execute (x)

Partial preview of the text

Download Linux Command Line Cheat Sheet and more Cheat Sheet Linux skills in PDF only on Docsity!

Linux Command Line Cheat Sheet

More nano info at: http://www.nano-editor.org/docs.php

Bash Commands

uname -a Show system and kernel

head -n1 /etc/issue Show distribution

mount Show mounted filesystems

date Show system date

uptime Show uptime

whoami Show your username

man command Show manual for command

Bash Shortcuts

CTRL-c Stop current command

CTRL-z Sleep program

CTRL-a Go to start of line

CTRL-e Go to end of line

CTRL-u Cut from start of line

CTRL-k Cut to end of line

CTRL-r Search history

!! Repeat last command

!abc Run last command starting with abc

!abc:p Print last command starting with abc

!$ Last argument of previous command

!* All arguments of previous command

^abc^ 123 Run previous command, replacing abc with 123

Bash Variables

env Show environment variables

echo $NAME Output value of $NAME variable

export NAME =value

Set $NAME to value

$PATH Executable search path

$HOME Home directory

$SHELL Current shell

IO Redirection

command < file Read input of command from file

command > file Write output of command to file

command > /dev/null

Discard output of command

command >> file Append output to file

command1 | command

Pipe output of command1 to command

Directory Operations

pwd Show current directory

mkdir dir Make directory dir

cd dir Change directory to dir

cd .. Go up a directory

ls List files

ls Options

-a Show all (including hidden) -R Recursive list -r Reverse order -t Sort by last modified -S Sort by file size -l Long listing format -1 One file per line -m Comma-separated output -Q Quoted output

Search Files grep pattern files

Search for pattern in files

grep -i Case insensitive search grep -r Recursive search grep -v Inverted search find /dir/ - name name*

Find files starting with name in dir

find /dir/ -user name

Find files owned by name in dir

find /dir/ - mmin num

Find files modifed less than num minutes ago in dir whereis command

Find binary / source / manual for command locate file Find file (quick search of system index)

File Operations touch file1 Create file cat file file

Concatenate files and output

less file1 View and paginate file file file1 Get type of file cp file1 file2 Copy file1 to file mv file1 file2 Move file1 to file rm file1 Delete file head file1 Show first 10 lines of file tail file1 Show last 10 lines of file tail -f file1 Output last lines of file1 as it changes

Process Management ps Show snapshot of processes top Show real time processes kill pid Kill process with id pid pkill name

Kill process with name name

killall name

Kill all processes with names beginning name

Nano Shortcuts

Files Ctrl-R Read file Ctrl-O Save file Ctrl-X Close file Cut and Paste ALT-A Start marking text CTRL-K Cut marked text or line CTRL-U Paste text Navigate File ALT-/ End of file CTRL-A Beginning of line CTRL-E End of line CTRL-C Show line number CTRL-_ Go to line number Search File CTRL-W Find ALT-W Find next CTRL-\ Search and replace

Screen Shortcuts screen Start a screen session. screen -r Resume a screen session. screen - list

Show your current screen sessions.

CTRL-A Activate commands for screen. CTRL-A c Create a new instance of terminal. CTRL-A n Go to the next instance of terminal. CTRL-A p Go to the previous instance of terminal. CTRL-A " Show current instances of terminals. CTRL-A A Rename the current instance of terminal.

File Permissions chmod 775 file Change mode of file to 775 chmod -R 600 folder

Recursively chmod folder to 600

chown user :group file

Change file owner to user and group to group

File Permission Numbers The first digit is the owner permission, the second the group and the third for everyone. Calculate each of the three permission digits by adding the numeric values of the permissions below. 4 read (r) 2 write (w) 1 execute (x)