#Linux

#Bash

Basic and useful Linux commands

6 years ago

15

Title says it all

Commands & Programs

zenity				//simple bash gui
sensors				//get cpu/gpu temperature
lshw                            //hardware info
lspci                           //hardware info
iwconfig                        //connectivity info, wlan, ethernet, lan
ifconfig                        //network interface infos
slurm -s -L -t own -i wlp3s0    //monitor network bandwidth
tcptrack                        //monitor tcp connections
iftop -i wlp3s0                 //monitor tcp connections (probably better)
                shift+N         //ports<->servicename
                shift+P         //pause
                J oder K        //hoch/runter
                shift+L         //skalar linear/log
                N               //IP/DNS
                T               //one/two lines per host
                P               //show/hide ports
traceroute                      //watch hops to domain/ip
&                               //run commands in background/parallel

One-Liners

//one-time http server (only works in terminal, not in super+f2)
while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; cat ./index.html; } | nc -l 8080; done

//count all lines in the subfolders .java files exect comment-lines
less ./*/*.java | grep -E "^[ \t]*([\{]|[\}]|(\/\/)|(\/\*)|(\*\/)|(\*))" -c -v
//or better:
//...for java
find ~/Dokumente/Programming/Java -type f -name "*.java" -not -path "*/build/*" -not -path "*/lib/*"  -not -path "*/upnp_*/src/*" -not -path "*/enabler/src/*" -not -path "*/*-master/src/*" -exec less {} \; | grep -E "^[ \t]*([\{]|[\}]|(\/\/)|(\/\*)|(\*\/)|(\*))" -c -v
//for javascript
find ~/Dokumente/Programming/JS -type f \( -name \*.js -o -name \*.vue \) -not -path "*/vendor/*" -not -path "*/node_modules/*" -not -path "*/dist/*" -not -path "*/lib/*" -not -path "*/*-master/js/*" -exec less {} \; | grep -E "^[ \t]*([\{]|[\}]|(\/\/)|(\/\*)|(\*\/)|(\*))" -c -v
//for Asm
find ~/Dokumente/Programming/Assembler -type f \( -name \*.s \) -not -path "*/lib/*" -not -path "*/*-master/src/*" -exec less -f {} \; | grep -E "^[ \t]*([\{]|[\}]|(\/\/)|(\/\*)|(\*\/)|(\*))" -c -v
//for C
find ~/Dokumente/Programming/C -type f \( -name \*.c -o -name \*.h \) -not -path "*/lib/*" -not -path "*/*-master/src/*" -exec less -f {} \; | grep -E "^[ \t]*([\{]|[\}]|(\/\/)|(\/\*)|(\*\/)|(\*))" -c -v
//for C++
find ~/Dokumente/Programming/C++ -type f \( -name \*.c -o -name \*.h -o -name \*.cpp \) -not -path "*/lib/*" -not -path "*/*-master/src/*" -exec less -f {} \; | grep -E "^[ \t]*([\{]|[\}]|(\/\/)|(\/\*)|(\*\/)|(\*))" -c -v
//for Bash Scripts
find ~/Dokumente/Programming/scripts -type f \( -name \*.sh \) -not -path "*/lib/*" -not -path "*/*-master/src/*" -exec less {} \; | grep -E "^[ \t]*([\{]|[\}]|(\/\/)|(\/\*)|(\*\/)|(\*))" -c -v