{"id":216,"date":"2020-09-26T13:31:33","date_gmt":"2020-09-26T13:31:33","guid":{"rendered":"https:\/\/dft.wiki\/?p=216"},"modified":"2026-07-16T08:43:15","modified_gmt":"2026-07-16T12:43:15","slug":"useful-tricks-and-commands-linux","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=216","title":{"rendered":"Random Linux Commands and Useful Tips"},"content":{"rendered":"<p><b>CATEGORIES<\/b><\/p>\n<ol>\n<li><a href=\"#SysEnv\">System and Environment<\/a><\/li>\n<li><a href=\"#Network\">Network<\/a><\/li>\n<li><a href=\"#PubIP\">Public IP<\/a><\/li>\n<li><a href=\"#DNSUtils\">DNS Utilities<\/a><\/li>\n<li><a href=\"#Mounting\">Mounting Volumes<\/a><\/li>\n<li><a href=\"#General\">General Linux Tips<\/a><\/li>\n<li><a href=\"#Ubuntu\">Ubuntu Tips<\/a><\/li>\n<li><a href=\"#RPI\">Raspberry PI Tips<\/a><\/li>\n<li><a href=\"#Kali\">Kali Tips<\/a><\/li>\n<li><a href=\"#Forensics\">Forensics Tools<\/a><\/li>\n<li><a href=\"#WDNAS\">Western Digital NAS<\/a><\/li>\n<li><a href=\"#ESXi\">VMWare ESXi Tips<\/a><\/li>\n<li><a href=\"#NVIDIA\">NVIDIA Drivers<\/a><\/li>\n<li><a href=\"#AMD\">AMD GPU Drivers<\/a><\/li>\n<\/ol>\n<hr id=\"SysEnv\" \/>\n<p><strong>SYSTEM AND ENVIRONMENT<\/strong><\/p>\n<pre>sudo hostnamectl set-hostname <strong>newHostName<\/strong>\r\nid || (whoami &amp;&amp; groups) 2&gt;\/dev\/null\r\nid -un\r\nuname\r\nuname -a\r\nuname -r\r\nuname -m\r\nneofetch\r\ninxi -F\r\nw\r\nlast -aiF\r\nlastb -adF\r\nlast reboot\r\njournalctl --list-boots\r\narch\r\nlsb_release -rd\r\ncat \/proc\/version\r\n(cat \/proc\/version || uname -a) 2&gt;\/dev\/null\r\nsystemctl show-environment\r\nenv\r\nset\r\nuptime\r\nlsblk\r\nlsblk -f\r\nlscpu\r\nlsusb\r\nlspci\r\nlspci -vvv\r\nlsmod\r\necho $SHELL\r\necho $HOME\r\nreset\r\nman <strong>commandName<\/strong>\r\ntldr <strong>commandName<\/strong>\r\napropos <strong>commandName<\/strong>\r\nsystemd-analyze\r\nsystemd-analyze blame\r\nsystemd-analyze critical-chain<\/pre>\n<p>Manage physical (discrete) memory:<\/p>\n<pre>dmidecode -t memory\r\nlsmem\r\nlsmem -a\r\nchmem -d 0x0000000878000000-0x000000087fffffff\r\nchmem -e -b 271<\/pre>\n<p>History of commands:<\/p>\n<pre>history -c\r\nhistory -r\r\nset +o history\r\n# history does not store this command\r\nset -o history\r\nhistory\r\n!123\r\nHISTTIMEFORMAT=\"%Y-%m-%d %T \"\r\ncat ~\/.bash_history | fzf -i<\/pre>\n<p>Prevent a command from being saved to history by starting it with a space (~\/.bashrc):<\/p>\n<pre>HISTCONTROL=ignoreboth<\/pre>\n<p>List all available commands, aliases, bash built-ins, bash keywords, and bash functions:<\/p>\n<pre>compgen -c\r\ncompgen -a\r\ncompgen -b\r\ncompgen -k\r\ncompgen -A function<\/pre>\n<p>Display kernel ring buffer messages sent to syslog since the last boot (human-readable timestamp, watch live, filter content, and clear buffer):<\/p>\n<pre>sudo dmesg -T\r\nsudo dmesg -w\r\nsudo dmesg | grep error\r\nsudo dmesg | grep usb\r\nsudo dmesg -c<\/pre>\n<p>List timers and services:<\/p>\n<pre>systemctl list-timers --all\r\nsystemctl list-units --type=service\r\nsystemctl --all<\/pre>\n<p>Rootless services:<\/p>\n<pre>systemctl edit --force --full <strong>serviceName<\/strong> <strong>--user<\/strong>\r\nsystemctl start <strong>serviceName<\/strong> <strong>--user<\/strong><\/pre>\n<p>Enable lingering (keep processes running after the user logs off):<\/p>\n<pre>loginctl <strong>show-user<\/strong> userName | grep <strong>Linger<\/strong>\r\nloginctl <strong>enable-linger<\/strong> userName<\/pre>\n<p>Storage volume speed test:<\/p>\n<pre>sudo apt install hdparm -y\r\nhdparm -tv -direct \/dev\/sdc1<\/pre>\n<p>Inodes:<\/p>\n<pre>ls -i\r\nstat <strong>fileName<\/strong>\r\ndf -i<\/pre>\n<pre>sudo apt install <strong>inotify-tools<\/strong> -y\r\ninotifywait -m -q -e modify <strong>\/var\/log\/applicationLogs<\/strong><\/pre>\n<p><strong>Note:<\/strong> there is a kernel module called <code>fanotify<\/code> that can monitor and intercept filesystem events.<\/p>\n<p>List users, superusers, logged-in users, login history, last login per user, and all users and groups:<\/p>\n<pre>cat \/etc\/passwd | cut -d: -f1\r\nawk -F: '($3 == \"0\") {print}' \/etc\/passwd\r\nw\r\nlast\r\nlastlog\r\nfor i in $(cut -d\":\" -f1 \/etc\/passwd 2&gt;\/dev\/null);do id $i;done 2&gt;\/dev\/null | sort\r\nid <strong>userName<\/strong><\/pre>\n<p>Get password policy:<\/p>\n<pre>grep \"^PASS_MAX_DAYS\\|^PASS_MIN_DAYS\\|^PASS_WARN_AGE\\|^ENCRYPT_METHOD\" \/etc\/login.defs<\/pre>\n<p>Find files writable by anyone or any group:<\/p>\n<pre>find \/ '(' -type f -or -type d ')' '(' '(' -user $USER ')' -or '(' -perm -o=w ')' ')' 2&gt;\/dev\/null | grep -v '\/proc\/' | grep -v $HOME | sort | uniq\r\nfor g in `groups`; do find \\( -type f -or -type d \\) -group $g -perm -g=w 2&gt;\/dev\/null | grep -v '\/proc\/' | grep -v $HOME; done\r\nfind . -mindepth 1 -type f -name \"*.zip\"\r\nfind . -mindepth 1 -type f -name \"*.zip\" -printf x | wc -c<\/pre>\n<p>Read a specific line number from a file:<\/p>\n<pre>awk 'NR==50' <strong>fileName<\/strong>\r\nsed '50!d' <strong>fileName<\/strong><\/pre>\n<p>Running processes:<\/p>\n<pre>ps aux\r\nps -ef\r\npgrep -l ssh\r\npgrep -u root\r\ntop -n 1<\/pre>\n<p>Run a process with a given priority, or change the priority of a running process:<\/p>\n<pre>nice -n <span style=\"color: #ff0000;\"><strong>3<\/strong><\/span> script.sh\r\nrenice <strong><span style=\"color: #ff0000;\">+1<\/span><\/strong> -p <strong>PID<\/strong>\r\nrenice <span style=\"color: #ff0000;\"><strong>5<\/strong><\/span> -p <strong>PID<\/strong><\/pre>\n<p>Note: <strong>PID<\/strong> is the process ID, which can be found using the <code>ps<\/code> command. The priority range is <span style=\"color: #ff0000;\"><strong>-20 (highest) to +19 (lowest)<\/strong><\/span>.<\/p>\n<p>Reparent a running program to a new terminal:<\/p>\n<pre>sudo reptyr PID\r\nsudo reptyr -s PID<\/pre>\n<p>List detailed information about all <strong>PCI buses and devices<\/strong>:<\/p>\n<pre>lspci<\/pre>\n<p>Configure and update <strong>Grub<\/strong>:<\/p>\n<pre>sudo nano \/etc\/default\/grub\r\nsudo os-prober\r\nsudo update-grub<\/pre>\n<p>See also the configuration files inside <strong>\/etc\/grub.d\/<\/strong>.<\/p>\n<p>Adding <code>net.ifnames=0<\/code> and <code>biosdevname=0<\/code> to the Grub config makes the Linux kernel name interfaces like <code>eth*<\/code>.<\/p>\n<pre>GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"<\/pre>\n<p>Check out <strong>Clover<\/strong> [<a href=\"https:\/\/sourceforge.net\/p\/cloverefiboot\/wiki\/Home\/\">Link<\/a>] as an alternative to Grub. It is especially useful as a bootloader that runs from a thumb drive to boot from an NVMe drive on systems with older BIOS firmware that cannot do so directly.<\/p>\n<p>Remove the welcome banner:<\/p>\n<pre>touch .hushlogin<\/pre>\n<p>Command-line calendar:<\/p>\n<pre>cal<\/pre>\n<p>Create a Linux password hash:<\/p>\n<pre>mkpasswd -m sha-512<\/pre>\n<p>Refresh a cloned instance or virtual machine:<\/p>\n<pre>apt purge cloud-init -y\r\napt install cloud-init -y\r\nnano \/etc\/cloud\/cloud.cfg\r\ncloud-init clean\r\ncloud-init init<\/pre>\n<p>Package managers by distribution:<\/p>\n<ul>\n<li>apt &#8211; Debian<\/li>\n<li>pacman &#8211; Arch<\/li>\n<li>yum &#8211; CentOS<\/li>\n<li>dnf &#8211; Fedora<\/li>\n<li>zypper &#8211; openSUSE<\/li>\n<li>apk-tools &#8211; Alpine<\/li>\n<li>snap &#8211; Ubuntu-based<\/li>\n<li>flatpak &#8211; Multiple<\/li>\n<\/ul>\n<p>Flatpak basic commands:<\/p>\n<pre>sudo apt install <strong>flatpak gnome-software-plugin-flatpak<\/strong> -y\r\nflatpak remotes\r\nflatpak remote-add --if-not-exists flathub https:\/\/flathub.org\/repo\/flathub.flatpakrepo\r\nflatpak remote-delete flathub\r\nflatpak search firefox\r\nflatpak update\r\nflatpak list\r\nflatpak list --app\r\nflatpak history<\/pre>\n<p>Scheduling a shutdown:<\/p>\n<pre>shutdown -h 20\r\nshutdown +20\r\nshutdown -r 20\r\nshutdown -r +20\r\nshutdown -h 17:30<\/pre>\n<p>Cancel a scheduled shutdown:<\/p>\n<pre>shutdown -c<\/pre>\n<p>Managing processes with Supervisor:<\/p>\n<pre>sudo apt install <strong>supervisor<\/strong> -y\r\nsudo systemctl <strong>enable --now<\/strong> supervisor\r\nsudo nano \/etc\/supervisor\/conf.d\/<strong>appName<\/strong><\/pre>\n<pre>[program:<strong>appName<\/strong>]\r\ncommand=<strong>\/path\/to\/your\/app<\/strong>\r\nautostart=true\r\nautorestart=true\r\n<span class=\"hljs-attr\">startretries<\/span>=<span class=\"hljs-number\">3<\/span>\r\nstderr_logfile=\/var\/log\/<strong>appName<\/strong>.err.log\r\nstdout_logfile=\/var\/log\/<strong>appName<\/strong>.out.log\r\n<span class=\"hljs-attr\">environment<\/span>=HOME=<span class=\"hljs-string\">\"\/home\/<strong>user<\/strong>\"<\/span>,USER=<span class=\"hljs-string\">\"<strong>myUser<\/strong>\"<\/span><\/pre>\n<ul>\n<li><code>sudo supervisorctl reread<\/code>\n<ul>\n<li>Reload the configuration without restarting processes.<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl update<\/code>\n<ul>\n<li>Apply the updated configuration.<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl start appName<\/code>\n<ul>\n<li>Start a process.<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl stop appName<\/code>\n<ul>\n<li>Stop a process.<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl restart appName<\/code>\n<ul>\n<li>Restart a process.<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl restart all<\/code>\n<ul>\n<li>Restart all processes.<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl status<\/code>\n<ul>\n<li>List all managed processes and their statuses.<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl tail appName<\/code>\n<ul>\n<li>View logs for a specific process.<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl shutdown<\/code>\n<ul>\n<li>Stop Supervisor itself.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr id=\"Network\" \/>\n<p><strong>NETWORK<\/strong><\/p>\n<pre>hostname -I\r\nip address\r\nip route\r\nip neighbor\r\nip link\r\nsudo ip route add default via 192.168.2.1 dev wlan0\r\nsudo ip route add 10.0.0.0\/24 via 192.168.2.1 dev eth0\r\nsudo ip route del 10.0.0.0\/24 via 192.168.2.1 dev eth0\r\nip route get 8.8.8.8\r\nip route get 8.8.8.8 fibmatch\r\nip route get 8.8.8.8 from 192.168.1.100 fibmatch\r\nip -4 -br a s dev wth0\r\nip route show scope host table all\r\nip route show scope link\r\nip route show scope global\r\nip route show table main\r\nip route show table local\r\nip route show table default\r\nip rule\r\nnmcli device status\r\nnmcli con show\r\nnmcli connection show SSID\r\nnmcli connection show \"Wired connection 1\"\r\nnmcli -g ip4.address,ip4.dns connection show SSID\r\nss --tcp\r\nss --udp\r\nss --listening\r\nss -ltn\r\narp -e\r\narp -a\r\nsystemd-resolve --status\r\nresolvectl\r\nsudo systemctl restart systemd-resolved\r\nnslookup <strong>example.com<\/strong>\r\nnslookup -type=ns <strong>example.com<\/strong>\r\nnslookup -type=mx <strong>example.com<\/strong>\r\nnslookup -type=aaaa <strong>example.com<\/strong>\r\nnslookup -type=txt <strong>example.com<\/strong>\r\nnslookup <strong>8.8.4.4<\/strong>\r\nnetplan try\r\nnetplan apply\r\nnetplan generate<\/pre>\n<p>Measure the throughput of a network connection between client and server:<\/p>\n<pre>iperf -s                   # for the server\r\niperf -c <strong>10.0.0.1<\/strong>          # for the client<\/pre>\n<p>Check the process ID connected to a specific port, and list open ports:<\/p>\n<pre>lsof -i\r\nlsof -i :22\r\n(netstat -punta || ss --ntpu)\r\nsudo ss -ltpn<\/pre>\n<p>Capture \/ Sniff TCP traffic:<\/p>\n<pre>tcpdump -D\r\ntcpdump -i <strong>eth0<\/strong> -c 10 host <strong>8.8.4.4<\/strong>\r\ntcpdump -i <strong>eth0<\/strong> src host <strong>8.8.4.4<\/strong>\r\ntcpdump -i <strong>eth0<\/strong> dst host <strong>8.8.4.4<\/strong>\r\ntcpdump -i <strong>eth0<\/strong> net <strong>10.10.10.0<\/strong> mask <strong>255.255.255.0<\/strong>\r\ntcpdump -i <strong>eth0<\/strong> net <strong>10.10.10.0\/24<\/strong>\r\ntcpdump -i <strong>eth0<\/strong> port <strong>53<\/strong>\r\ntcpdump -i <strong>eth0<\/strong> host <strong>8.8.4.4<\/strong> and port <strong>53<\/strong>\r\ntcpdump -i <strong>eth0<\/strong> port not <strong>23<\/strong> and not <strong>22<\/strong>\r\ntcpdump -w <strong>network_traffic.pcap<\/strong>\r\ntimeout 10 tcpdump<\/pre>\n<p>Change network interface metric:<\/p>\n<pre>sudo apt install <strong>ifmetric<\/strong> -y\r\nsudo ifmetric <strong>wlx70f11c1927ef<\/strong> 599\r\nip route<\/pre>\n<p>Manage network connections over CLI:<\/p>\n<pre>nmtui<\/pre>\n<p>Check the routing path using Trace Route (ICMP) and Trace Path (UDP):<\/p>\n<pre>traceroute <strong>8.8.8.8<\/strong><\/pre>\n<pre>tracepath <strong>8.8.8.8<\/strong><\/pre>\n<p>Troubleshoot <code>conntrack<\/code>:<\/p>\n<pre>sudo apt install conntrack -y\r\nsudo conntrack -L\r\nsudo conntrack -L -p tcp\r\nsudo conntrack -S\r\ncat \/proc\/sys\/net\/netfilter\/nf_conntrack_count\r\ncat \/proc\/sys\/net\/netfilter\/nf_conntrack_max<\/pre>\n<hr id=\"PubIP\" \/>\n<p><strong>PUBLIC IP<\/strong><\/p>\n<pre>curl https:\/\/ipinfo.io\/ip\r\ncurl http:\/\/ipecho.net\/plain\r\ndig +short myip.opendns.com @resolver1.opendns.com\r\ndig -4 +short myip.opendns.com @resolver1.opendns.com\r\ndig -6 +short myip.opendns.com @resolver1.opendns.com<\/pre>\n<hr \/>\n<p><strong>API TEST<\/strong><\/p>\n<p>Use <strong>HTTPie<\/strong> to query and visualize HTTP headers [<a href=\"https:\/\/github.com\/httpie\/cli\">Link<\/a>].<\/p>\n<pre>sudo apt install <strong>httpie<\/strong> -y\r\nhttp <strong>example.com<\/strong><\/pre>\n<hr id=\"DNSUtils\" \/>\n<p><strong>DNS UTILITIES<\/strong><\/p>\n<pre>sudo apt install <strong>dnsutils<\/strong> -y\r\ndig <strong>example.com<\/strong>\r\ndig <strong>+trace<\/strong> example.com\r\nwhois <strong>example.com<\/strong>\r\nnmcli dev show | grep 'IP4.DNS'\r\nhost <strong>example.com<\/strong><\/pre>\n<p>Using Systemd Resolver:<\/p>\n<pre>systemd-resolve <strong>domain.com<\/strong>\r\nsystemd-resolve --status\r\nsystemd-resolve --flush-caches\r\nsudo systemctl restart systemd-resolved<\/pre>\n<p>OR<\/p>\n<pre>resolvectl status\r\nresolvectl flush-caches<\/pre>\n<p>To resolve any domain ending with .local to the same IP address:<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt install <strong>dnsmasq<\/strong> -y\r\necho 'address=\/.local\/<strong>10.10.10.100<\/strong>' &gt;&gt; \/etc\/dnsmasq.conf\r\necho 'server=8.8.8.8' &gt;&gt; \/etc\/dnsmasq.conf\r\necho 'server=1.1.1.1' &gt;&gt; \/etc\/dnsmasq.conf\r\nsudo systemctl restart dnsmasq<\/pre>\n<p>The configuration above resolves any domain ending with <code>.local<\/code> to <strong>10.10.10.100<\/strong>. All other domains are forwarded to Google and Cloudflare upstream servers, respectively.<\/p>\n<p>Do not forget to update the system resolver (<code>\/etc\/resolv.conf<\/code>) to point to <strong>127.0.0.1<\/strong>.<\/p>\n<hr id=\"Mounting\" \/>\n<p><strong>VOLUMES<\/strong><\/p>\n<p>Find mounted volumes in the system:<\/p>\n<pre>findmnt\r\nfindmnt -l<\/pre>\n<p>List all Samba\/Windows shares in your workgroup:<\/p>\n<pre>nmblookup -S WORKGROUP<\/pre>\n<p>List and connect to SMB shares:<\/p>\n<pre>smbclient -L \\\\\\\\<strong>192.168.1.10<\/strong>\r\nsmbclient \\\\\\\\<strong>192.168.1.10<\/strong>\\\\IPC$<\/pre>\n<p>Show the tree of hosts and shares in the Windows Network:<\/p>\n<pre>smbtree<\/pre>\n<p><strong>Manually mount<\/strong> a private share with <strong>write privileges<\/strong> for the current user:<\/p>\n<pre>sudo mount -t cifs -o username=${USER},password=${PASSWORD},uid=$(id -u),gid=$(id -g) <strong>\/\/server-address\/folder \/mount\/path\/on\/ubuntu<\/strong><\/pre>\n<p>Mount <strong>anonymous shares<\/strong> from SMB locally with read and write privileges for all users <strong>on boot<\/strong>:<\/p>\n<pre>\/\/<strong>192.168.1.10<\/strong>\/Public \/home\/<strong>user<\/strong>\/Public cifs rw,username=geek,password=geek,noperm 0 0<\/pre>\n<p>List <strong>NFS<\/strong> exports (locally and remotely):<\/p>\n<pre>showmount -e\r\nshowmount -e <strong>192.168.1.1<\/strong><\/pre>\n<p>Check and repair file system:<\/p>\n<pre>sudo umount \/dev\/<strong>sdb1<\/strong>\r\nsudo fsck -p \/dev\/<strong>sdb1<\/strong>\r\nsudo mount \/dev\/<strong>sdb1<\/strong><\/pre>\n<p><strong>Note:<\/strong> the <strong>-p<\/strong> option allows the tool to automatically repair problems that can be safely fixed without user intervention.<\/p>\n<p>Use Bind Mount to mount a directory inside another directory (like an alias, mirror, or mapping point):<\/p>\n<pre>sudo mount --bind <strong>\/PATH\/dataSource \/PATH\/mountLocation<\/strong>\r\nsudo mount --rbind <strong>\/PATH\/dataSource \/PATH\/mountLocationRecursive<\/strong><\/pre>\n<p>Check all real mount points on the system:<\/p>\n<pre>sudo findmnt --real<\/pre>\n<hr id=\"General\" \/>\n<p><strong>GENERAL LINUX TIPS<\/strong><\/p>\n<p>Send a message to all active terminal sessions:<\/p>\n<pre>sudo wall \"System under maintenance!\"<\/pre>\n<p>Prevent a package from being upgraded:<\/p>\n<pre>sudo apt-mark hold <strong>packageName<\/strong><\/pre>\n<p>Revert the hold above:<\/p>\n<pre>sudo apt-mark unhold <strong>packageName<\/strong><\/pre>\n<p>Get all hardware info:<\/p>\n<pre>sudo apt install -y <strong>hardinfo<\/strong><\/pre>\n<p>Create a backup of a file when editing with Nano:<\/p>\n<pre>nano -B <strong>fileName<\/strong><\/pre>\n<p>Basic Bash expansions:<\/p>\n<pre>mkdir name<strong>{1..10}<\/strong>\r\nmkdir name<strong>{a,b,c}<\/strong><\/pre>\n<p>Ways to create a file of a specific size:<\/p>\n<pre class=\"wp-block-preformatted\">truncate -s 10M <strong>fileName<\/strong>\r\nfallocate -l $((10*1024*1024)) <strong>fileName<\/strong>\r\nhead -c 10MB \/dev\/zero &gt; <strong>fileName<\/strong>\r\nhead -c 10MB \/dev\/urandom &gt; <strong>fileName<\/strong>\r\ndd if=\/dev\/zero bs=10MB count=1 of=<strong>fileName<\/strong>\r\ndd if=\/dev\/urandom bs=10MB count=1 of=<strong>fileName<\/strong><\/pre>\n<p>Safely overwrite all unused space on a drive:<\/p>\n<pre>dd if=\/dev\/random of=big || rm big<\/pre>\n<p>Cleanly kill processes:<\/p>\n<pre>sudo sigterm PID\r\nsudo sigkill PID\r\nsudo sigstop PID<\/pre>\n<p>Overwrite files before deleting:<\/p>\n<pre>shred -f -n 5 -z -u -v <strong>filename<\/strong><\/pre>\n<p>ARP scan to find all devices on the network (replace wlan0 with your interface):<\/p>\n<pre>sudo apt install <strong>arp-scan<\/strong> -y\r\nsudo arp-scan --interface=<strong>wlan0<\/strong> --localnet<\/pre>\n<p>Print file content to the terminal:<\/p>\n<pre>cat <strong>file.txt<\/strong> | more\r\ncat <strong>file.txt<\/strong> | less\r\nless <strong>file.txt<\/strong><\/pre>\n<p>Shortcut to rename or copy a file, useful for backups:<\/p>\n<pre>mv file.<strong>{conf,bkp}<\/strong>\r\ncp file.<strong>{conf,local}<\/strong><\/pre>\n<p>Execute a single command across multiple targets:<\/p>\n<pre>mkdir -p -v \/home\/josevnz\/tmp\/{dir1,dir2,dir3}<\/pre>\n<p>Create a unique temporary file or directory (useful to avoid collisions in automation scripts):<\/p>\n<pre>TMPFILE='mktemp' || exit 1\r\necho \"Temporary file name $TMPFILE\"<\/pre>\n<pre>TMPDIR='mktemp -d' || exit 1\r\necho \"Temporary directory name $TMPDIR\"<\/pre>\n<p>Measure latency between your device and another:<\/p>\n<pre>sudo apt install mtr\r\nmtr google.com<\/pre>\n<p>Check the ports your server is listening on:<\/p>\n<pre>netstat -lt\r\nnetstat -lu\r\nnetstat -nr\r\nnetstat -tulpn\r\nnetstat -s\r\nnetstat -tp\r\nnetstat -an | grep \"<strong>:22<\/strong>\"<\/pre>\n<p>Run a script to check for outdated shared libraries running on your server:<\/p>\n<pre>curl -s -L https:\/\/kernelcare.com\/uchecker | sudo python<\/pre>\n<p>Alternative to <strong>wget (axel)<\/strong> with multi-threading support:<\/p>\n<pre>axel -a -n 1 \"<strong>https:\/\/example.com\/file.zip<\/strong>\"<\/pre>\n<p><strong>Aria2<\/strong> is another alternative to wget and axel. It resumes interrupted downloads and supports multiple threads, torrents, and metalinks.<\/p>\n<pre>aria2c <strong>-s8<\/strong> \"https:\/\/example.com\/Linux.iso\"\r\naria2c <strong>-s8 -c<\/strong> \"https:\/\/example.com\/Linux.iso\"\r\naria2c <strong>--max-download-limit=1M<\/strong> \"https:\/\/example.com\/Linux.iso\"\r\naria2c <strong>-d \/path\/downloaded\/<\/strong> \"https:\/\/example.com\/Linux.iso\"\r\naria2c <strong>--http-proxy=http:\/\/proxy.com:8080<\/strong> \"https:\/\/example.com\/Linux.iso\"\r\naria2c <strong>-S<\/strong> linux.torrent\r\naria2c <strong>--select-file=6-8,10<\/strong> linux.torrent<\/pre>\n<p>Automate responses to repetitive prompts from an application or script (use with caution):<\/p>\n<pre>yes | <strong>command<\/strong>\r\nyes string | <strong>command<\/strong><\/pre>\n<p>See also the <code>expect<\/code> command for more granular automation based on expected prompts and responses.<\/p>\n<p>Record an entire terminal session, including commands, output, and prompts. The recording is saved to a file that can be replayed for auditing:<\/p>\n<pre>script --timing=<strong>record.Times<\/strong> <strong>record.Output<\/strong><\/pre>\n<p>To end the recorded session, type <code>exit<\/code>.<\/p>\n<pre>scriptreplay --timing=<strong>record.Times<\/strong> <strong>record.Output<\/strong>\r\nscriptreplay --timing=record.Times <strong>--speed 2<\/strong> record.Output\r\nscriptreplay --timing=record.Times <strong>--speed 0.5<\/strong> record.Output<\/pre>\n<p>You just ran a command without <code>sudo<\/code>. Try this:<\/p>\n<pre>ufw status\r\nsudo <strong>!!<\/strong><\/pre>\n<p>Or if the command was incomplete:<\/p>\n<pre>sudo apt\r\n<strong>!!<\/strong> update<\/pre>\n<p>Reuse the <strong>last word<\/strong> from the previous command:<\/p>\n<pre>mkdir <strong>directoryName<\/strong>\r\ncd <strong>!$<\/strong><\/pre>\n<p>Add a user to multiple groups:<\/p>\n<pre>sudo usermod -aG <strong>group1,group2,group3 user<\/strong><\/pre>\n<p>Remove a user from a group:<\/p>\n<pre>sudo gpasswd -d <strong>user groupName<\/strong><\/pre>\n<p>Change a user&#8217;s home directory and move its contents:<\/p>\n<pre>usermod -d \/home\/<strong>newHome<\/strong> --move-home <strong>userName<\/strong><\/pre>\n<p>Show a user&#8217;s password expiration information:<\/p>\n<pre>chage -l <strong>userName<\/strong><\/pre>\n<p>Change a user&#8217;s password expiration:<\/p>\n<pre>sudo chage -M <strong>90<\/strong> <strong>userName<\/strong>\r\nsudo chage -M <strong>2030-12-31<\/strong> <strong>userName<\/strong><\/pre>\n<p>Watch multiple log files at the same time (alternative to <code>tail -f<\/code>):<\/p>\n<pre>sudo apt install <strong>multitail<\/strong> -y\r\nmultitail <strong>kern.log syslog<\/strong><\/pre>\n<p>Watch a directory, file, or command output, refreshing every second:<\/p>\n<pre>watch -n 1 \"<strong>ls -l<\/strong>\"<\/pre>\n<p>Search for an application:<\/p>\n<pre>which <strong>nmap<\/strong>\r\nwhatis <strong>nmap<\/strong>\r\ndpkg --get-selections\r\ndpkg -l | grep <strong>sshfs<\/strong>\r\nrpm -qa | grep <strong>sshfs<\/strong><\/pre>\n<p>Install compilers and kernel headers to meet application installation requirements:<\/p>\n<pre>sudo apt install gcc make build-essential linux-headers-$(uname -r) -y<\/pre>\n<p>List installed kernel modules:<\/p>\n<pre>modprobe -h<\/pre>\n<p>Install and run 7-Zip to extract a .7z file:<\/p>\n<pre>sudo apt install p7zip p7zip-full p7zip-rar -y\r\n7z e <strong>file.7z<\/strong><\/pre>\n<p>List the contents of a ZIP file:<\/p>\n<pre>zipinfo -1 <strong>file.zip<\/strong>\r\nunzip -l <strong>file.zip<\/strong><\/pre>\n<p>Mount an archive file as a read-only volume:<\/p>\n<pre>archivemount <strong>fileName.tar.gz<\/strong> <strong>\/Path\/MountingPoint<\/strong><\/pre>\n<p>Place an executable in this folder to make it accessible system-wide:<\/p>\n<pre>echo $PATH\r\nmv <strong>script.sh<\/strong> \/usr\/local\/bin<\/pre>\n<p>View command history:<\/p>\n<pre>history<\/pre>\n<p>Check what the current user is allowed to run with <strong>sudo<\/strong>:<\/p>\n<pre>sudo -l<\/pre>\n<p>Allow a user to run <strong>sudo<\/strong> without a password prompt:<\/p>\n<pre>sudo nano \/etc\/sudoers.d\/<strong>userName<\/strong><\/pre>\n<p>Add the following:<\/p>\n<pre><strong>userName<\/strong> ALL=(ALL) NOPASSWD: ALL<\/pre>\n<p>Keep <strong>sudo<\/strong> active without prompting for a password <strong>during the session<\/strong>:<\/p>\n<pre>sudo -l<\/pre>\n<p>Check out <code>run0<\/code> as an alternative to <code>sudo<\/code>:<\/p>\n<pre>run0 <strong>commandName<\/strong><\/pre>\n<p>Lock and unlock users:<\/p>\n<pre>usermod -L <strong>userNameToLock<\/strong>\r\nusermod -U <strong>userNameToUnlock<\/strong><\/pre>\n<p>OR<\/p>\n<pre>passwd -u <strong>userNameToLock<\/strong>\r\npasswd -u <strong>userNameToUnlock<\/strong><\/pre>\n<p>Create a directory symbolic link:<\/p>\n<pre>ln -d -s <strong>\/targetFile<\/strong> <strong>\/symbolicLinkName<\/strong><\/pre>\n<p>Get the destination of a symbolic link:<\/p>\n<pre>readlink -m <strong>symbolicLinkName<\/strong><\/pre>\n<p>Transform piped input into arguments for a command:<\/p>\n<pre>ls | xargs <strong>cat<\/strong><\/pre>\n<p>Navigate to a user&#8217;s home directory:<\/p>\n<pre>cd ~<strong>userName<\/strong><\/pre>\n<p>Remove duplicate values and return only unique ones:<\/p>\n<pre>cat <strong>listOfItems.txt<\/strong> | sort | uniq<\/pre>\n<p>Pipe output to clipboard:<\/p>\n<pre>echo \"hi\" | xclip<\/pre>\n<p>Encode and decode Base64:<\/p>\n<pre>echo \"ABC\" | base64\r\necho \"QUJDCg==\" | base64 -d\r\nbase64 &lt;&lt;&lt; \"ABC\"\r\nbase64 -d &lt;&lt;&lt; \"QUJDCg==\"<\/pre>\n<p>Define variables in Bash and use them in commands:<\/p>\n<pre>export ip=<strong>10.0.0.1<\/strong> port=<strong>53<\/strong>\r\nnc -v $ip $port -e \/bin\/bash<\/pre>\n<p>Create an alias for a command (add to <strong>~\/.bash_aliases<\/strong>):<\/p>\n<pre>alias <strong>ll=\"ls -l\"<\/strong><\/pre>\n<p>Cut and merge videos with FFMPEG:<\/p>\n<pre>ffmpeg -i <strong>video1.mp4<\/strong> -ss <strong>00:01<\/strong> -to <strong>01:18<\/strong> <strong>output_1.mp4<\/strong>\r\nffmpeg -i <strong>video2.mp4<\/strong> -ss <strong>00:02<\/strong> -to <strong>01:01<\/strong> <strong>output_2.mp4<\/strong>\r\nffmpeg -f concat -i <strong>list.txt<\/strong> -c copy <strong>output_merged.mp4<\/strong><\/pre>\n<p>The list.txt file should contain the files to merge:<\/p>\n<pre style=\"padding-left: 40px;\">file <strong>output_1.mp4<\/strong>\r\nfile <strong>output_2.mp4<\/strong><\/pre>\n<p>Change the default start mode for VMs in VirtualBox to headless:<\/p>\n<pre>VBoxManage modifyvm \"<strong>vm name<\/strong>\" --defaultfrontend headless\r\nVBoxManage setproperty defaultfrontend headless<\/pre>\n<p>Run an application or script in the background, detached from the terminal:<\/p>\n<pre>nohup <strong>appToRunInBg.sh<\/strong> &amp;<\/pre>\n<p>Detach background jobs from your terminal session:<\/p>\n<pre>disown <strong>jobId<\/strong><\/pre>\n<p>Using the <code>&lt;<\/code> operator to pass file contents as input to a command:<\/p>\n<pre>cat &lt; <strong>fileName.txt<\/strong><\/pre>\n<p>Using the <code>&lt;&lt;<\/code> operator, useful for scripting:<\/p>\n<pre>telnet <strong>server.com<\/strong> &lt;&lt; EOL\r\n<strong>firstCommand\r\nsecondCommand<\/strong>\r\nEOL<\/pre>\n<p>Temporary file systems (tmpfs):<\/p>\n<ul>\n<li><code>\/dev\/shm<\/code>\n<ul>\n<li>always <strong>tmpfs<\/strong> (RAM).<\/li>\n<\/ul>\n<\/li>\n<li><code>\/tmp<\/code>\n<ul>\n<li>on-disk but can be <strong>tmpfs<\/strong>; does not retain files across reboots.<\/li>\n<\/ul>\n<\/li>\n<li><code>\/var\/tmp<\/code>\n<ul>\n<li>never on <strong>tmpfs<\/strong>; retains files across reboots.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Automate X via command line:<\/p>\n<pre>sudo apt install <strong>xautomation<\/strong> -y\r\nxte \"str Hello!\"\r\nxte \"key Return\"\r\nxte \"keydown Control_L\"\r\nxte \"keyup Control_L\"<\/pre>\n<p>Convert Markdown to PDF:<\/p>\n<pre>pandoc -o <strong>new.pdf original.md<\/strong><\/pre>\n<p>Manipulate PDF files:<\/p>\n<pre>sudo apt install <strong>qpdf<\/strong> -y<\/pre>\n<pre>qpdf --empty --pages <strong>cover.pdf pages*.pdf<\/strong> -- <strong>combined.pdf<\/strong>\r\nqpdf --empty --pages <strong>book-one.pdf 2-7 book-two.pdf 3,5<\/strong> -- <strong>selected-pages.pdf<\/strong>\r\nqpdf <strong>book.pdf book-page.pdf<\/strong> --split-pages          # output file names: book-page-1.pdf book-page-2.pdf ...\r\nqpdf --rotate=+90:1 <strong>original.pdf rotated.pdf<\/strong>\r\nqpdf --encrypt <strong>viewPassword<\/strong> <strong>editPassword<\/strong> <strong>256<\/strong> -- not-encrypted.pdf encrypted.pdf\r\nqpdf --decrypt --password=<strong>viewPassword<\/strong> encryted.pdf not-encrypted.pdf<\/pre>\n<ul>\n<li><strong>&#8212;<\/strong>\n<ul>\n<li>Refers to standard input when data is being piped.<\/li>\n<\/ul>\n<\/li>\n<li><strong>&#8211;empty<\/strong>\n<ul>\n<li>Tells qpdf not to expect an input file and to use piped data instead. Requires <strong>&#8212;<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<li><strong>&#8211;encrypt<\/strong>\n<ul>\n<li>Requires two passwords: one for viewing and one for editing. They can be the same, but if different, the security restrictions will apply accordingly.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Emulate a KVM (keyboard + video + mouse) switch to control multiple systems [<a href=\"https:\/\/github.com\/debauchee\/barrier\">Link<\/a>].<\/p>\n<p>Generate a 6-digit TOTP from a seed directly on the command line:<\/p>\n<pre>oathtool --totp -b <strong>SEED<\/strong><\/pre>\n<p>Unlike <code>&gt;<\/code>, which writes immediately, <code>sponge<\/code> buffers all input before writing. This is important when multiple processes write to the same file simultaneously.<\/p>\n<pre>sudo apt install <strong>moreutils<\/strong> -y\r\ncat <strong>read.data<\/strong> | sponge <strong>write.data<\/strong><\/pre>\n<p>Crawl and mirror a website:<\/p>\n<pre>wget --mirror --convert-links --adjust-extension --page-requisites --no-parent -P <strong>exampleBackup<\/strong> <strong>https:\/\/example.com\/path\/<\/strong><\/pre>\n<p>Rename multiple files and directories in a text editor:<\/p>\n<pre>sudo apt install <strong>moreutils<\/strong> -y\r\n<strong>vidir<\/strong><\/pre>\n<p>UEFI firmware upgrade:<\/p>\n<pre>sudo apt update\r\nsudo apt install <strong>fwupd<\/strong> -y\r\nsudo fwupdmgr get-devices\r\nsudo fwupdmgr refresh --force\r\nsudo fwupdmgr get-updates\r\nsudo fwupdmgr update<\/pre>\n<p>Upload all files from the current directory to FTP:<\/p>\n<pre>sudo apt install <strong>lftp<\/strong> -y\r\n<strong>lftp<\/strong> -u user:pass 192.168.0.10 -p 2221\r\n<strong>&gt;<\/strong> <strong>mput<\/strong> <strong>*<\/strong><\/pre>\n<hr id=\"Ubuntu\" \/>\n<p><strong>UBUNTU TIPS<\/strong><\/p>\n<p>Remove auto-mounted icons from the dock:<\/p>\n<pre>gsettings set org.gnome.shell.extensions.dash-to-dock show-mounts false<\/pre>\n<p>A powerful tool to configure your Gnome desktop (similar to Regedit on Windows, use with caution):<\/p>\n<pre>sudo apt install dconf-editor -y<\/pre>\n<p>Find, enable, and disable keyboard backlight (brightness from 0 to 3):<\/p>\n<pre>find \/sys\/class\/leds -name '*kbd_backlight'\r\necho 2 | sudo tee \/sys\/class\/leds\/dell::kbd_backlight\/brightness\r\necho 0 | sudo tee \/sys\/class\/leds\/dell::kbd_backlight\/brightness<\/pre>\n<p>Set the keyboard backlight timeout (in seconds):<\/p>\n<pre>sudo nano \/sys\/devices\/platform\/dell-laptop\/leds\/dell::kbd_backlight\/stop_timeout<\/pre>\n<p>Set the timezone and adjust the clock:<\/p>\n<pre>sudo timedatectl set-timezone <strong>America\/Toronto<\/strong>\r\nsudo date +%T -s \"<strong>23:59:59<\/strong>\"\r\nsudo date +%Y%m%d -s \"<strong>20220110<\/strong>\"<\/pre>\n<p>Install ClipGrab (video download tool) in Ubuntu 20.04 (from the Bionic repository):<\/p>\n<pre>sudo add-apt-repository <strong>ppa:clipgrab-team\/ppa<\/strong>    # <em>edit the repository list and change distribution from focal to bionic<\/em>\r\nsudo apt update &amp;&amp; sudo apt install <strong>clipgrab<\/strong> -y<\/pre>\n<p>Change the behavior when the laptop lid is closed in Ubuntu 20.04:<\/p>\n<pre>sudo gedit \/etc\/systemd\/logind.conf<\/pre>\n<pre>HandleLidSwitch=<strong>lock\/ignore\/poweroff\/hibernate<\/strong><\/pre>\n<pre>systemctl restart systemd-logind.service<\/pre>\n<p>Check the integrity of installed DEB packages and their dependencies:<\/p>\n<pre>sudo apt install <strong>debsums<\/strong> -y\r\ndebsums <strong>nano<\/strong>\r\nrdebsums <strong>nano<\/strong><\/pre>\n<p>Enable hibernation on Ubuntu 20.04:<\/p>\n<pre>sudo systemctl <strong>hibernate<\/strong><\/pre>\n<hr id=\"RPI\" \/>\n<p><strong>RASPBERRY PI TIPS<\/strong><\/p>\n<p>Set a different user as the default auto-login for Raspbian (<strong>autologin-user=pi<\/strong>, replace <strong>pi<\/strong> with your desired username):<\/p>\n<pre>nano \/etc\/lightdm\/lightdm.conf<\/pre>\n<p>List all USB devices connected to your machine:<\/p>\n<pre>lsusb<\/pre>\n<p>Remove line 8 from a text file:<\/p>\n<pre>sed -i '<strong>8d<\/strong>' <strong>~\/.ssh\/known_hosts<\/strong><\/pre>\n<p>Redirect output to null (useful with crontab):<\/p>\n<pre>&gt; \/dev\/null 2&gt;&amp;1<\/pre>\n<p>Install all .deb files from the current directory:<\/p>\n<pre>sudo dpkg -i *.deb<\/pre>\n<p>Check disk and RAM usage:<\/p>\n<pre>sudo free\r\nsudo df -h\r\nsudo du -sh \/\r\nsudo du -sh \/*\r\nsudo du -had 1 . | sort -rh\r\nsudo du -Sh \/ | sort -rh | head -5\r\nsudo ncdu \/<\/pre>\n<p>Show <strong>progress<\/strong> while copying or transferring large files:<\/p>\n<pre>pv <strong>file.zip<\/strong> &gt; <strong>\/tmp\/file.zip<\/strong><\/pre>\n<p>Block ping responses in Ubuntu\/Debian:<\/p>\n<pre>sudo nano \/etc\/sysctl.conf<\/pre>\n<pre>net.ipv4.icmp_echo_ignore_all = 1<\/pre>\n<pre>sudo sysctl -p<\/pre>\n<p>Online services to test your server&#8217;s IPv6 connectivity:<\/p>\n<pre>https:\/\/tools.keycdn.com\/ipv6-ping\r\nhttps:\/\/ipv6-test.com\/validate.php<\/pre>\n<p>Keyboard-driven web browser for the CLI:<\/p>\n<pre>sudo apt install <strong>lynx<\/strong> -y\r\nlynx <strong>http:\/\/www.google.com<\/strong><\/pre>\n<pre>sudo apt install <strong>links<\/strong> -y\r\nlynx <strong>http:\/\/example.com<\/strong><\/pre>\n<p>Convert images in batches:<\/p>\n<pre>mogrify -format <strong>jpg<\/strong> *.png<\/pre>\n<p>Batch resize images:<\/p>\n<pre>mogrify -resize <strong>x400<\/strong> *.jpeg<\/pre>\n<p>OR<\/p>\n<pre>mkdir -p <strong>resized<\/strong> &amp;&amp; mogrify -path <strong>resized<\/strong> -resize x400 *.jpeg<\/pre>\n<p>Convert iPhone .HEIC images to .JPG:<\/p>\n<pre>sudo apt install <strong>libheif-examples<\/strong> -y\r\nfor i in *.HEIC; do heif-convert \"$i\" \"${i%.HEIC}.jpg\"; done<\/pre>\n<p>OR<\/p>\n<pre>sudo apt install <strong>libheif-examples<\/strong> -y\r\nls *.HEIC | xargs -n 1 -P 5 sh -c 'heif-convert \"$1\" \"${1%.HEIC}.jpg\"' _<\/pre>\n<p>Convert iPhone .MOV videos to .MP4:<\/p>\n<pre>sudo apt install <strong>ffmpeg<\/strong> -y\r\nls *.MOV | xargs -n 1 -P 5 -I {} bash -c 'ffmpeg -y -i \"$1\" -map_metadata 0 -movflags +faststart -c:v libx264 -crf 18 -preset slow -c:a aac -b:a 192k \"${1%.*}.mp4\"' _ {}<\/pre>\n<p>Return to the previous directory:<\/p>\n<pre>cd <strong>-<\/strong><\/pre>\n<pre>pushd \/var\r\n...\r\npopd<\/pre>\n<p>Matrix screensaver in the terminal:<\/p>\n<pre>sudo apt install <strong>cmatrix<\/strong> -y\r\ncmatrix<\/pre>\n<p>Print input in columns:<\/p>\n<pre>mount | column -t<\/pre>\n<p>Terminal shortcuts:<\/p>\n<ul>\n<li>ctrl+l &#8211; Clear screen.<\/li>\n<li>ctrl+u &#8211; Clear line.<\/li>\n<li>ctrl+r &#8211; Search command history.<\/li>\n<\/ul>\n<hr id=\"Kali\" \/>\n<p><strong>KALI TIPS<\/strong><\/p>\n<p>Toggle a theme that makes Kali look like Windows 10:<\/p>\n<pre>kali-undercover<\/pre>\n<p>Fix Kali issues after an upgrade:<\/p>\n<pre>sudo apt install <strong>xfce4-settings<\/strong> -y<\/pre>\n<p>Manage the GNOME keyring:<\/p>\n<pre>sudo apt install <strong>seahorse<\/strong> -y<\/pre>\n<p>Then open the start menu and search for <strong>Passwords and Keys<\/strong>.<\/p>\n<p>Disable hardware beep (consider adding to <strong>\/etc\/rc.local<\/strong>):<\/p>\n<pre>#!\/bin\/bash\r\nrmmod pcspkr\r\nexit 0<\/pre>\n<p>Create the service file <strong>\/etc\/systemd\/system\/rc-local.service<\/strong>:<\/p>\n<pre>[Unit]\r\n Description=\/etc\/rc.local Compatibility\r\n ConditionPathExists=\/etc\/rc.local\r\n\r\n[Service]\r\n Type=forking\r\n ExecStart=\/etc\/rc.local start\r\n TimeoutSec=0\r\n StandardOutput=tty\r\n RemainAfterExit=yes\r\n SysVStartPriority=99\r\n\r\n[Install]\r\n WantedBy=multi-user.target<\/pre>\n<p>Mark as executable and enable the service on boot:<\/p>\n<pre>sudo chmod +x \/etc\/rc.local\r\nsudo systemctl enable rc-local<\/pre>\n<p>Adjust the vertical and horizontal position of a display:<\/p>\n<pre>xrandr\r\nxrandr --output <strong>DP-1-3<\/strong> --panning 1920x1080 --transform 1,0,-4,0,1,-5,0,0,1<\/pre>\n<p>The first command lists display names. Replace DP-1-3 with the display you want to adjust.<\/p>\n<p>Full upgrade:<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt full-upgrade -y\r\n[ -f \/var\/run\/reboot-required ] &amp;&amp; sudo reboot -f<\/pre>\n<p>Userspace reboot (Soft Reboot) restarts everything except the kernel and firmware:<\/p>\n<pre>sudo systemctl <strong>soft-reboot<\/strong><\/pre>\n<p>Manage handlers for lid, power, and other switches:<\/p>\n<pre>sudo nano \/etc\/systemd\/logind.conf<\/pre>\n<p>Remote Desktop:<\/p>\n<pre>sudo apt install -y novnc x11vnc\r\nx11vnc -display :0 -autoport -localhost -nopw -bg -xkb -ncache -ncache_cr -quiet -forever\r\n\/usr\/share\/novnc\/utils\/launch.sh --listen 8081 --vnc localhost:5900\r\nss -antp | grep vnc<\/pre>\n<p>Create an SSH tunnel for VNC:<\/p>\n<pre>ssh <strong>userName@192.168.1.10<\/strong> -L 5900:localhost:5900<\/pre>\n<p>PDF tools pre-installed in Kali:<\/p>\n<pre>pdftotext <strong>fileName.pdf<\/strong> output.txt\r\npdftohtml <strong>fileName.pdf<\/strong> output.html<\/pre>\n<hr id=\"Forensics\" \/>\n<p><strong>FORENSICS TOOLS<\/strong><\/p>\n<p>Safely erase files in Linux with BleachBit (also available for Windows):<\/p>\n<pre>sudo apt install <strong>bleachbit<\/strong> -y\r\n<strong>sudo<\/strong> bleachbit<\/pre>\n<p>=&gt; Windows version available at <a href=\"https:\/\/www.bleachbit.org\/\">https:\/\/www.bleachbit.org\/<\/a>.<br \/>\n=&gt; Alternative: Eraser, available at <a href=\"https:\/\/eraser.heidi.ie\/\">https:\/\/eraser.heidi.ie\/<\/a>.<\/p>\n<p>Encrypt system, disk, and volumes in Windows:<\/p>\n<pre>VeraCrypt available at <a href=\"https:\/\/www.veracrypt.fr\/\">https:\/\/www.veracrypt.fr\/<\/a>.<\/pre>\n<p>Create a 1GB file for download testing or other purposes:<\/p>\n<pre>sudo dd if=\/dev\/zero of=<strong>1gb.zip<\/strong> bs=1 count=0 seek=$[1024*1024*1024]<\/pre>\n<p>Write an ISO file to a USB drive using DD:<\/p>\n<pre>sudo dd bs=4M if=<strong>file.iso<\/strong> of=\/dev\/<strong>sdX<\/strong> conv=fdatasync status=progress<\/pre>\n<p>OR<\/p>\n<pre>sudo dd if=Downloads\/<strong>file.iso<\/strong> of=\/dev\/sda1 bs=1M status=progress<\/pre>\n<hr id=\"WDNAS\" \/>\n<p><strong>WESTERN DIGITAL NAS<\/strong><\/p>\n<p>Mount WD MyCloud Home in Linux manually:<\/p>\n<pre>sudo mount -t cifs \/\/mycloud\/Public \/home\/<strong>user<\/strong>\/MyCloud\/ -o username=geek,password=geek,uid=$(id -u),gid=$(id -g),forceuid,forcegid<\/pre>\n<p>Mount WD MyCloud Home in Linux automatically via <code>\/etc\/fstab<\/code>:<\/p>\n<pre>\/\/mycloud\/Public \/home\/<strong>user<\/strong>\/MyCloud\/ cifs username=geek,password=geek,iocharset=utf8,file_mode=0777,dir_mode=0777<\/pre>\n<p><strong>WORKING WITH STRINGS AND FILES<\/strong><\/p>\n<p>Count the number of lines and the length of the longest line in a file:<\/p>\n<pre>wc -l <strong>\/directory\/file.txt<\/strong>\r\nwc -L <strong>\/directory\/file.txt<\/strong><\/pre>\n<p>Search for files containing a specific string:<\/p>\n<pre>grep -l '<strong>text<\/strong>' *.*<\/pre>\n<p>Search for a string in compressed files:<\/p>\n<pre>zcat <strong>fileName.gz<\/strong> | grep -l '<strong>text<\/strong>'\r\nzgrep -l '<strong>text<\/strong>' *.*<\/pre>\n<p>See also <strong>zmore<\/strong>, <strong>zless<\/strong>, and <strong>zdiff<\/strong>.<\/p>\n<p>Find the position and line number of a specific byte (in hex) in a file:<\/p>\n<pre><span class=\"\">grep -aob $'<strong>\\x9d<\/strong>' fileName.txt\r\n<\/span>sed -n '\/<strong>\\x9d<\/strong>\/=' fileName.txt<\/pre>\n<p>Grep with inverted match (returns lines that do not match the pattern):<\/p>\n<pre>cat fileName | grep <strong>-v<\/strong> 'string'<\/pre>\n<p>Search for a string in files recursively:<\/p>\n<pre>grep -R '<strong>password<\/strong>' --include='*.py' --color \/path<\/pre>\n<p>Print file content in reverse line order:<\/p>\n<pre>tac <strong>file.txt<\/strong><\/pre>\n<p>Wrap output to fit a specified width (default: 80 columns):<\/p>\n<pre>fold <strong>file.txt<\/strong>\r\nfold -w60 <strong>file.txt<\/strong>\r\nfold -s <strong>file.txt<\/strong><\/pre>\n<p>Compare files:<\/p>\n<pre>diff <strong>file1.txt file2.txt<\/strong><\/pre>\n<p>Get information about a file:<\/p>\n<pre>file <strong>file.zip<\/strong>\r\nstat <strong>file.txt<\/strong><\/pre>\n<p>Print the readable strings from a binary file:<\/p>\n<pre>strings <strong>binaryFile<\/strong><\/pre>\n<p>Inspect binary files in hex format:<\/p>\n<pre>xxd <strong>binaryFile<\/strong>\r\nxxd -s 0x000123abc <strong>binaryFile<\/strong> | head -n 5<\/pre>\n<p>Note: the second example seeks the given offset and prints only 5 lines. This is useful for inspecting content at a specific position within a large file.<\/p>\n<p>Print numbers from 1 to 10 separated by spaces:<\/p>\n<pre>echo <strong>{1..10}<\/strong><\/pre>\n<p>Usage of <strong>cut<\/strong>: <code>-d \" \"<\/code> sets the delimiter to a space, and <code>-f 4<\/code> selects the fourth column.<\/p>\n<pre>echo \"<strong>a b c d e f g<\/strong>\" | cut -d \" \" -f 4<\/pre>\n<p>Usage of <strong>tr<\/strong>: <code>-d \" \"<\/code> deletes spaces; <code>\" \" \"\\n\"<\/code> replaces spaces with newlines; <code>[a-z] [A-Z]<\/code> converts lowercase to uppercase; <code>-s \"a\"<\/code> squeezes repeated characters to one; <code>-cd [:digit:]<\/code> keeps only digits; <code>-d [:digit:]<\/code> removes digits.<\/p>\n<pre>echo \"a b\" | tr -d \" \"\r\necho \"a b\" | tr \" \" \"\\n\"\r\necho \"a b\" | tr [a-z] [A-Z]\r\necho \"a b\" | tr [:lower:] [:upper:]\r\necho \"aaa\" | tr -s \"a\"\r\necho \"a1b\" | tr -cd [:digit:]\r\necho \"a1b\" | tr -d [:digit:]<\/pre>\n<p>Reverse the order of characters:<\/p>\n<pre>echo \"<strong>ABC<\/strong>\" | rev<\/pre>\n<hr id=\"ESXi\" \/>\n<p><strong>VMWARE ESXi TIPS<\/strong><\/p>\n<p>Enable external USB drives as datastores:<\/p>\n<pre>\/etc\/init.d\/usbarbitrator stop\r\nchkconfig usbarbitrator off\r\nls \/dev\/disks\/<\/pre>\n<p>Prepare the disk:<\/p>\n<pre>partedUtil mklabel \/dev\/disks\/<span style=\"color: #ff0000;\"><strong>mpx.vmhba33:C0:T0:L0<\/strong><\/span> gpt\r\neval expr $(partedUtil getptbl \/dev\/disks\/<span style=\"color: #ff0000;\"><strong>mpx.vmhba33:C0:T0:L0<\/strong><\/span> | tail -1 | awk '{print $1 \" \\\\* \" $2 \" \\\\* \" $3}') - 1\r\npartedUtil setptbl \/dev\/disks\/<span style=\"color: #ff0000;\"><strong>mpx.vmhba33:C0:T0:L0<\/strong><\/span> gpt \"1 2048 <span style=\"color: #ff6600;\"><strong>9999999999<\/strong><\/span> AA31E02A400F11DB9590000C2911D1B8 0\"\r\nvmkfstools -C vmfs6 -S USB-Datastore \/dev\/disks\/<span style=\"color: #ff0000;\"><strong>mpx.vmhba33:C0:T0:L0<\/strong><\/span>:1<\/pre>\n<p>Note: replace <strong><span style=\"color: #ff0000;\">mpx.vmhba33:C0:T0:L0<\/span><\/strong> with your actual USB disk path, and <span style=\"color: #ff6600;\"><strong>9999999999<\/strong><\/span> with the last sector calculated by the second command.<\/p>\n<hr id=\"NVIDIA\" \/>\n<p><strong>NVIDIA DRIVERS<\/strong><\/p>\n<p>Check the GPU model, add repositories, and install the driver.<\/p>\n<pre>lspci | grep -iE \"3d|display|vga\" | grep -i nvidia<\/pre>\n<p><strong>Newer Hardware<\/strong><\/p>\n<pre>sudo apt install nvidia-detect -y\r\nsudo nvidia-detect<\/pre>\n<p>If a driver is available for your hardware, an installation command will be shown. It will likely be:<\/p>\n<pre>sudo apt install <strong>nvidia-driver<\/strong> -y &amp;&amp; sudo reboot<\/pre>\n<p><strong>Older Hardware<\/strong><\/p>\n<p>It is strongly recommended to disable the open-source <code>nouveau<\/code> kernel module, which often conflicts with NVIDIA&#8217;s drivers.<\/p>\n<pre>echo 'blacklist nouveau' | sudo tee \/etc\/modprobe.d\/blacklist-nouveau.conf\r\necho 'options nouveau modeset=0' | sudo tee -a \/etc\/modprobe.d\/blacklist-nouveau.conf\r\nsudo update-initramfs -u &amp;&amp; sudo reboot<\/pre>\n<p>First check if your specific model has an installer on the official NVIDIA website [<a href=\"https:\/\/www.nvidia.com\/en-us\/drivers\/\">Link<\/a>].<\/p>\n<p>For some models, the installation route may be:<\/p>\n<pre>sudo sed -i 's\/main\/main non-free contrib\/g' \/etc\/apt\/sources.list<\/pre>\n<p>Or:<\/p>\n<pre>sudo sed -i 's\/main\/main non-free contrib\/g' \/etc\/apt\/sources.list.d\/<strong>debian<\/strong>.sources<\/pre>\n<p>Or:<\/p>\n<pre>sudo apt-add-repository <strong>contrib<\/strong> &amp;&amp; sudo apt-add-repository <strong>non-free<\/strong> &amp;&amp; sudo apt update<\/pre>\n<p>Drivers for legacy hardware can be installed as follows:<\/p>\n<pre>sudo apt install <strong>--no-install-recommends<\/strong> <strong>nvidia-tesla-535-driver nvidia-tesla-535-kernel-dkms<\/strong> nvidia-smi -y<\/pre>\n<p>Or:<\/p>\n<pre>sudo apt install <strong>nvidia-legacy-390xx-driver<\/strong> nvidia-smi -y<\/pre>\n<p>Or:<\/p>\n<pre>apt-get install <strong>nvidia-driver-pinning-580<\/strong> nvidia-smi -y<\/pre>\n<p>Reboot and verify:<\/p>\n<pre>sudo reboot\r\nsudo lsmod | grep nvidia\r\nsudo nvidia-smi<\/pre>\n<p>Hold (lock) the package to prevent upgrades:<\/p>\n<pre>sudo apt-mark hold <strong>nvidia-legacy-390xx-driver<\/strong><\/pre>\n<p>For use with Docker and GPU workloads:<\/p>\n<pre>curl -fsSL https:\/\/nvidia.github.io\/libnvidia-container\/gpgkey | sudo gpg --dearmor -o \/usr\/share\/keyrings\/nvidia-container-toolkit-keyring.gpg\r\ncurl -s -L https:\/\/nvidia.github.io\/libnvidia-container\/stable\/deb\/nvidia-container-toolkit.list | sed 's#deb https:\/\/#deb [signed-by=\/usr\/share\/keyrings\/nvidia-container-toolkit-keyring.gpg] https:\/\/#g' | sudo tee \/etc\/apt\/sources.list.d\/nvidia-container-toolkit.list\r\nsudo apt-get update\r\nsudo apt-get install -y nvidia-container-toolkit\r\nsudo systemctl restart docker<\/pre>\n<hr id=\"AMD\" \/>\n<p><strong>AMD GPU Drivers<\/strong><\/p>\n<p><strong>On Ubuntu:<\/strong><\/p>\n<pre>sudo apt install build-essential dkms linux-headers-amd64 wget curl rsync -y\r\nwget https:\/\/repo.radeon.com\/amdgpu-install\/latest\/ubuntu\/noble\/amdgpu-install_<strong>7.2.4.70204-1<\/strong>_all.deb\r\nsudo dpkg -i amdgpu-install*.deb\r\nsudo apt update &amp;&amp; sudo apt upgrade -y<\/pre>\n<p>For Mesa (+ Vulkan):<\/p>\n<pre>sudo amdgpu-install -y --accept-eula --opencl=rocr --opengl=mesa --vulkan=pro<\/pre>\n<p><strong>OR<\/strong> for ROCm:<\/p>\n<pre>sudo amdgpu-install -y --usecase=rocm<\/pre>\n<p>Verify the installation:<\/p>\n<pre>sudo dmesg | grep -i amdgpu\r\nsudo lshw -c video<\/pre>\n<p><strong>On Debian:<\/strong><\/p>\n<pre>sudo apt update\r\nsudo apt install rocminfo libamdhip64-5 rocm-smi -y<\/pre>\n<p>Verify that the kernel module loads properly:<\/p>\n<pre>sudo rocminfo\r\nsudo rocm-smi<\/pre>\n<p>The <strong>AMD Radeon RX 6400<\/strong> is based on the <strong>RDNA 2 architecture<\/strong> (specifically the <code>gfx1034<\/code> microarchitecture) and is not officially supported by ROCm. A workaround is to trick ROCm into treating it as a supported card, such as the RX 6800 (<code>gfx1030<\/code>).<\/p>\n<p>Since I was previously running with an NVIDIA card, I had to reinstall Ollama so it pulls the ROCm libraries instead.<\/p>\n<pre>curl -fsSL https:\/\/ollama.com\/install.sh | sudo sh\r\nsudo systemctl edit ollama<\/pre>\n<p>You may also need to disable CUDA (NVIDIA):<\/p>\n<pre>[Service]\r\nEnvironment=\"OLLAMA_VULKAN=1\"\r\n# Radeon\r\n#Environment=\"GGML_VK_VISIBLE_DEVICES=0\"\r\n# Nvidia\r\n#Environment=\"GGML_VK_VISIBLE_DEVICES=1\"<\/pre>\n<p>Leaving <code>GGML_VK_VISIBLE_DEVICES<\/code> unset allows Ollama to use both GPUs as needed.<\/p>\n<pre>sudo systemctl daemon-reload\r\nsudo systemctl restart ollama<\/pre>\n<p>This is also a useful tool for listing available GPUs:<\/p>\n<pre>sudo apt install mesa-vulkan-drivers vulkan-tools\r\nvulkaninfo --summary<\/pre>\n<p>Results of running a model that fits in neither the 8GB NVIDIA nor the 4GB Radeon alone, but works across both combined:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5991\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-38-36.png\" alt=\"\" width=\"757\" height=\"43\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-38-36.png 757w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-38-36-300x17.png 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><\/p>\n<p>About 7.3GB on NVIDIA.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5992\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-39-24.png\" alt=\"\" width=\"770\" height=\"377\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-39-24.png 770w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-39-24-300x147.png 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-39-24-768x376.png 768w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/p>\n<p>The rest on AMD.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5993\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-40-50.png\" alt=\"\" width=\"964\" height=\"162\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-40-50.png 964w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-40-50-300x50.png 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/09\/Screenshot_2026-07-16_08-40-50-768x129.png 768w\" sizes=\"auto, (max-width: 964px) 100vw, 964px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CATEGORIES System and Environment Network Public IP DNS Utilities Mounting Volumes General Linux Tips Ubuntu [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-216","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=216"}],"version-history":[{"count":284,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions"}],"predecessor-version":[{"id":5994,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions\/5994"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}