← echo

Server Commands

Not limited to Ubuntu Server on Raspberry Pi, but I use these commands on my Pi 4.

Current CPU Frequency : sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
Maximum CPU Frequency : sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
Get CPU Temperature   : cat /sys/class/thermal/thermal_zone*/temp
Active ssh sessions   : ss -p | grep -i ssh
SSH tunnel to a port  : sudo -u <username> ssh -fN -R 80:localhost:80 <remoteserver>
Network Consumption   : sudo vnstat -i -m eth0
Kill close_wait proc. : sudo ss --tcp state CLOSE-WAIT --kill
Check Port connections: sudo netstat -pan | egrep "tcp.*:8080.*"
List systemctl timers : systemctl list-timers
Memory Usage(RAM)     : sudo free -h
Vegeta Load           : echo "GET https://singhangad.in/" | vegeta attack -duration=0s | tee result.bin | vegeta report
Kill TCP process      : sudo fuser -k 443/tcp
List port and process : sudo netstat -plotn
Show process as tree  : pstree -p
Create symbolic link. : sudo ln -sf ../sites-available/print.singhangad.in ../sites-enabled/

File encryption with OpenSSL (AES-256-CBC):

Encrypt file : echo "password" | openssl enc -aes-256-cbc -in archive.tgz -out archive.tgz.enc -pbkdf2 -pass stdin
Decrypt file : openssl enc -aes-256-cbc -d -in archive.tgz.enc -out archive.tgz -pbkdf2 -pass pass:password