Show Menu
Cheatography

Basic linux commands

bash commands

uname -a
Show system and kernel info
date
Show system date
uptime
System uptime
whoami
Show current user
mount
Show mounted filesy­stems
man
Show manual for command

bash variables

env
Show enviro­nment variables
echo "­STR­ING­"
Output string
echo $NAME
Output value of NAME variable
export NAME = value
set "­value to NAME
$PATH
Executable search path
$HOME
Home directory
$SHELL
Current shell

directory operations

pwd
Shows present working directory
mkdir dirname
Make directory
cd dirname
Change directory
cd ..
Go to parent directory of current dir
ls
list files
 

ls options

-l
Long list
-a
Show all(hidden files too)
-R
Recursive order
-r
Reverse order
-t
Sort by last modified
-m
Comma separated output
-Q
Quoted output
-S
Sort by file size

file search methods

grep pattern files
Search for patter in files
grep -r
Recursive search
grep -i
Case insens­itive 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
locate file
Find file

file operations

touch file1
create file1
cat file1 file2
concat­enate file and output
file file1
get type of file1
cp file1 file2
Copy file1 to file2
mv file1 file2
Move file1 to file2
rm file1
Delete file1
head file1
show top 10 lines of file1
tail file1
show bottom 10 lines of file1
 

IO redire­ction

command < file
read input of command from file
command > file
write output to file
command >> file
Append output to file
command1 | command2
Pipe operator to output of command 1 to command 2

process management

ps
show 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 name name

file permis­sions

chown user:group file
Change file owner to user and group to group
chmod 777 file
Change mode of file to 777
The first digit is owner permis­sion,
the second is group and third is user
4
read(r)
2
write(w)
1
execute(x)
 

bash shortcuts

CTRL - c
Stop current comand
CTRL - z
Sleep program
CTRL - a
Go to start
CTRL - e
Go to end
CTRL - r
search history
!!
repeat last command
!abc
run last command starting with abc
!$
last argument of previous command
!*
all arguments of previous command
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Pocket Guide LINUX commands Cheat Sheet
          Common Commands Cheat Sheet
          Command Line and Terminal navigation Cheat Sheet