Linux Command Line Cheat Sheet

The most essential Linux commands
Keep this Linux cheat sheet on your desk printed,
it will help you to learn them quick and become a Linux expert very soon.
Click on the image to open at full size
linux commands list

File Commands
1) The ls Linux command lists files and directories within the current working directory.
ls - directory listing ls -al - formatted listing with hidden files
2) The cd Linux command changes the current directory in Linux and can toggle between directories conveniently.
cd dir - change directory to dir cd - change to home
3) The pwd Linux command (print working directory) command displays the name of the current working directory.
pwd - show current directory
4) The mkdir (make directory) command is used to make a new directory.
mkdir dir - create directory dir

5) rm (short for remove) is a Unix / Linux command which is used to delete files from a filesystem.
rm file - delete file rm -r dir - delete directory dir rm -f file - force remove file rm -rf dir - remove directory dir
6) The cp command is used to copies files and directories
cp file1 file2 - copy file1 to file2
7) mv (short for move) is a Unix command that moves one or more files or directories from one place to another.
mv file1 file2 - move file1 to file2
8) The link command creates a hard link named FILE2 which shares the same index node as the existing file FILE1. Since FILE1 and FILE2 share the same index node, they will point to the same data on the disk, and modifying one will be functionally the same as modifying the other.
ln -s file link - create symbolic link "link" to file
9) The touch command updates the access and modification times of each FILE to the current system time.
If you specify a FILE that does not already exist, touch creates an empty file with that name unless the -c or -h options are specified
touch file - create or update file
10) cat  command It has three related functions with regard to text files: displaying them, combining copies of them and creating new ones.
cat > file - place standard input into file
11) more is a filter for paging through text one screen at a time.
more file - output the contents of the file
12) The less command lets an admin scroll through configuration and error log files, displaying text files one screen at a time, with backward or forward moving available in files.
less file - output the contents of the file
head file - output first 10 lines of file tail -f file - output contents of file as it grows
(SSH client) is a program for logging into a remote machine and for
     executing commands on a remote machine, It is intended to replace rlogin
     and rsh, and provide secure encrypted communications between two
     untrusted hosts over an insecure network.
ssh user@host - connet tto host as user ssh -P port user@host - connet using port p ssh -D port user@host - connet and use bind port
Installing from source works on any GNU/Linux system that has the compiler and related tools and libraries, follows this route once you have a source package:

Unpack the archive and cd to its base directory.
Run the configure script ./configure
Compile the software make
Install the software make install

./configure make make install
1) ping is a simple way to send network data to, and receive network data from, another computer on a network. It is frequently used to test, at the most basic level, whether another system is reachable over a network, and if so, how much time it takes for that data to be exchanged
Ping host - ping host 'host'
2) whois searches for an object in a WHOIS database. WHOIS is a query and response protocol that is widely used for querying databases that store the registered users of an Internet resource, such as a domain name or an IP address block, but is also used for a wider range of other information.
whois domain - get whos for domain
3) The command dig is a tool for querying DNS nameservers for information about host addresses, mail exchanges, nameservers, and related information. This tool can be used from any Linux (Unix) or Macintosh OS X operating system. The most typical use of dig is to simply query a single host.
dig dig -x host - reverse lookup host
4) wget is a free utility for non-interactive download of files from the web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.

wget file - download file wget -c file - continue stopped download wget -r url - recursively download file from url

System info

1) The date command is used to print out, or change the value of, the system's time and date information.
date - show current date/time
2) Display a conveniently-formatted calendar from the command line.
cal - show this month's calendar
3) uptime tells you how long the system has been running.
uptime - show uptime
4) The w command is a quick way to see who is logged on and what they are doing.
w - display who is online
5) This command prints the username associated with the current effective user ID
whoami - who are you logged in as
6) Print information about the current system
uname -a - show kernel config
7) Show / check cpu information on Linux
cat /proc/cpuinfo - cpu info
8) show/check memory information on Linux
cat /proc/meminfo - memory information
10) On Linux and other Unix-like operating systems, man is the interface used to view the system's reference manuals.
man command - show manual for command
11)The df command reports the amount of available disk space being used by file systems
df - show disk usage
12) du command estimates and displays the disk space used by files.
du - show directory space usage du -sh - human readable size in GB
13) Linux free- Command Displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel
free- show memory and swap usage
14) Linux whereis app command Locates the binary, source, and manual page files for a command.
whereis app - show possible locations of app
15) linux command which app
which app - show which app will be run by default


1) grep linux command : grep, which stands for "global regular expression print," processes text line by line and prints any lines which match a specified pattern
grep pattern files - search for pattern in files
grep -r pattern dir - search recursively for pattern in dir
locate file - find all instances of file

Process Managment

1) ps displays information about a selection of the active processes.
ps - display currently active processes ps aux - ps with alot of detail
2) kill is used to send a signal to a process
kill pid - kill process with pid "pid" kill all proc - kill all processes named proc
3) bg is a job control command that resumes suspended jobs while keeping them running in the background.
bg - lists stopped/background jobs, resume stopped jobs in the background
4) the fg command continues a stopped job by running it in the foreground
fg - bring most recent job to foreground fg n - brings job n to foreground

File Permissions

Linux chmod command is used to change the permissions of files or directories
chmod octal file - change permission of file
4 - read (r) 2 - write (w) 1 - execute (x) order: pwmer/ ex: chmod 777 - rwx for everyone chmod 755 - rw for owner, rx for group/world


1) The tar program is used to create, maintain, modify, and extract files that are archived in the tar format
tar cf file.tar files - tar files into file.tar tar xf file.tar - untar into current directory tar tf file.tar - show contents of archive
tar flags:
c - create archive
t - table of contents
x - extract
f - specifules filename
z - use zip/gzip
j - bzip2 compression
k - do not overwrite
T - files from file
w - ask for confirmation
V - verbose

2) Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times.
gzip file - compress file and rename to file.gz
gzip -d file.gz - decompress file.gz


ctrl+c halts current command ctrl+z stops current command fg - resume stopped command in foreground bg - resume stopped command in background ctrl+d - log out of current session ctrl+w - erases one word in current session ctrl+u - erases whole lne ctrl+r - reverse lookup of previous commands !! - report last command exit - log out of current session

VIM quitting

:x - exit, saving changes :wq - exit, saving changes :q - exit, if no changes :q! - exit, ignore changes

inserting text

i - insert before cursor I - insert before line a - append after cursor A - append after line o - open new line after cur line O - open new line before cur line r - replace one character R - replace many characters


h - move left j - move down k - move up l - move right w - move to next word W - move to next blank delimited word b - move to beginning of the word B - move to beginning of blank delimited word e - move to end of word E - move to end of blank delimited word ( - move a sentence background ) - move a sentence forward { - move paragraph back } - move paragraph forward $ - move to end of line nG - move to nth line of file :n - move to nth line of file G - move to last line of file fc - move forward to 'c' Fc - move backward to 'c' H - move to top of screen M - move to middle of screen L - move to bottom of screen % - move to associated (),{},[]

deleting text

x - delete character to the right X - delete character to the left D - delete to the end of line dd - delete current line :d - delete current line


/string - search forward for string ?string - search back for string n - search for next instance of string N - for for previos instance of string


:s/pattern/string/flags - replace pattern with string, according to flags g - flag, replace all occurences c - flag, confirm replaces & - repoat last :s command files :w file - write to file :r file - read file in after line :n - go to next file :p go to previous file :e file - edit file !!cmd - replace line with output of cmd other u - undo last change U - undo all changes to line
Leave a Comment if you like it :)
bash commands

August 4, 2016


Post a Comment


Popular Posts

USB WiFi adapters that support monitor mode and wireless injection

usb wifi adapter with monitor mode and wireless injection (100% compatibl…

how to update Kali Linux and Fix update error

Kali Linux one of the best Linux distro for penetration testing it's freq…

Fix Kali Linux sources.list Repositories

Fix default repository First after installing a clean Kali Linux the sou…

Recent Comments

Contact Me