Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Unix/Linux Command Reference Cheat Sheet, Cheat Sheet of Operating Systems

In this one page cheat sheet you have the Unix/Linux Command Reference: File Commands, Process Management, SSH, Shortcuts, and so on.

Typology: Cheat Sheet

2019/2020

Uploaded on 10/23/2020

ehimay
ehimay ๐Ÿ‡บ๐Ÿ‡ธ

4.8

(20)

268 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Unix/Linux Command Reference .com
File Commands
ls โ€“ directory listing
ls -al โ€“ formatted listing with hidden files
cd dir - change directory to dir
cd โ€“ change to home
pwd โ€“ show current directory
mkdir dir โ€“ create a directory dir
rm file โ€“ delete file
rm -r dir โ€“ delete directory dir
rm -f file โ€“ force remove file
rm -rf dir โ€“ force remove directory dir *
cp file1 file2 โ€“ copy file1 to file2
cp -r dir1 dir2 โ€“ copy dir1 to dir2; create dir2 if it
doesn't exist
mv file1 file2 โ€“ rename or move file1 to file2
if file2 is an existing directory, moves file1 into
directory file2
ln -s file link โ€“ create symbolic link link to file
touch file โ€“ create or update file
cat > file โ€“ places standard input into file
more file โ€“ output the contents of file
head file โ€“ output the first 10 lines of file
tail file โ€“ output the last 10 lines of file
tail -f file โ€“ output the contents of file as it
grows, starting with the last 10 lines
Process Management
ps โ€“ display your currently active processes
top โ€“ display all running processes
kill pid โ€“ kill process id pid
killall proc โ€“ kill all processes named proc *
bg โ€“ lists stopped or background jobs; resume a
stopped job in the background
fg โ€“ brings the most recent job to foreground
fg n โ€“ brings job n to the foreground
File Permissions
chmod octal file โ€“ change the permissions of file
to octal, which can be found separately for user,
group, and world by adding:
โ—4 โ€“ read (r)
โ—2 โ€“ write (w)
โ—1 โ€“ execute (x)
Examples:
chmod 777 โ€“ read, write, execute for all
chmod 755 โ€“ rwx for owner, rx for group and world
For more options, see man chmod.
SSH
ssh user@host โ€“ connect to host as user
ssh -p port user@host โ€“ connect to host on port
port as user
ssh-copy-id user@host โ€“ add your key to host for
user to enable a keyed or passwordless login
Searching
grep pattern files โ€“ search for pattern in files
grep -r pattern dir โ€“ search recursively for
pattern in dir
command | grep pattern โ€“ search for pattern in the
output of command
locate file โ€“ find all instances of file
System Info
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 information about user
uname -a โ€“ show kernel information
cat /proc/cpuinfo โ€“ cpu information
cat /proc/meminfo โ€“ memory information
man command โ€“ show the manual for command
df โ€“ show disk usage
du โ€“ show directory space usage
free โ€“ show memory and swap usage
whereis app โ€“ show possible locations of app
which app โ€“ show which app will be run by default
Compression
tar cf file.tar files โ€“ create a tar named
file.tar containing files
tar xf file.tar โ€“ extract the files from file.tar
tar czf file.tar.gz files โ€“ create a tar with
Gzip compression
tar xzf file.tar.gz โ€“ extract a tar using Gzip
tar cjf file.tar.bz2 โ€“ create a tar with Bzip2
compression
tar xjf file.tar.bz2 โ€“ extract a tar using Bzip2
gzip file โ€“ compresses file and renames it to
file.gz
gzip -d file.gz โ€“ decompresses file.gz back to
file
Network
ping host โ€“ ping host and output results
whois domain โ€“ get whois information for domain
dig domain โ€“ get DNS information for domain
dig -x host โ€“ reverse lookup host
wget file โ€“ download file
wget -c file โ€“ continue a stopped download
Installation
Install from source:
./configure
make
make install
dpkg -i pkg.deb โ€“ install a package (Debian)
rpm -Uvh pkg.rpm โ€“ install a package (RPM)
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
* use with extreme caution.

Partial preview of the text

Download Unix/Linux Command Reference Cheat Sheet and more Cheat Sheet Operating Systems in PDF only on Docsity!

Unix/Linux Command Reference

.com

File Commands

ls โ€“ directory listing ls -al โ€“ formatted listing with hidden files cd dir - change directory to dir cd โ€“ change to home pwd โ€“ show current directory mkdir dir โ€“ create a directory dir rm file โ€“ delete file rm -r dir โ€“ delete directory dir rm -f file โ€“ force remove file rm -rf dir โ€“ force remove directory dir * cp file1 file2 โ€“ copy file1 to file cp -r dir1 dir2 โ€“ copy dir1 to dir2 ; create dir2 if it doesn't exist mv file1 file2 โ€“ rename or move file1 to file if file2 is an existing directory, moves file1 into directory file ln -s file link โ€“ create symbolic link link to file touch file โ€“ create or update file cat > file โ€“ places standard input into file more file โ€“ output the contents of file head file โ€“ output the first 10 lines of file tail file โ€“ output the last 10 lines of file tail -f file โ€“ output the contents of file as it grows, starting with the last 10 lines

Process Management

ps โ€“ display your currently active processes top โ€“ display all running processes kill pid โ€“ kill process id pid killall proc โ€“ kill all processes named proc * bg โ€“ lists stopped or background jobs; resume a stopped job in the background fg โ€“ brings the most recent job to foreground fg n โ€“ brings job n to the foreground

File Permissions

chmod octal file โ€“ change the permissions of file to octal , which can be found separately for user, group, and world by adding: โ— 4 โ€“ read (r) โ— 2 โ€“ write (w) โ— 1 โ€“ execute (x) Examples: chmod 777 โ€“ read, write, execute for all chmod 755 โ€“ rwx for owner, rx for group and world For more options, see man chmod.

SSH

ssh user@host โ€“ connect to host as user ssh -p port user@host โ€“ connect to host on port port as user ssh-copy-id user@host โ€“ add your key to host for user to enable a keyed or passwordless login

Searching

grep pattern files โ€“ search for pattern in files grep -r pattern dir โ€“ search recursively for pattern in dir command | grep pattern โ€“ search for pattern in the output of command locate file โ€“ find all instances of file

System Info

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 information about user uname -a โ€“ show kernel information cat /proc/cpuinfo โ€“ cpu information cat /proc/meminfo โ€“ memory information man command โ€“ show the manual for command df โ€“ show disk usage du โ€“ show directory space usage free โ€“ show memory and swap usage whereis app โ€“ show possible locations of app which app โ€“ show which app will be run by default

Compression

tar cf file.tar files โ€“ create a tar named file.tar containing files tar xf file.tar โ€“ extract the files from file.tar tar czf file.tar.gz files โ€“ create a tar with Gzip compression tar xzf file.tar.gz โ€“ extract a tar using Gzip tar cjf file.tar.bz2 โ€“ create a tar with Bzip compression tar xjf file.tar.bz2 โ€“ extract a tar using Bzip gzip file โ€“ compresses file and renames it to file.gz gzip -d file.gz โ€“ decompresses file.gz back to file

Network

ping host โ€“ ping host and output results whois domain โ€“ get whois information for domain dig domain โ€“ get DNS information for domain dig -x host โ€“ reverse lookup host wget file โ€“ download file wget -c file โ€“ continue a stopped download

Installation

Install from source: ./configure make make install dpkg -i pkg.deb โ€“ install a package (Debian) rpm -Uvh pkg.rpm โ€“ install a package (RPM)

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

  • use with extreme caution.