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

Linux Command Reference, Cheat Sheet of Linux skills

file commands, compression, network and installation commands in linux

Typology: Cheat Sheet

2020/2021

Uploaded on 04/27/2021

anahitay
anahitay ๐Ÿ‡บ๐Ÿ‡ธ

4.7

(16)

255 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Linux Command Reference
File Commands
ls โ€“ directory listing
ls -al โ€“ formatted listing with hidden fles
cd dir - change directory to dir
cd โ€“ change to home
pwd โ€“ show current directory
mkdir dir โ€“ create a directory dir
rm file โ€“ delete fle
rm -r dir โ€“ delete directory dir
rm -f file โ€“ force remove fle
rm -rf dir โ€“ force remove directory dir *
cp file1 file2 โ€“ copy fle1 to fle2
cp -r dir1 dir2 โ€“ copy dir1 to dir2; create dir2 if it
doesn't exist
mv file1 file2 โ€“ rename or move fle1 to fle2
if fle2 is an existing directory, moves fle1 into
directory fle2
ln -s file link โ€“ create symbolic link link to fle
touch file โ€“ create or update fle
cat > file โ€“ places standard input into fle
more file โ€“ output the contents of fle
head file โ€“ output the frst 10 lines of fle
tail file โ€“ output the last 10 lines of fle
tail -f file โ€“ output the contents of fle 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 fle
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 fles
grep -r pattern dir โ€“ search recursively for
pattern in dir
command | grep pattern โ€“ search for pattern in the
output of command
locate file โ€“ fnd all instances of fle
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
fle.tar containing fles
tar xf file.tar โ€“ extract the fles from fle.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 fle and renames it to
fle.gz
gzip -d file.gz โ€“ decompresses fle.gz back to
fle
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 fle
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 Linux Command Reference and more Cheat Sheet Linux skills in PDF only on Docsity!

Linux Command Reference

File Commands

ls โ€“ directory listing ls -al โ€“ formatted listing with hidden fles cd dir - change directory to dir cd โ€“ change to home pwd โ€“ show current directory mkdir dir โ€“ create a directory dir rm file โ€“ delete fle rm -r dir โ€“ delete directory dir rm -f file โ€“ force remove fle rm -rf dir โ€“ force remove directory dir * cp file1 file2 โ€“ copy fle1 to fle cp -r dir1 dir2 โ€“ copy dir1 to dir2 ; create dir2 if it doesn't exist mv file1 file2 โ€“ rename or move fle1 to fle if fle2 is an existing directory, moves fle1 into directory fle ln -s file link โ€“ create symbolic link link to fle touch file โ€“ create or update fle cat > file โ€“ places standard input into fle more file โ€“ output the contents of fle head file โ€“ output the frst 10 lines of fle tail file โ€“ output the last 10 lines of fle tail -f file โ€“ output the contents of fle 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 fle 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 fles grep -r pattern dir โ€“ search recursively for pattern in dir command | grep pattern โ€“ search for pattern in the output of command locate file โ€“ fnd all instances of fle

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 fle.tar containing fles tar xf file.tar โ€“ extract the fles from fle.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 fle and renames it to fle.gz gzip -d file.gz โ€“ decompresses fle.gz back to fle

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 fle 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.