Comanda | Descriere | |
---|---|---|
RPM | rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm | How to Install an RPM Packagey | rpm -qa | Listeaza toate pachetele instalate |
rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm | How to check dependencies of RPM Package before Installing | YUM | yum search htop | Search for htop package | yum search all htop | With search all you can force searching in all the fields (e.g., in the description too |
yum search htop --enablerepo=epel | Enable currently disabled repo for a single command | |
yum repolist | Lists all enabled repositories. | |
yum -v repolist all | List all repo status: enabled/disabled | |
yum list | Lists all packages that are available in all enabled repo & all packages that are installed on your system. | |
yum provides '*htop*' | ||
yum install yum-plugin-downloadonly | Install "Downloadonly" plugin for yum (RHEL6) | |
yum install yum-utils | Install "Downloadonly" plugin for yum (RHEL6) | |
yum install --downloadonly whois-5.1.1-2.el7.x86_64 | Download to ./var/cache/yum/x86_64/7/base/packages/whois-5.1.1-2.el7.x86_64.rpm, but don’t install | |
yum install yum-utils | Install the yum-utils package for "yumdownloader" | |
yumdownloader package | Utilitar pentru a descarca local un pachet si fara a il instala. | |
yum remove package | Sterge un pachet | |
yum check-update | Checks whether updates exist for packages that are already installed on your system. | |
yum update | pdates all packages, including packages on which they depend. | |
yum clean all | Removes all cached package downloads and cached headers that contain information about remote packages. Running this command can help to clear problems that can result from unfinished transactions or out-of-date headers. | |
Repositories for YUM | epel-release | Extra Packages for Enterprise Linux (EPEL) EPEL is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Linux (OL). EPEL packages are usually based on their Fedora counterparts and will never conflict with or replace packages in the base Enterprise Linux distributions. EPEL uses much of the same infrastructure as Fedora, including buildsystem, bugzilla instance, updates manager, mirror manager and more. |
yum install https://centos7.iuscommunity.org/ius-release.rpm | (PHP-ul intra in conflict cu cPanel) Inline with Upstream Stable - IUS is a community project that provides RPM packages for newer versions of select software for Enterprise Linux distributions. | |
yum install centos-release-scl | Enterprise Linux distributions are designed to be around for a long time. They are also designed to maintain ABI/API compatibility over the lifetime of the distribution, so that you can create your own custom programs on day 1 of the release and have them work as long as the distribution is supported. For CentOS that is currently 10 years. This means, however, that by the end of the lifetime of a distribution, the programming language or database versions (think php, python, perl or mysql, postgresql) included are getting very old compared to those that are available in "cutting edge" Linux distributions. | |
yum --disablerepo="*" --enablerepo="scl" | list available | |
yum --disablerepo="*" --enablerepo="scl" | search |
|
rSync | rsync -avz -e 'ssh -p 24' /root/desicronizat/ 37.251.160.254:/root/desicronizat/ | rSync server-to-server via SSH |
Find | find . | cut -d"/" -f2 | sort | uniq -c | sort -n | Numara inodes dintr-un folder | find . -type f -size +100M ! -path "./var*" -exec ls -alh {} \; | Numara inodes dintr-un folder cu exclude | echo "Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n" | Numara inodes dintr-un director | find . | cut -d"/" -f2 | sort | uniq -c | sort -n | Numara inodes dintr-un folder | find -type f -ctime +1100 ! -path "./conservare*" ! -path "./CONSERVARE*" -exec ls -lah {} \; |
Bash | dmesg | egrep -i “killed process” | View killed proccess | diff -y -W 120 File_1.txt File_2.txt | Difference | grep -Fxvf ip.txt ip.txt2 | Difference | grep -f ip.txt ip.txt2 | Difference | sar -q | awk {'print $1,$2,"--->",$6'} | Load raport | ps -aux --sort=-pcpu | head -n 6 | Sorteaza primele 5 procese consumatoare de procesor | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | Grep IP address | grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" | Grep Email | grep -oE "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" | Grep IP address |
Sar | sar -u 3 10 | View Stats 3 = interval + 10 = count |
Echo | echo -e "\e[31m Hello World \e[0m" | Coloreaza scrisul si dupa reseteaza |
Compresie & Arhivare | ||
tar -cvf Arhiva.tar file1 file2 | Arhiveaza file1 si file2 in "Arhiva.tar" | |
tar -xvf Arhiva.tar | Dezarhiveaza "Arhiva.tar" | |
tar -tvf Arhiva.tar | Listeaza continutul "Arhiva.tar" | |
tar -cvzf Arhiva.tar.gz file1 file2 | Arhiveaza si comprima "Arhiva.tar.gz" | |
tar -xvzf Arhiva.tar.gz | Dezarhiveaza si decomprima "Arhiva.tar.gz" | |
tar -tvzf Arhiva.tar.gz | Listeaza continutul arhivei comprimate "Arhiva.tar.gz" | |
tar -zxpvf | Dezarhivare si decompresie -> xxx.tar.gz | |
tar -jxpvf | Dezarhivare si decompresie -> xxx.tar.bz2 | |
gunzip Arhiva.tar.gz | Doar iti decomprima "Arhiva.tar.gz" in "Arhiva.tar" | |
zip Arhiva.tar.zip Arhiva.tar | Comprima cu ZIP arhiva "Arhiva.tar" in "Arhiva.tar.zip" | |
unzip Arhiva.tar.zip | Decomprima arhiva "Arhiva.tar.zip" in "Arhiva.tar" | |
IPTABLES | iptables -nvL | Show all rules |
-A INPUT -s 46.161.9.18/32 -j DROP | Blocare adresa IP | |
iptables -I INPUT -p tcp -m tcp --dport 24 -j ACCEPT | Allow port 24 | |
iptables -I INPUT -s 172.16.24.149 -j ACCEPT | Allow adresa IP sursa | |
iptables -I INPUT -d 172.16.24.149 -j ACCEPT | Allow adresa IP destinatie | |
iptables -I INPUT -s 37.251.156.0/24 -p tcp --dport 24 -j ACCEPT | Allow clasa xServer | |
.htaccess | deny from all | Blocare acces all |
allow from IP | Allow IP | |
require all denied | Blocare acces all - Apache2.4 | |
require ip IP | Allow adresa IP - Apache2.4 | |
Netstat | netstat -anp | grep :80 | grep ESTABLISHED | awk {' print $5 '}| cut -d: -f1 | wc -l | Cate conexiuni active are in acest moment |
Base64 | base64 exemplu.php | Cripteaza continutul fisierului |
base64 -d exemplu.php | Decripteaza continutul fisierului | |
SSH | ssh root@10.16.97.1 -p 24 | Ssh port 24 |
ssh -t root@37.251.160.178 "ps aux" | Ssh -> ruleaza o comanda -> afiseaza output -> inchide sesiunea | |
ssh -t root@`cat ip.txt` "hostname" | la fel doar ca IP-ul serverului il ia din fisierul ip.txt | |
SSH-agent | ssh-agent | Ssh agent |
ssh-add /root/.ssh/private_key | Adauga cheia privata in ssh-agent | |
eval `ssh-agent` | Arata PID-ul si apoi poti sa ii dai kill | |
Open SSL | openssl pkcs12 -in domain.pfx -clcerts -nokeys -out domain.crt | Extragere certificat (public key) |
openssl pkcs12 -in domain.pfx -nocerts -nodes -out domain.key | Extragere cheie (privat key) | |
openssl pkcs12 -in domain.pfx -cacerts -nokeys -chain -out cacrt.crt | Extrage ca-bundle | |
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile moreORcabundle.crt | Creare arhiva .pfx | |
CUT | cat /etc/userdomains | cut -d":" -f1 | Desparte dupa delimitatorul ":" si afiseaza doar primul element |
CUT -exclude un element(f1) | cat /etc/userdomains | cut -d":" --complement -f1 | Desparte dupa delimitatorul ":" si afiseaza tot mai putin primul element |
for i | for i in {1..10000}; do echo $i; done | Citeste fiecare linie din i, apoi afiseaza fiecare linie |
for i in `cat ip.txt`; do echo $i; done | for i | |
for (( i = 30; i <= 37; i++ )); do echo $i; done | for i crescator | |
Exim: | exim -bp | grep frozen | awk {'print $3'} | xargs exim -Mrm | Delete frozen email |
Postfix | postqueue -p | Display a list of queued mail, deferred and pending | mailq | List queued mails | postcat -vq XXX | View message (contents, header and body) in Postfix queue | postqueue -f | Force send email from queue | postsuper -d ALL | Delete all queued mail | mailq | grep "^[A-F@0-9]" | sum mailq |
Kill | kill -9 123 | SIGKILL - Kill signal. This signal causes the immediate termination of the process by the Linux kernel. Programs cannot listen for this signal. | kill -15 123 | SIGTERM - Termination signal. This signal is given to processes to terminate them. Identic cu "Control + C" sau cu "kill 123 | kill -25 123 | SIGTSTP (STP) - Terminal - Stop/pause the process; can be trapped | kill -26 123 | SIGCONT (CONT) - Continue - Run a stopped process | PS | ps -u apache/root | Procesele unui anumit user | ps -efH | To print a process tree: | pstree -p | Print a process tree with process ID: | pkill firefox | kill all Firefox | pgrep -l httpd | To avoid killing the wrong processes | DIG | dig +multiline +noall +answer +nocmd cyberciti.biz ANY | dig +short dd-studio.ro | Short answer = Only IP | dig +trace | Trace delegation down from root | dig -f file_name | Dig file | Alocare adresa IP | dhclient eth0 | Alocare IP dinamic prin DHCP | ip address add 37.251.156.162/24 | Alocare IP static via comanda IP | ip route show | Vezi rutele | ip route add default via 37.251.156.1 | Adaugare Default Gateway | ip address flush dev eth0 | Sterge adresa IP alocata interfetei eth0 | ifconfig eth0 eth0 37.251.156.162/24 | Alocarea IP static via comanda IFCONFIG |
cPanel | /usr/local/cpanel/cpanel -V | Versiune cPanel |
/scripts/pkgacct user | Genereaza arhiva | |
Virtualmin | wget http://software.virtualmin.com/gpl/scripts/install.sh | Install Virtualmin |
virtualmin list-domains | List domains | |
SPAM | grep cwd /var/log/exim_mainlog | grep -v /var/spool | awk -F"cwd=" '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -n | Check SPAM |
ps php | ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }' | Cat consuma un proces PHP |
PHP | ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }' | Check PHP proces - medie |
SCP | scp -P 24 cpmove-recrutar.tar.gz root@172.16.24.124:/home | SCP |
Raport per request | # cat deluat.ro-ssl_log | grep "06/Sep/2017" | cut -d: -f2,3 | uniq -c | Raport per Request-uri |
csf | csf -g IP | Search the iptables and ip6tables rules for a match |
csf -t | Displays the current list of temporary allow and deny IP entries with their TTL and comment | |
csf -dr IP | Unblock an IP and remove from /etc/csf/csf.deny | |
csf -tr IP | Remove an IP from the temporary IP ban or allow list | |
csf -s | Start the firewall rules | |
csf -f | Flush/Stop firewall rules (note: lfd may restart csf) | |
csf -r | Restart the firewall rules | |
csf -a IP | Allow an IP and add to /etc/csf/csf.allow | |
clamd | freshclam | update virus databases |
clamscan -r -bell -i /home | To check all files on the computer, but only display infected files and ring a bell when found: | |
clamscan -r /home | To check all files on the computer, displaying the name of each file | |
clamscan -i /home | To check all files on the computer, displaying the name of each file | |
maldet | maldet -d && maldet -u | Make sure to update to the latest version and virus signatures |
maldet -a /home/user | To scan a specific user's home directory | |
maldet -b --scan-all /home?/?/public_? | To launch a background scan for all user's public_html and public_ftp in all home directories, run the following command | |
maldet --report list | List all scan reports time and SCANID | |
maldet --report SCANID | Show a specific report details : | |
/usr/local/maldetect/conf.maldet | aldet can send you and email alert each time it detects malware. Please review these configuration variables in: | |
grep "{scan}" /usr/local/maldetect/event_log | Show all scan details from log file: | |
Vi | vi -> :%s/^ //g | Replace in Vi (inlocuieste spatiul de la inceput cu nimic) |
Browser Web | elinks | Browser Web din linie de comanda |
qm - Qemu/KVM Virtual Machine Manager | qm list | list all vmids |
qm suspend 1234 | suspend vmid1234 | |
Diverse statistici | cat /var/log/virtualmin/secundar.ro_access_log | grep "04/Oct/2017" | cut -d":" -f2,3 | sort -h | uniq -c | statistica access log /requesturi per minut | cat /var/log/virtualmin/secundar.ro_access_log | grep "04/Oct/2017" |grep -v 200 | cut -d":" -f2,3 | sort -h | uniq -c | statistica access log /requesturi per minut cate nu au avut status 200 |
IMMUTABLE (Unchangeable) in Linux | lsattr .htaccess | List attribute |
chattr +i .htaccess | Change attribute -> Make file immutable | |
chattr +a .htaccess | Make file only append | |
chattr -R +i folder | chattr for folder | |
Mysqldump | mysqldump database_name > dump_file.sql | Dump database_name to dump_file.sql |
mysql < dump_file.sql | import from sql dump | |
MySQL | show databases; | List all databases; |
use database_name; | select database_name | |
select database(); | view what database you selected | |
show tables; | List all tables; | |
select * from table_name; | List all from table_name; | |
show table status; | show informations(MyISAM/InnoDB) | |
status | info: | |
DD = Data Definition | dd if=/dev/zero of=/home/file_with_zero bs=1024k count=1024 | if=input file; of=output file; bs=block size; --> copiaza din /dev/zero 1024 de blockuri cu dimensiunea de 1024k si este egal cu 1GB. |
dd if=/dev/sda of=/dev/sdb | Create an img file of the /dev/sda hard drive. To restore that image type: dd if=disk1.img of=/dev/sda | |
dd if=file1 of=file2 conv=ucase | How to change case of input text using dd command: file1=hello --> file=HELLO | |
Viewing Block Devices and File Systems | lsblk | List block device; MAJ:MIN=major and minor device number; RM=if the device is removable; RO=if the device is read-only |
blkid | List block device UUID, Type=ext4,ext3,etc | |
findmnt | List block device; or use findmnt -t ext4 | |
Viewing Hardware Information | lspci (-v or -vv) | List all PCI devices that are in the system. List information about PCI buses and devices that are attached to them |
lsusb (-v or -vv) | List information about USB buses and devices that are attached to them | |
lscpu | List information about CPUs that are present in the system, including the number of CPUs, their architecture, vendor, family, model, CPU caches, etc | |
Kernel Modules | lsmod / cat /proc/modules | Show the status of modules in the Linux Kernel |
modprobe | Program to add and remove modules from the Linux Kernel (-l -list modle) | |
modinfo | Program to show information about a Linux Kernel module | |
NetFilter / Iptables | ||
table[ -t ] |
filter |
INPUT |
OUTPUT | ||
FORWARD | nat |
PREROUTING |
OUTPUT | ||
POSTROUTING | conntrack |
PREROUTING |
INPUT | ||
OUTPUT | ||
FORWARD | ||
POSTROUTING | security |
INPUT |
OUTPUT | ||
FORWARD | mangle |
PREROUTING |
INPUT | ||
OUTPUT | ||
FORWARD | ||
POSTROUTING | raw |
PREROUTING |
OUTPUT | ||
chain |
1. PREROUTING | -A "chain"=append -I "chain"=insert -L "chain"=list | -nvL "chain"=list detailed | -L "chain" --line-numbers=List chain rules + line numbers -D "chain" 5=delete rule 5 -R "chain" new-rule=replace -P "chain" policy=default policy (ex: iptables -P INPUT DROP) -F "chain" = flush chain, delete all rules (ex: iptables -F INPUT) -N "chain" = new chain_custom -X "chain_custom" = delete chain_custom -Z "chain" = reset counters |
2. INPUT | 3. OUTPUT | 4. FORWARD | 5. POSTROUTING |
target[ -j ] |
ACCEPT | Trecerea pachetului prin chain va fi permisa | DROP | Pachetul va fi distrus fara instiintarea expeditorului | REJECT | Pachetul va fi distrus dar expeditorul va primi un mesaj de eroare ce poate fi ales cu --reject-with tcp-reject | LOG | Scrie in syslog informatii despre pachet | --log-prefix XXX | --log-level "debug,info,notice,warning, err,crit,alert,emerg" | REDIRECT | Redirectioneaza pachetelor catre statia locala | RETURN | Incheie parcurgerea chain-ului si i-se aplica default_policy | MARK | Marcheaza pachetele | ex: --set-mark 12 | DOAR in MANGLE | TTL | Modifica TTL | SNAT | Modifica adresa IP sursa la iesirea din statie | DOAR in NAT | DNAT | Modifica adresa IP destinatie la iesirea din statie | DOAR in NAT | MASQUERADE | Asemanator cu SNAT, potrivit pentru interfetele de retea cu adresa asignata dinamic |
iptables | iptables-save > iptables_bkp.txt | Export rules | nano iptables_bkp.txt | Edit rules | iptables-restore < iptables_bkp.txt | Import rules |
MySQL | grant all privileges on *.* to 'root'@'188.26.250.54' identified by 'dandinca'; | Acordare drepturi depline pe toata informatia pt root. |
---Tune2fs--- Adjust parameters on ext2/ext3/ext4 filesystems |
tune2fs -l /dev/sda | Listeaza informatii | tune2fs -m 0 /dev/sda | Seteaza reserved blocks to 0%, temporar pentru a elibera spatiul pe partitia respectiva. | tune2fs -r 20000 /dev/mapper/centos-root | Rezerva 20 000 de blocuri | tune2fs -l /dev/mapper/centos-root | grep 'Mount count:\|Maximum mount count:' | Vezi cand se va face urmatorul fsck | tune2fs -c 80 /dev/mapper/centos-root | If errors are found on the file system, fsck will run no matter what. fsck will also run automatically after 30 mounts by default in Ubuntu. You can use tune2fs to increase the number of mounts and/or have it run after a certain amount of days. |
tune2fs -i d3 m2 w1 /dev/HARDDRIVE | fsck will run after 3 days, 2 months and 1 week | tune2fs -L PORNDRIVE /dev/HARDDRIVE | Setting a volume label |
xx | x | xxx |