Show Menu

Basic Linux Commands Cheat Sheet by

Basic Linux command you should know
development     programming     linux

File Commands

ls – directory listing
ls -al – formatted listing with hidden files
cd [dire­ctory] - change directory to directory
pwd – Print Working Directory
mkdir [dire­ctory] – create a directory named directory
rm [file­_name] – delete filename
rm -r [dire­ctory] – delete directory recurs­ively
rm -f [file­_name] – force remove file
rm -rf [dire­ctory] – force remove directory directory recurs­ively * Use with care
cp [file1 file2] – copy file1 to file2
mv [file1 file2] – rename or move file1 to file2
ln -s [file­_name link] – create symbolic link to file
touch [file­_name] – create or update file
cat > [file­_name] – places standard input into file
more [file­_name] – output the contents of file
head [file­_name] – output the first 10 lines of file
tail [file­_name] – output the last 10 lines of file
tail -f [file­_name] – output the contents of file as it grows, starting with the last 10 lines
chmod [octal file_n­ame] change the permis­sions of file to octal

Compre­ssion

tar cf [file­_na­me.tar files] – create a tar named file_n­ame.tar containing files
tar xf [file­_na­me.t­ar] – extract the files from file_n­ame.tar
tar czf [file­_na­me.t­ar.gz files] – create a tar file with Gzip compre­ssion
tar xzf [file­_na­me.t­ar.gz] – extract a tar using Gzip
tar xjf [file­_na­me.t­ar.bz2] – extract a tar using Bzip2
gzip [file­_name] – compresses file and renames it to file_n­ame.gz
gzip -d [file­_na­me.gz] – decomp­resses file_n­ame.gz back to file
 

System Inform­ation

date – show the current date and time
cal – show this month's calendar
uptime – show current uptime
w – display who is online
whoami – who you are logged in as
finger user – display inform­ation about user
uname -a – show kernel inform­ation
cat /proc/­cpuinfo – cpu inform­ation
cat /proc/­meminfo – memory inform­ation
man command – show the manual for command
df – show disk usage
du – show directory space usage
free – show memory and swap usage
whereis [appl­ica­tio­n_n­ame] – show possible locations of binary, source, and manual page files for a command
which [appl­ica­tio­n_n­ame] – show which applic­ation will be run by default

Searching

grep [pattern files] – search for pattern in files
grep -r [pattern direct­ory] – search recurs­ively for pattern in directory
[comm­and] | grep [patt­ern] – search for pattern in the output of command
locate [file­_name] – find all instances of file
 

Process Management

ps – (Process Status) displays your currently active processes
top – (Table of Processes) display all running processes
kill [pid] – kill process id pid
killall [proc­ess­_name] – kill all processes named [proce­ss_­name]
bg – lists stopped or background jobs; resume background job
fg – brings the most recent job to foreground
fg [n] – brings job id to the foreground

Network

ping [host] – ping host and output results
whois [domain] – get whois inform­ation for domain
dig [domain] – get DNS inform­ation for domain
dig -x [host] – reverse lookup host
wget [file at URL] – download file from URL
wget -c [file at URL] – continue a stopped download
ssh [user­@host] – connect to host as user
ssh -p [port user@h­ost] – connect to host on port port as user
ssh-co­py-id [user­@host] – add your key to host for user to enable a keyed or login without password

Shortcuts

Ctrl+C – halts the current command
Ctrl+Z – stops the current command; resume with fg in the foreground or bg in the background
Ctrl+D – log out of current session, similar to exit
Ctrl+W – erases one word in the current line
Ctrl+U – erases the whole line
Ctrl+R – type to bring up a recent command
!! - repeats the last command
exit – log out of current session

Download the Basic Linux Commands Cheat Sheet

2 Pages
//media.cheatography.com/storage/thumb/nexwebsites_basic-linux-commands.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

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

          Regular Expressions Cheat Sheet
          mod_rewrite Cheat Sheet