Nejčastěji používané příkazy v linuxu

seznam DHCP klientu
/var/lib/dhcp3/dhcpd.leases

linuxove tahaky
http://ogi.cz/help/

verze jadra
uname -r
cat /proc/version
rpm -q kernel
dmesg | grep Linux

pridani verejneho klice
wget http://adresa-klice/nazev-klice
apt-key add nazev-klice
gpg –import nazev-klice && gpg –fingerprint

kontrola posty
tail -f /var/log/mail.log

test posty
sendmail -f od@domena.cz komu@domena.cz < /home/b/eicar.com

Wol a wake on lan
# aptitude install etherwake
# etherwake <mac address>
wakeonlan is also available, a program that uses UDP packets not TCP, and hence does not need to be run as root. It is also slightly more configurable.
# aptitude install wakeonlan && exit
$ wakeonlan <mac address>

pripojeni do fstab sitove disky hned po stratu
//192.168.254.3/d /mnt/disk-D smbfs username=<uzivatelske jmeno>,password=<heslo> 0 0
//192.168.254.3/filmy /mnt/filmy smbfs username=<uzivatelske jmeno>,password=<heslo> 0 0

nmap
zjisteni rpc sluzeb
Nmap -sS -sR target
detekce OS
Nmap -vv -sS -O www.domena.cz

amap Program naváže s daným portem komunikaci a zašle na něj spouštěč (určitá přesně definovaná data) a

zaznamená si veškerá data přijatá z onoho portu a komunikaci ukončí.

pridani uzivatele do skupiny
gpasswd -a clamav amavis

instalace debian balicku
dpkg -i <nazev_balicku>

chyby na síťovce
dmesg
vypis procesu
ps aux
vytizenost pocitace
cat /proc/loadavg
top -b

vypise co se dejen na portu 80
netstat -tupan|grep 80
netstat -atpn |grep :80
netstat -natup
netstat -lnp

editace cronu
crontab -e

vypise sluzby na pc
nmap ip_adresa_pc

odchytava co se deje na urcitem portu
tcpdump tcp port 22 -X |grep PASS
tcpdump -nnvvS tcp and dst port 22
http://www.jaknalinux.cz/tcpdump-linux-17/

zjisteni ktere programy maji setuserid
find / \( -perm -02000 -o -perm -04000 \) -ls

posta v textove konzoli
mutt

symbolicke odkazy
ln -s <kam odkazujeme> <umisteni symbolickeho odkazu>

vsechny procesy ps -A
misto na disku df

vypise seznam zarizeni na PCI
lspci

arping

testsaslauthd -u user -p password -f /var/spool/postfix/var/run/saslauthd/mux

chown -R ftpuser:ftpgroup www.domena.ccz/
chown -R 10000:10000 valaska/

gzip -9

zabaleni do tar a gzip
tar -cvzf bu.tar.gz /home/bu
zabaleni do tar a bzip2
tar -cvjf bu.tar.gz /home/bu
extrahovani
tar -xvf bu.tar

tar -cvzf bu.tar.gz /home/bu          #pomocí parametru z přímo v taru
#nebo
tar cf – /home/bu | bzip2 > bu.tar.gz #propojením taru a gzipu

Užitečný je parametr -c, který přesměruje výstup gzipu do standardního výstupu, který lze pak

nasměrovat do vlastního souboru. Vedlejším, ale rovněž cenným efektem je že po kompresi nedojde ke smazání původního souboru.
gzip -c plan.txt > plan.tgz

tar -xvzf bu.tar.gz  #obnova souborů komprimovaných s gzip
tar -xvzf bu.tgz     #to samé, jen je použit zkrácený tvar přípony
tar -xvjf bu.tar.bz2 #obnova souborů komprimovaných s bzip2
tar -xvZf bu.tar.Z   #to samé pro dříve užívaný compress

restart posty
/etc/init.d/spamassassin restart
/etc/init.d/amavis restart
/etc/init.d/clamav-daemon restart
/etc/init.d/postfix restart

aktualizace ClamAV
freshclam -d

vymaza aktualizaci, je potreba vymazat vsechny cash soubory
rm /var/lib/clamav/*.*

vymazani v poste slozky queue
postsuper -d ALL

oprava tabulek
mysqlcheck –all-databases -p[HESLO]
mysqlcheck –repair –all-databases -p[HESLO]

30 3 * * * * /usr/local/sbin/reset

procesy
* man ps, man pstree
* man top
* man nice
* man nohup
* help help 🙂
* man kill, help kill, man killall
* man bash, sekce JOB CONTROL, viz též help jobs fg bg
* man lsof
* man fuser

zruseni procesu
kill #PID

stav raidu
cat /proc/mdstat
vypis raidovych poli
grep /dev/md /etc/fstab

ulozeni spam a zavirovanych zprav
/var/lib/amavis/virusmails

aktualizace spamassasinu
sa-update

Ucit tzv. bayes modul muzes tak, ze hodis spam do slozky napr. /root/spam a ham (tj. maily, ktere

nejsou spamy) do slozky napr. /root/ham. Pak spustis:

sa-learn –spam –showdots –dir /root/spam
sa-learn –ham –showdots –dir /root/ham

ulozene bulk maily od odesilatelu
/var/lib/amavis/tmp

promazani spamu staršího dvaceti dnů
find /var/lib/amavis/virusmails/0 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/1 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/2 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/3 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/4 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/5 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/6 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/7 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/8 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/9 -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/a -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/A -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/b -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/B -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/c -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/C -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/d -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/D -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/e -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/E -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/f -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/F -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/g -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/G -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/h -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/H -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/i -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/I -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/j -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/J -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/k -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/K -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/l -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/L -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/m -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/M -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/n -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/N -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/o -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/O -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/p -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/P -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/q -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/Q -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/r -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/R -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/s -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/S -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/t -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/T -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/u -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/U -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/v -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/V -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/x -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/X -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/y -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/Y -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/z -type f -mtime +20 -exec rm -v -rf {} \;
find /var/lib/amavis/virusmails/Z -type f -mtime +20 -exec rm -v -rf {} \;
rm /var/lib/clamav/*.*
rm /var/lib/clamav/daily.inc/*.*
rm /var/lib/clamav/main.inc/*.*
freshclam -d

zcat seznam_cd1.gz | grep ‚xpexeso‘
| grep ‚xpexeso‘

zcat /var/lib/amavis/virusmails/0/*.gz | grep ‚stavebni‘

find . -exec grep -li string {} \;

zgrep *.gz | tail -n 20
gunzip -c file1.*.gz |grep -v

gunzip *.gz | grep -q ‚fotbal‘

zgrep „fotbal“ *.gz

SQL příkazy

Změna obsahu buňky
UPDATE `prefix-tabulka` SET sloupec = replace(sloupce, ‚co hledám‘, ‚čím nahrazuji‘);

Pomohl Vám článek a chcete nás odměnit? Pošlete nám platbu přes paypal nebo na BTC peněženku 1bBr5iNS337NVzWjkvvH31bjmDvH4kfGb