2/18/2018 - 1:06 PM

My Linux Cheat Sheet

Linux commands that I saved over years.

Ctrl+Alt+F1 to open virtual console.
Ctrl+Alt+F7 to return to desktop.

uname -a = printeaza informatii despre sistem

inxi -Fxz = informatii despre drivere sistem

dmidecode = informatii RAM

grep MHz /proc/cpuinf = frecventa procesoare

apt-cache search something = cauta in sistem daca exista pachetul respectiv

octave --no-gui = deschide octave direct in terminal

lscpu = informatii despre pc

dmesg / journalctl -xb (for current log) = printeaza mesajele kernelului

runlevel = pe ce nivel ruleaza sistemul
telinit x = specifica runlevel pentru linux; x = 0->6
level 0 = shut down(halt)
level 1 = rescue mode
level 2,3,4,5 = multiuser without network, with network, with X/V windows system
level 6 = reboot

wall = trimite un mesaj catre toti userii

systemctl start/status/stop sshd.service(for example) sau alte servicii.

df = afiseaza Filesystem cu spatiul liber si unde e mountat.

dd if=/dev/zero(for zeros) of=/dev/sda(for ssd) bs=1k(sau 512) count=1
		  /random(for random mem) /mmkblk01(for emmc)
								  /sdb(for serial drive bus = usb)
= make the disk to appear brand new and unpartitioned ELSE use gparted

dd if=/dev/random of=fisier.bin bs=128 count=4 = geneareaza un fisier de 512 bytes (4 blocuri de cate 128 bytes) 

echo $HISTSIZE = cate comenzi retine in istoric bash-ul

xxd = descompune fisierul in hexazecimal

python -c 'print hex(number in zecimal)' = transforma un numar in hexazecimal
python -c 'print 0x(number in hexazecimal)' = transforma numarul in zecimal 

htop = informatii procese + nuclee procesor

readlink -f file = show full path to file

stat "file" = display information about the file

cat /etc/passwd | column -t -s "<separator>" = display the output as a table

ps aux | sort -rnk 4 = sort processes by memory usage
ps aux | sort -nk 3 = sort processes by cpu usage

cd - = return tu previous directory

yes | apt-get update = say yes to any command

cat test.txt | tr '\t' '\s' > after_test.txt = replace tabs with spaces in a file
cat test.txt | tr a-z A-Z > after_test.txt = replace lowercase with uppercase

cat urls.txt(file that contains different urls) | xargs wget = pass lines as arguments for wget to download stuff from that urls

dd if=/dev/urandom of=file.txt bs=1024 count=102400 = create big random file