Sunteți pe pagina 1din 11

Command Description

apropos whatis
Show commands
pertinent to string. See
also threadsafe
man -t ascii | ps2pdf - > ascii.pdf
make a pdf of a manual
page
which command
Show full path name of
command
time command
See how long a
command takes
time cat
Start stopwatch. Ctrl-d
to stop. See also sw
dir navigation
cd -
Go to previous
directory
cd
Go to !"#$
directory
%cd dir && command'
Go to dir( e)ecute
command and return to
current dir
pushd .
*ut current dir on stack
so you can popd +ack
to it
file searching
alias l,-ls -l --color,auto- .uick dir listing
ls -lrt
/ist files +y date. See
also newest and find_mm_
yyyy
ls 0usr0+in | pr -12 -3C"/4#5S
*rint in 2 columns to
width of terminal
find -name -6.7ch8- | )args grep -$ -e)pr-
Search -e)pr- in this dir
and +elow. See
also findrepo
find -type f -print9 | )args -r9 grep -: -e)ample-
Search all regular files
for -e)ample- in this dir
and +elow
find -ma)depth ; -type f | )args grep -: -e)ample-
Search all regular files
for -e)ample- in this dir

find -ma)depth ; -type d | while read dir< do echo dir< echo
cmd2< done
*rocess each item with
multiple commands %in
while loop'
find -type f = -perm ->>>
:ind files not reada+le
+y all %useful for we+
site'
find -type d = -perm -;;; :ind dirs not accessi+le
+y all %useful for we+
site'
locate -r -file7?086@.t)t-
Search cached inde) for
names. 1his re is like
glo+ 6file6.t)t
look reference
Auickly search %sorted'
dictionary for prefi)
grep --color reference 0usr0share0dict0words
!ighlight occurances of
regular e)pression in
dictionary
archives and compression
gpg -c file $ncrypt file
gpg file.gpg Becrypt file
tar -c dir0 | +Cip2 > dir.tar.+C2
#ake compressed
archive of dir0
+Cip2 -dc dir.tar.+C2 | tar -)
$)tract archive %use
gCip instead of +Cip2
for tar.gC files'
tar -c dir0 | gCip | gpg -c | ssh userDremote -dd of,dir.tar.gC.gpg-
#ake encrypted
archive of dir0 on
remote machine

find dir0 -name -6.t)t- | tar -c --files-from,- | +Cip2 >
dirEt)t.tar.+C2
#ake archive of su+set
of dir0 and +elow

find dir0 -name -6.t)t- | )args cp -a --target-directory,dirEt)t0
--parents
#ake copy of su+set of
dir0 and +elow
% tar -c 0dir0to0copy ' | % cd 0where0to0 && tar -) -p '
Copy %with
permissions' copy0 dir
to 0where0to0 dir
% cd 0dir0to0copy && tar -c . ' | % cd 0where0to0 && tar -) -p '
Copy %with
permissions' contents
of copy0 dir to
0where0to0

% tar -c 0dir0to0copy ' | ssh -C userDremote -cd 0where0to0 &&
tar -) -p-
Copy %with
permissions' copy0 dir
to remoteF0where0to0 dir
dd +s,;# if,0dev0sda | gCip | ssh userDremote -dd of,sda.gC-
Gackup harddisk to
remote machine
rsync %5etwork efficient file copierF 4se the --dry-run option for testing'
rsync -* rsyncF00rsync.server.com0path0to0file file
"nly get diffs. Bo
multiple times for
trou+lesome downloads
rsync --+wlimit,;999 fromfile tofile
/ocally copy with rate
limit. Ht-s like nice for
H0"
rsync -aC -e ssh --delete I0pu+licEhtml0 #irror we+ site %using
remote.comF-I0pu+licEhtml-
compression and
encryption'

rsync -auC -e ssh remoteF0dir0 . && rsync -auC -e
ssh . remoteF0dir0
SynchroniCe current
directory with remote
one
ssh %Secure S!ell'
ssh 4S$JD!"S1 command
Jun command on
!"S1 as 4S$J
%default
command,shell'
ssh -f -K 4S$JD!"S15L#$ )eyes
Jun G4H command on
!"S15L#$ as
4S$J
scp -p -r 4S$JD!"S1F file dir0
Copy with permissions
to 4S$J-s home
directory on !"S1
scp -c arcfour 4S$JD/L5!"S1F +igfile
4se faster crypto for
local /L5. 1his might
saturate Gig$
ssh -g -/ M9M9FlocalhostFM9 rootD!"S1
:orward connections to
!"S15L#$FM9M9
out to !"S1FM9
ssh -J ;>N>FimapF;>N rootD!"S1
:orward connections
from !"S1F;>N> in to
imapF;>N
ssh-copy-id 4S$JD!"S1
Hnstall pu+lic key for
4S$JD!"S1 for
password-less log in
wget %multi purpose download tool'

%cd dir0 && wget -nd -p!$Ok


httpF00www.pi)el+eat.org0cmdline.html'
Store local +rowsa+le
version of a page to the
current dir
wget -c httpF00www.e)ample.com0large.file
Continue downloading
a partially downloaded
file
wget -r -nd -np -l; -L -6.Ppg- httpF00www.e)ample.com0dir0
Bownload a set of files
to the current directory
wget ftpF00remote0file7;-28.iso0
:1* supports glo++ing
directly

wget -. -"- httpF00www.pi)el+eat.org0timeline.html | grep -a


href- | head
*rocess output directly
echo -wget url- | at 9;F99
Bownload url at ;L#
to current dir
wget --limit-rate,29k url Bo a low priority
download %limit to
29KB/s in this case'
wget -nv --spider --force-html -i +ookmarks.html Check links in a file
wget --mirror httpF00www.e)ample.com0
$fficiently update a
local copy of a site
%handy from cron'
networking %5ote ifconfig( route( mii-tool( nslookup commands are obsolete'
ethtool eth9
Show status of ethernet
interface eth9
ethtool --change eth9 autoneg off speed ;99 duple) full
#anually set ethernet
interface speed
iw dev wlan9 link
Show link status of
wireless interface
wlan9
iw dev wlan9 set +itrates legacy-2.> ;
#anually set wireless
interface speed
iw dev wlan9 scan
/ist wireless networks
in range
ip link show /ist network interfaces
ip link set dev eth9 name wan
Jename interface eth9
to wan
ip link set dev eth9 up
Gring interface eth9 up
%or down'
ip addr show
/ist addresses for
interfaces
ip addr add ;.2.N.>02> +rd Q dev eth9
Ldd %or del' ip and
mask %2RR.2RR.2RR.9'
ip route show /ist routing ta+le
ip route add default via ;.2.N.2R>
Set default gateway to
;.2.N.2R>
ss -tupl
/ist internet services on
a system
ss -tup
/ist active connections
to0from system
host pi)el+eat.org
/ookup B5S ip address
for name or vice versa
hostname -i
/ookup local ip address
%e.uivalent to host
ShostnameS'
whois pi)el+eat.org
/ookup whois info for
hostname or ip address
windows networking %5ote sam+a is the package that provides all this windows specific
networking support'
sm+tree
:ind windows
machines. See also
findsm+
nm+lookup -L ;.2.N.>
:ind the windows
%net+ios' name
associated with ip
address
sm+client -/ windowsE+o)
/ist shares on windows
machine or sam+a
server

mount -t sm+fs -o fmask,TTT(guest 00windowsE+o)0share
0mnt0share
#ount a windows share
echo -message- | sm+client -# windowsE+o)
Send popup to windows
machine %off +y default
in U* sp2'
text manipulation %5ote sed uses stdin and stdout. 5ewer versions support inplace
editing with the -i option'
sed -s0string;0string20g-
Jeplace string; with
string2
sed -s0@%.6@';0@;20g-
#odify anystring; to
anystring2
sed -0? 6V0d< 0? 60d-
Jemove comments and
+lank lines
sed -Fa< 0@@05< s0@@@n00< ta-
Concatenate lines with
trailing @
sed -s07 @t8600-
Jemove trailing spaces
from lines
sed -s0@%7SW@8@'0@@@;0g-
$scape shell
metacharacters active
within dou+le .uotes
se. ;9 | sed Ws0?0 0< s0 6@%.@XY(@Z@'0@;0W Jight align num+ers
se. ;9 | sed p | paste - - Buplicate a column
sed -n -;999Xp<.Z- *rint ;999th line
sed -n -;9(29p<29.- *rint lines ;9 to 29
sed -n -s0.6[title>@%.6@'[@0title>.60@;0ip<1<.-
$)tract title from
!1#/ we+ page
sed -i >2d I0.ssh0knownEhosts Belete a particular line
sort -t. -k;(;n -k2(2n -kN(Nn -k>(>n Sort H*\> ip addresses
echo -1est- | tr -7FlowerF8- -7FupperF8- Case conversion
tr -dc -7FprintF8- [ 0dev0urandom
:ilter non printa+le
characters
tr -s -7F+lankF8- -@t- [0proc0diskstats | cut -f>
cut fields separated +y
+lanks
history | wc -l Count lines
se. ;9 | paste -s -d - -
Concatenate and
separate line items to a
single line
set operations %5ote you can export LANG=C for speed. Llso these assume no duplicate
lines within a file'
sort file; file2 | uni. 4nion of unsorted files
sort file; file2 | uni. -d
Hntersection of unsorted
files
sort file; file; file2 | uni. -u
Bifference of unsorted
files
sort file; file2 | uni. -u
Symmetric
Bifference of unsorted
files
Poin -t-@9- -a; -a2 file; file2 4nion of sorted files
Poin -t-@9- file; file2
Hntersection of sorted
files
Poin -t-@9- -v2 file; file2
Bifference of sorted
files
Poin -t-@9- -v; -v2 file; file2
Symmetric Bifference
of sorted files
math
echo -%; Q s.rt%R''02- | +c -l
Auick math %Calculate
]'. See also bc
se. -f ->0^g- ; 2 22222 | paste -sd-Q | +c -l
Calculate _ the uni)
way
echo -pad,29< min,T>< %;996;9?T'0%%padQmin'6M'- | +c
#ore comple) %int' e.g.
1his shows ma) :ast$
packet rate
echo -pad,29< min,T>< print %;99$T'0%%padQmin'6M'- | python
*ython handles
scientific notation

echo -pad,29< plot 7T>F;R;M8 %;996;966T'0%%padQ)'6M'- |


gnuplot -persist
*lot :ast$ packet rate
vs packet siCe
echo -o+ase,;T< i+ase,;9< T>29T- | +c
Gase conversion
%decimal to
he)adecimal'
echo %%9)2dec''
Gase conversion %he) to
dec' %%shell arithmetic
e)pansion''
units -t -;99m0!"#s- -miles0hour-
4nit conversion %metric
to imperial'
units -t -R99GG- -GiG-
4nit conversion
%SH to H$C prefi)es'
units -t -; googol- Befinition lookup
se. ;99 | %tr -@n- Q< echo 9' | +c
Ldd a column of
num+ers. See
also add and f$ncpy
calendar
cal -N Bisplay a calendar
cal 2 ;YR2 Bisplay a calendar for a
particular month year
date -d fri
3hat date is it this
friday. See also day
7 %date -d -;2F99 Q; day- Q^d' , -9;- 8 || e)it
e)it a script unless it-s
the last day of the
month
date --date,-2R Bec- Q^L
3hat day does )mas
fall on( this year
date --date,-D2;>Y>MNT>Y-
Convert seconds since
the epoch %;2Y9-9;-9;
41C' to date
1`,-Lmerica0/osELngeles- date
3hat time is it on west
coast of 4S %use
tCselect to find 1`'
date --date,-1`,WLmerica0/osELngelesW 92F99 ne)t :ri-
3hat-s the local time
for 2L# ne)t :riday on
west coast 4S
locales
printf W^-d@nW ;2N>
*rint num+er with
thousands grouping
appropriate to locale
G/"COESH`$,@-; ls -l
4se locale thousands
grouping in ls. See
also l
echo WH live in Slocale territorySW
$)tract info from locale
data+ase
/L5G,enEH$.utfM locale intEprefi)
/ookup locale info for
specific country. See
also ccodes
locale -kc %locale | sed -n -s0@%/CE.@X>(@Z@',.60@;0p-' | less
/ist fields availa+le in
locale data+ase
recode %"+soletes iconv( dos2uni)( uni)2dos'
recode -l | less
Show availa+le
conversions %aliases on
each line'
recode windows-;2R2.. fileEtoEchange.t)t
3indows WansiW to
local charset %auto does
CJ/: conversion'
recode utf-M0CJ/:.. fileEtoEchange.t)t
3indows utfM to local
charset
recode iso-MMR2-;R..utfM fileEtoEchange.t)t
/atin2 %western europe'
to utfM
recode ..0+T> [ file.t)t > file.+T> GaseT> encode
recode 0.p.. [ file..p > file.t)t
Auoted printa+le
decode
recode ..!1#/ [ file.t)t > file.html 1e)t to !1#/
recode -lf windows-;2R2 | grep euro /ookup table of characters
echo -n 9)M9 | recode latin-20);..dump
Show what a code
represents in latin-2
charmap
echo -n 9)29LC | recode ucs-20)2..latin-20) Show latin-2 encoding
echo -n 9)29LC | recode ucs-20)2..utf-M0) Show utf-M encoding
CDs
gCip [ 0dev0cdrom > cdrom.iso.gC
Save copy of data
cdrom
mkisofs -\ /LG$/ -r dir | gCip > cdrom.iso.gC
Create cdrom image
from contents of dir
mount -o loop cdrom.iso 0mnt0dir
#ount the cdrom image
at 0mnt0dir %read only'
cdrecord -v dev,0dev0cdrom +lank,fast Clear a CBJ3
gCip -dc cdrom.iso.gC | cdrecord -v dev,0dev0cdrom -
Gurn cdrom image %use
dev,L1L*H -scan+us to
confirm dev'
cdparanoia -G
Jip audio tracks from
CB to wav files in
current dir
cdrecord -v dev,0dev0cdrom -audio -pad 6.wav
#ake audio CB from
all wavs in current dir
%see also cdrdao'
oggenc --tracknum,track track.cdda.wav -o track.ogg
#ake ogg file from
wav file
disk space %See also %&lint'
ls -lSr
Show files +y siCe(
+iggest last
du -s 6 | sort -k;(;rn | head
Show top disk users in
current dir. See
also d$top
du -hs 0home06 | sort -k;(;h
Sort paths +y easy to
interpret disk usage
df -h
Show free space on
mounted filesystems
df -i
Show free inodes on
mounted filesystems
fdisk -l
Show disks partitions
siCes and types %run as
root'
rpm -. -a --.f -^;9XSH`$Z@t^X5L#$Z@n- | sort -k;(;n
/ist all pac'a(es +y
installed siCe %Gytes' on
rpm distros
dp'(-.uery -3 -f,-XHnstalled-SiCe<;9Z@tX*ackageZ@n- | sort /ist all pac'a(es +y
-k;(;n
installed siCe %OGytes'
on de+ distros
dd +s,; seek,21G if,0dev0null of,e)tN.test
Create a large test file
%taking no space'. See
also tr$ncate
> file
truncate data of file or
create an empty file
monitoring/debugging
tail -f 0var0log0messages
)onitor messa(es in a log
file
strace -c ls >0dev0null
Summarise0profile
system calls made +y
command
strace -f -e open ls >0dev0null
/ist system calls made
+y command
strace -f -e trace,write -e write,;(2 ls >0dev0null
#onitor what-s written
to stdout and stderr
ltrace -f -e getenv ls >0dev0null
/ist li+rary calls made
+y command
lsof -p
/ist paths that process
id has open
lsof I
/ist processes that have
specified path open
tcpdump not port 22
Show network traffic
e)cept ssh. See
also tcpd$mp_not_me
ps -e -o pid(args --forest
/ist processes in a
hierarchy

ps -e -o pcpu(cpu(nice(state(cputime(args --sort pcpu | sed -0?


9.9 0d-
/ist processes +y ^
cpu usage
ps -e -orss,(args, | sort -+ -k;(;n | pr -13C"/4#5S
/ist processes +y mem
%OG' usage. See
also ps_mem!py
ps -C firefo)-+in -/ -o pid(tid(pcpu(state
/ist all threads for a
particular process
ps -p ;( -o etime,
/ist elapsed wall time
for particular process
HBs
last re+oot
Show system re+oot
history
free -m
Show amount of
%remaining' JL# %-m
displays in #G'
watch -n.; -cat 0proc0interrupts-
3atch changea+le data
continuously
udevadm monitor
#onitor udev events to
help configure rules
system information %see also sysinfo' %-V- means root access is re.uired'
uname -a
Show kernel version
and system architecture
head -n; 0etc0issue
Show name and version
of distri+ution
cat 0proc0partitions
Show all partitions
registered on the
system
grep #em1otal 0proc0meminfo
Show JL# total seen
+y the system
grep Wmodel nameW 0proc0cpuinfo Show C*4%s' info
lspci -tv Show *CH info
lsus+ -tv Show 4SG info
mount | column -t
/ist mounted
filesystems on the
system %and align
output'
grep -: capacityF 0proc0acpi0+attery0GL190info
Show state of cells in
laptop +attery
V dmidecode -. | less
Bisplay S#GH"S0B#H
information
V smartctl -L 0dev0sda | grep *owerE"nE!ours
!ow long has this disk
%system' +een powered
on in total
V hdparm -i 0dev0sda
Show info a+out disk
sda
V hdparm -t1 0dev0sda
Bo a read speed test on
disk sda
V +ad+locks -s 0dev0sda
1est for unreada+le
+locks on disk sda
interactive %see also lin$x 'eyboard shortc$ts*

readline
/ine editor used +y
+ash( python( +c(
gnuplot( ...

screen
\irtual terminals with
detach capa+ility( ...

mc
*owerful file manager
that can +rowse rpm(
tar( ftp( ssh( ...

(n$plot
Hnteractive0scripta+le
graphing
links 3e+ +rowser
)dg-open .

S-ar putea să vă placă și