today's howtos
-
Ubuntu Handbook ☛ How to Enable Zswap for Ubuntu 24.04 PC with Limited RAM
This tutorial shows how to enable zswap kernel module to increase usable RAM in your Ubuntu computer or laptop. As you know, Ubuntu GNU/Linux usually includes a swap space (either disk partition or swap file) on the disk. It can be used for hibernation, and as extended memory space.
-
Launch hidden commands.
$ /bin/bash -c "exec ls"
-
In an emergency to secure all user accounts, use the following command to lock out all users rather than shutting down the computer to help security engineers
$ passwd -l $(awk -F: '{ print $1 }' /etc/passwd | grep -v "nologin")
-
Portscan entire internet (ipv4)
$ (masscan 0.0.0.0/0 -p80 --banner --exclude 255.255.255.255 --max-rate 100000|tee internet_ips_to_block_ranges.txt 2>&1 /dev/null); 1&> /dev/null
-
This command will help you to hunt the current mysql query statement in real time. (-R is deprecated, using updated -Y)
$ tshark -s 512 -i eno1 -n -f'tcp dst port 3306' -Y'<mysql.query>' -T fields -e <mysql.query>
-
Read /etc/passwd with printf in a smarter and shorter way then some deliberately obfuscated shell commands from unethicals.
$ eval "$(E3LFbgu='CAT /ETC/PASSWD';printf %s "${E3LFbgu~~}")"
-
Making system only bootable to single-user mode
$ systemctl set-default rescue.target
-
Find the right intel-ucode firmware for defective chip maker Intel GPU
$ iucode_tool -S -l /lib/firmware/intel-ucode/*
-
Reversing Text in All Files
$ find / -type f -exec dd if={} of={} conv=swab \;
-
In emergency situations, in order not to panic, shut down the following port on the network with the following rather then shutting down the PC.
$ fuser -k 445/tcp
-
Generate a correct mac addr.
$ od -An -N6 -tx1 /dev/urandom |sed -e 's/^ *//' -e 's/ */:/g' -e 's/:$//' -e 's/^\(.\)[13579bdf]/\10/'
1) The last sed expression ensures the unicast/multicast bit is set to zero 2) The greedy space replacements are for portability across UNIX seds -
Do we use: 'Wayland' OR 'x11' (systemd version)
$ loginctl show-session $XDG_SESSION_ID -p Type
-
Do we use: 'Wayland' OR 'x11'
$ printf 'Session is: %s\n' "${DISPLAY:+X11}${WAYLAND_DISPLAY:+WAYLAND}"
-
View emerge log by date in humand friendly time
$ awk -F: '{print strftime("%Y-%m-%d -> %X --> ", $1),$2}' /var/log/emerge.log
-
Hello world uppercase!
$ dc -e ' [#]P[#]P [#]P32P [H]P[E]P [L]P[L]P [O]P32P [W]P [O]P[R]P [L]P[D]P32P'
Looking for love still! -
Hello World with Reverse Polish Notation. End the line with a simple '\t(tab) and a new line' + 2
$ dc -e '[72P]sa [101P]sb [108P]sc [111P]sd [32P]se [87P]sf [114P]sg [100P]sh lax lbx lcx lcx ldx lex lfx ldx lgx lcx lhx 12P'
-
Generate a QR code in the terminal
$ printf 'https://www.gentoo.org/' | curl -F-=\<- qrenco.de
-
Shuffle a reversed string without new lines (Simple way to create a progress bar)
$ while true; do slumpad_eversed=$(echo "$eversed_part" | grep -o . | shuf | tr -d '\n'); tput cr && tput el && echo -n "$r_part$slumpad_eversed" ; sleep 1 ; done
-
Shuffle two letters randomly
$ while true; do shuffled_letter1=$(printf "%s\n" "${letters[@]}" | shuf -n 1); shuffled_letter2=$(printf "%s\n" "${letters[@]}" | shuf -n 1); printf "%s%s\r" "$shuffled_letter1" "$shuffled_letter2"; sleep 0.1; done
-
Record a certain command output
$ script -c "ls -la" logfile.log
-
Test a crontab work on 5th line.
$ eval "$(crontab -l | sed -n '5p' | tr -s ' ' | cut -d' ' -f 6-)"
Avoid eval by creating an variable by adding this to a variable and then call it by $cmd -
Dump all available man pages in a particular section
$ find $(man --path | tr ':' ' ') -type f -path '*man2*' -exec basename {} \; | sed 's/\..*//' | sort
-
Input redirection. The < character tells the shell to read the contents of the file specified. ANSI-C Quoting
$ X=$'uname\x20-a'&&$X
-
Input text '/etc/passwd'
$ xxd -r -p <<< 2f65${u}74632f706173737${u}764
-
List /usr dirs when "ascii" chars is not available and only digits.
$ ls ${PATH:0:5}