{"id":216,"date":"2020-09-26T13:31:33","date_gmt":"2020-09-26T13:31:33","guid":{"rendered":"https:\/\/dft.wiki\/?p=216"},"modified":"2026-04-21T14:22:30","modified_gmt":"2026-04-21T18:22:30","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><span data-offset-key=\"e176a894f29244fc836579077fee2a91:0\"><span class=\"prism-token token 2 function \">sudo hostnamectl set-hostname <strong>newHostName<\/strong>\r\nid<\/span><\/span> <span data-offset-key=\"e176a894f29244fc836579077fee2a91:2\"><span class=\"prism-token token 4 operator \">||<\/span><\/span> <span data-offset-key=\"e176a894f29244fc836579077fee2a91:4\"><span class=\"prism-token token 6 punctuation \">(<\/span><\/span><span data-offset-key=\"e176a894f29244fc836579077fee2a91:5\"><span class=\"prism-token token 7\">whoami <\/span><\/span><span data-offset-key=\"e176a894f29244fc836579077fee2a91:6\"><span class=\"prism-token token 8 operator \">&amp;&amp;<\/span><\/span><span data-offset-key=\"e176a894f29244fc836579077fee2a91:7\"><span class=\"prism-token token 9\"> groups<\/span><\/span><span data-offset-key=\"e176a894f29244fc836579077fee2a91:8\"><span class=\"prism-token token 10 punctuation \">)<\/span><\/span><span data-offset-key=\"e176a894f29244fc836579077fee2a91:9\"><span class=\"prism-token token 11\"> 2<\/span><\/span><span data-offset-key=\"e176a894f29244fc836579077fee2a91:10\"><span class=\"prism-token token 12 operator \">&gt;<\/span><\/span><span data-offset-key=\"e176a894f29244fc836579077fee2a91:11\" data-slate-fragment=\"JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJjb2RlJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTIyc3ludGF4JTIyJTNBJTIyYmFzaCUyMiU3RCUyQyUyMm5vZGVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIyYmxvY2slMjIlMkMlMjJ0eXBlJTIyJTNBJTIyY29kZS1saW5lJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJ0ZXh0JTIyJTJDJTIybGVhdmVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIybGVhZiUyMiUyQyUyMnRleHQlMjIlM0ElMjJpZCUyMCU3QyU3QyUyMCh3aG9hbWklMjAlMjYlMjYlMjBncm91cHMpJTIwMiUzRSUyRmRldiUyRm51bGwlMjIlMkMlMjJtYXJrcyUyMiUzQSU1QiU1RCU3RCU1RCU3RCU1RCU3RCU1RCU3RCU1RCU3RA==\"><span class=\"prism-token token 13\">\/dev\/null<\/span><\/span>\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\narch\r\nlsb_release -rd\r\ncat \/proc\/version\r\n(cat \/proc\/version || uname -a ) 2&gt;\/dev\/null\r\n<span data-offset-key=\"dea70944ad1141bf99ef758dbc865415:0\"><span class=\"prism-token token punctuation \">systemctl show-environment\r\n<\/span><\/span><span data-offset-key=\"dea70944ad1141bf99ef758dbc865415:1\"><span class=\"prism-token token 1\">env\r\n<\/span><\/span><span data-offset-key=\"dea70944ad1141bf99ef758dbc865415:3\"><span class=\"prism-token token 3\">set\r\n<\/span><\/span>uptime\r\nlsblk\r\nlsblk -f\r\n<span data-slate-fragment=\"JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJjb2RlJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTIyc3ludGF4JTIyJTNBJTIyYmFzaCUyMiU3RCUyQyUyMm5vZGVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIyYmxvY2slMjIlMkMlMjJ0eXBlJTIyJTNBJTIyY29kZS1saW5lJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJ0ZXh0JTIyJTJDJTIybGVhdmVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIybGVhZiUyMiUyQyUyMnRleHQlMjIlM0ElMjJsc2NwdSUyMiUyQyUyMm1hcmtzJTIyJTNBJTVCJTVEJTdEJTVEJTdEJTVEJTdEJTVEJTdEJTVEJTdE\">lscpu\r\nlsusb\r\nlspci\r\nlspci -vvv\r\nlsmod\r\necho $SHELL\r\necho $HOME\r\nreset\r\nman <strong>commantName<\/strong>\r\ntldr <strong>commandName<\/strong>\r\napropos <strong>commandName<\/strong>\r\nsystemd-analyze\r\nsystemd-analyze blame\r\nsystemd-analyse critical chain\r\n<\/span><\/pre>\n<p>Manage physical (discrete) memory:<\/p>\n<pre><span data-slate-fragment=\"JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJjb2RlJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTIyc3ludGF4JTIyJTNBJTIyYmFzaCUyMiU3RCUyQyUyMm5vZGVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIyYmxvY2slMjIlMkMlMjJ0eXBlJTIyJTNBJTIyY29kZS1saW5lJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJ0ZXh0JTIyJTJDJTIybGVhdmVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIybGVhZiUyMiUyQyUyMnRleHQlMjIlM0ElMjJsc2NwdSUyMiUyQyUyMm1hcmtzJTIyJTNBJTVCJTVEJTdEJTVEJTdEJTVEJTdEJTVEJTdEJTVEJTdE\">dmidecode -t memory\r\nlsmem\r\nlsmem -a\r\nchmem -d 0x0000000878000000-0x000000087fffffff\r\nchmem -e -b 271<\/span><\/pre>\n<p>History of commands:<\/p>\n<pre><span data-slate-fragment=\"JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJjb2RlJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTIyc3ludGF4JTIyJTNBJTIyYmFzaCUyMiU3RCUyQyUyMm5vZGVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIyYmxvY2slMjIlMkMlMjJ0eXBlJTIyJTNBJTIyY29kZS1saW5lJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJ0ZXh0JTIyJTJDJTIybGVhdmVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIybGVhZiUyMiUyQyUyMnRleHQlMjIlM0ElMjJsc2NwdSUyMiUyQyUyMm1hcmtzJTIyJTNBJTVCJTVEJTdEJTVEJTdEJTVEJTdEJTVEJTdEJTVEJTdE\">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\r\n<\/span><\/pre>\n<p>Preventing a command from being logged in the history if it starts with a space character (~\/.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&#8217;s ring buffer messages being sent to the syslog since the last boot (human timestamp, watch as it happens, 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 of the system:<\/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\r\n<\/strong><\/pre>\n<p>Enable lingering (processes to still running after 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 is capable of monitoring and intercepting filesystem events.<\/p>\n<p>List users, list super-users, who are logged, last logged users, the last login by users, and list all users and groups:<\/p>\n<pre>cat \/etc\/passwd | cut -d: -f1\r\n<span data-offset-key=\"9d43d2f7f991427b930f08811a19ee69:0\"><span class=\"prism-token token 34 function \">awk<\/span><\/span><span data-offset-key=\"9d43d2f7f991427b930f08811a19ee69:1\"><span class=\"prism-token token 35\"> -F: <\/span><\/span><span data-offset-key=\"9d43d2f7f991427b930f08811a19ee69:2\"><span class=\"prism-token token 36 string \">'(<\/span><\/span><span data-offset-key=\"9d43d2f7f991427b930f08811a19ee69:3\"><span class=\"prism-token token 36 string variable \">$3<\/span><\/span><span data-offset-key=\"9d43d2f7f991427b930f08811a19ee69:4\"><span class=\"prism-token token 36 string \"> == \"0\") {print}'<\/span><\/span><span data-offset-key=\"9d43d2f7f991427b930f08811a19ee69:5\" data-slate-fragment=\"JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJjb2RlJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTIyc3ludGF4JTIyJTNBJTIyYmFzaCUyMiU3RCUyQyUyMm5vZGVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIyYmxvY2slMjIlMkMlMjJ0eXBlJTIyJTNBJTIyY29kZS1saW5lJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJ0ZXh0JTIyJTJDJTIybGVhdmVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIybGVhZiUyMiUyQyUyMnRleHQlMjIlM0ElMjJhd2slMjAtRiUzQSUyMCcoJTI0MyUyMCUzRCUzRCUyMCU1QyUyMjAlNUMlMjIpJTIwJTdCcHJpbnQlN0QnJTIwJTJGZXRjJTJGcGFzc3dkJTIyJTJDJTIybWFya3MlMjIlM0ElNUIlNUQlN0QlNUQlN0QlNUQlN0QlNUQlN0QlNUQlN0Q=\"><span class=\"prism-token token 37\"> \/etc\/passwd\r\n<\/span><\/span>w\r\n<span data-slate-fragment=\"JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJjb2RlJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTIyc3ludGF4JTIyJTNBJTIyYmFzaCUyMiU3RCUyQyUyMm5vZGVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIyYmxvY2slMjIlMkMlMjJ0eXBlJTIyJTNBJTIyY29kZS1saW5lJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJ0ZXh0JTIyJTJDJTIybGVhdmVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIybGVhZiUyMiUyQyUyMnRleHQlMjIlM0ElMjJsYXN0JTIyJTJDJTIybWFya3MlMjIlM0ElNUIlNUQlN0QlNUQlN0QlNUQlN0QlNUQlN0QlNUQlN0Q=\">last\r\nlastlog\r\n<\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:0\"><span class=\"prism-token token 50 keyword \">for<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:1\"><span class=\"prism-token token 51\"> i <\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:2\"><span class=\"prism-token token 52 keyword \">in<\/span><\/span> <span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:4\"><span class=\"prism-token token 54 variable variable \">$(<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:5\"><span class=\"prism-token token 54 variable function \">cut<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:6\"><span class=\"prism-token token 54 variable \"> -d<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:7\"><span class=\"prism-token token 54 variable string \">\":\"<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:8\"><span class=\"prism-token token 54 variable \"> -f1 \/etc\/passwd 2<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:9\"><span class=\"prism-token token 54 variable operator \">&gt;<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:10\"><span class=\"prism-token token 54 variable \">\/dev\/null<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:11\"><span class=\"prism-token token 54 variable variable \">)<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:12\"><span class=\"prism-token token 55 punctuation \">;<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:13\"><span class=\"prism-token token 56 keyword \">do<\/span><\/span> <span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:15\"><span class=\"prism-token token 58 function \">id<\/span><\/span> <span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:17\"><span class=\"prism-token token 60 variable \">$i<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:18\"><span class=\"prism-token token 61 punctuation \">;<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:19\"><span class=\"prism-token token 62 keyword \">done<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:20\"><span class=\"prism-token token 63\"> 2<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:21\"><span class=\"prism-token token 64 operator \">&gt;<\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:22\"><span class=\"prism-token token 65\">\/dev\/null <\/span><\/span><span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:23\"><span class=\"prism-token token 66 operator \">|<\/span><\/span> <span data-offset-key=\"a172c2406e9c4ae7b3e4368ecf91f7b6:25\" data-slate-fragment=\"JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJjb2RlJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTIyc3ludGF4JTIyJTNBJTIyYmFzaCUyMiU3RCUyQyUyMm5vZGVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIyYmxvY2slMjIlMkMlMjJ0eXBlJTIyJTNBJTIyY29kZS1saW5lJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJ0ZXh0JTIyJTJDJTIybGVhdmVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIybGVhZiUyMiUyQyUyMnRleHQlMjIlM0ElMjJmb3IlMjBpJTIwaW4lMjAlMjQoY3V0JTIwLWQlNUMlMjIlM0ElNUMlMjIlMjAtZjElMjAlMkZldGMlMkZwYXNzd2QlMjAyJTNFJTJGZGV2JTJGbnVsbCklM0JkbyUyMGlkJTIwJTI0aSUzQmRvbmUlMjAyJTNFJTJGZGV2JTJGbnVsbCUyMCU3QyUyMHNvcnQlMjIlMkMlMjJtYXJrcyUyMiUzQSU1QiU1RCU3RCU1RCU3RCU1RCU3RCU1RCU3RCU1RCU3RA==\"><span class=\"prism-token token 68 function \">sort\r\nid <strong>userName\r\n<\/strong><\/span><\/span><\/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 writeable by anybody 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>Running processes with a given priority and changing the priority of the 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 that can be found using the ps command. The priority range is <span style=\"color: #ff0000;\"><strong>from -20 (high priority) to +19 (low priority)<\/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>By adding <code>net.ifnames=0<\/code> and <code>biosdevname=0<\/code> in 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 good as a bootloader that runs in a thumbdrive to quick start an NVMe drive, in the event of an old BIOS firmware that can&#8217;t directly boot from an NVMe.<\/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 the cloned instance\/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>Applications that work with core\/distribution libraries to install software:<\/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>Canceling 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 the 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>Starts a process<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl stop appName<\/code>\n<ul>\n<li>Stops a process<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl restart appName<\/code>\n<ul>\n<li>Restarts a process<\/li>\n<\/ul>\n<\/li>\n<li><code>sudo supervisorctl restart all<\/code>\n<ul>\n<li>Restarts ALL process<\/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>Measures the throughput of a network connection between the client and server:<\/p>\n<pre>iperf -s\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# for the server\r\niperf -c <strong>10.0.0.1<\/strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0# for the client<\/pre>\n<p>Check the process ID that is connected to a specific port and open ports:<\/p>\n<pre>lsof -i\r\n<span data-offset-key=\"17f5bace61024153af073e3a45bbed9f:0\"><span class=\"prism-token token 60 function \">lsof<\/span><\/span><span data-offset-key=\"17f5bace61024153af073e3a45bbed9f:1\" data-slate-fragment=\"JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJjb2RlJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTIyc3ludGF4JTIyJTNBJTIyYmFzaCUyMiU3RCUyQyUyMm5vZGVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIyYmxvY2slMjIlMkMlMjJ0eXBlJTIyJTNBJTIyY29kZS1saW5lJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJ0ZXh0JTIyJTJDJTIybGVhdmVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIybGVhZiUyMiUyQyUyMnRleHQlMjIlM0ElMjJsc29mJTIwLWklMjIlMkMlMjJtYXJrcyUyMiUzQSU1QiU1RCU3RCU1RCU3RCU1RCU3RCU1RCU3RCU1RCU3RA==\"><span class=\"prism-token token 61\"> -i :22\r\n<span class=\"prism-token token punctuation \">(<\/span><span class=\"prism-token token 1\">netstat -punta <\/span><span class=\"prism-token token 2 operator \">||<\/span><span class=\"prism-token token 3\"> ss --ntpu)\r\nsudo ss -ltpn\r\n<\/span><\/span><\/span><\/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>Changing network interfaces 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 (ICPM) 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 the HTTP readers [<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\r\n<\/strong>dig <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 will resolve any domain that ends with <code>.local<\/code> to the IP <strong>10.10.10.100<\/strong>. Any other that does not match this pattern will be forwarded to the upstream servers for Google and CloudFlare, respectively.<\/p>\n<p>Do not forget to change the system resolver (<code>\/etc\/resolv.conf<\/code>) 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>To 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 mounting<\/strong> a private share with <strong>write privileges<\/strong> given to the 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 all users&#8217; read and write privileges <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 option <strong>-p<\/strong> will allow the tool to automatically repair problems that can be safely repaired without user intervention.<\/p>\n<p>Using Bind Mount as a way to mount a directory in another directory (like an alias, a mirror or a 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 mounting points of the system:<\/p>\n<pre>sudo findmnt --real<\/pre>\n<hr id=\"General\" \/>\n<p><strong>GENERAL LINUX TIPS<\/strong><\/p>\n<p>Send messages 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>Reverting hold above:<\/p>\n<pre>sudo apt-mark unhold <strong>packageName<\/strong><\/pre>\n<p>App to get all hardware info:<\/p>\n<pre>sudo apt install -y <strong>hardinfo<\/strong><\/pre>\n<p>Create a backup of a file while 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 with a certain 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>Safe overwrite all unused space of the drive:<\/p>\n<pre>dd if=\/dev\/random of=big || rm big<\/pre>\n<p>Cleanly killing 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 in the network (replace wlan0 with the interface you want to perform the search):<\/p>\n<pre>sudo apt install <strong>arp-scan<\/strong> -y\r\nsudo arp-scan --interface=<strong>wlan0<\/strong> --localnet<\/pre>\n<p>Printing file content or output on the screen\/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, great for backup:<\/p>\n<pre>mv file.<strong>{conf,bkp}<\/strong>\r\ncp file.<strong>{conf,local}<\/strong><\/pre>\n<p>Execute a single command on many targets:<\/p>\n<pre>mkdir -p -v \/home\/josevnz\/tmp\/{dir1,dir2,dir3}<\/pre>\n<p>Making a temporary file\/directory that is unique (excellent to prevent collision in automation scripts):<\/p>\n<pre>TMPFILE=\u2018mktemp\u2018 || exit 1\r\necho \"Temporary file name $TMPFILE\"<\/pre>\n<pre>TMPDIR=\u2018mktemp -d\u2018 || exit 1\r\necho \"Temporary directory name $TMPDIR\"<\/pre>\n<p>Measuring latency between your device and another:<\/p>\n<pre>sudo apt install mtr\r\nmtr google.com<\/pre>\n<p>Check the ports that your server is listening to:<\/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 if any shared outdated libraries are 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> but with multi-threads:<\/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,\u00a0 capable of multiple threads, and torrents or 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 the response of a repetitive prompt of an application or script (use it with caution):<\/p>\n<pre>yes | <strong>command<\/strong>\r\nyes string | <strong>command<\/strong><\/pre>\n<p>See also the command <code>expect<\/code> for more granular automation based on expected prompts and appropriate responses.<\/p>\n<p>Record the whole session, including issued commands, their outputs, and prompts. It is saved to a file that can be replayed for audit:<\/p>\n<pre>script --timing=<strong>record.Times<\/strong> <strong>record.Output<\/strong><\/pre>\n<p>To end the recoded session type <code>exit<\/code>.<\/p>\n<pre>scriptreplay --timing=<strong>record.Times<\/strong> <strong>record.Output\r\n<\/strong>scriptreplay --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 used a command without using &#8220;sudo&#8221; first. 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 on the next:<\/p>\n<pre>mkdir <strong>directoryName<\/strong>\r\ncd <strong>!$<\/strong><\/pre>\n<p>Adding one user to many groups:<\/p>\n<pre>sudo usermod -aG <strong>group1,group2,group3 user<\/strong><\/pre>\n<p>Removing a user from a group:<\/p>\n<pre>sudo gpasswd -d <strong>user groupName<\/strong><\/pre>\n<p>Changing the home directory and moving its content for a user:<\/p>\n<pre>usermod -d \/home\/<strong>newHome<\/strong> --move-home <strong>userName<\/strong><\/pre>\n<p>Showing the user&#8217;s password expiration information:<\/p>\n<pre>chage -l <strong>userName<\/strong><\/pre>\n<p>Changing the 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 for a directory, file, or any other command 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\n<span data-slate-fragment=\"JTdCJTIyb2JqZWN0JTIyJTNBJTIyZG9jdW1lbnQlMjIlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJibG9jayUyMiUyQyUyMnR5cGUlMjIlM0ElMjJjb2RlJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTIyc3ludGF4JTIyJTNBJTIyYmFzaCUyMiU3RCUyQyUyMm5vZGVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIyYmxvY2slMjIlMkMlMjJ0eXBlJTIyJTNBJTIyY29kZS1saW5lJTIyJTJDJTIyaXNWb2lkJTIyJTNBZmFsc2UlMkMlMjJkYXRhJTIyJTNBJTdCJTdEJTJDJTIybm9kZXMlMjIlM0ElNUIlN0IlMjJvYmplY3QlMjIlM0ElMjJ0ZXh0JTIyJTJDJTIybGVhdmVzJTIyJTNBJTVCJTdCJTIyb2JqZWN0JTIyJTNBJTIybGVhZiUyMiUyQyUyMnRleHQlMjIlM0ElMjJycG0lMjAtcWElMjIlMkMlMjJtYXJrcyUyMiUzQSU1QiU1RCU3RCU1RCU3RCU1RCU3RCU1RCU3RCU1RCU3RA==\">rpm -qa<\/span> | grep <strong>sshfs<\/strong><\/pre>\n<p>Install compilers and kernel headers to meet the application&#8217;s installation requirements:<\/p>\n<pre>sudo apt install gcc make build-essential linux-headers-$(uname -r) -y<\/pre>\n<p>List kernel modules installed:<\/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>Listing the content of a ZIP file:<\/p>\n<pre>zipinfo -1 <strong>file.zip<\/strong>\r\nunzip -l <strong>file.zip<\/strong><\/pre>\n<p>Mounting 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 file in this folder to be accessible from anywhere and by any user:<\/p>\n<pre>echo $PATH\r\nmv <strong>script.sh<\/strong> \/usr\/local\/bin<\/pre>\n<p>See the history of the commands.<\/p>\n<pre>history<\/pre>\n<p>Check what the current user is allowed to execute with <strong>sudo<\/strong>.<\/p>\n<pre>sudo -l<\/pre>\n<p>Allow users to use the command <strong>sudo<\/strong> without a password prompt.<\/p>\n<pre>sudo nano \/etc\/sudoers.d\/<strong>userName<\/strong><\/pre>\n<p>And add the following:<\/p>\n<pre><strong>userName<\/strong> ALL=(ALL) NOPASSWD: ALL<\/pre>\n<p>Keep <strong>sudo<\/strong> without prompting for a password <strong>during the section<\/strong>:<\/p>\n<pre>sudo -l<\/pre>\n<p>Check out the command <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>Creating directory symbolic link:<\/p>\n<pre><span data-offset-key=\"a443914c177f4e74a4755bdf2a9be520:0\"><span class=\"prism-token token function \">ln<\/span><\/span><span data-offset-key=\"a443914c177f4e74a4755bdf2a9be520:1\"><span class=\"prism-token token 1\"> -d -s <strong>\/targetFile<\/strong><\/span><\/span> <strong>\/symbolicLinkName<\/strong><\/pre>\n<p>Getting 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>Going to the home directory of a user:<\/p>\n<pre>cd ~<strong>userName<\/strong><\/pre>\n<p>Removing the repeated values and returning the unique ones:<\/p>\n<pre>cat <strong>listOfItems.txt<\/strong> | sort | uniq<\/pre>\n<p>Piping output to clipboard:<\/p>\n<pre>echo \"hi\" | xclip<\/pre>\n<p>Coding and decoding 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, then 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>Cutting and merging 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 would contain a list of the files to be merged as follows:<\/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 to 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 but detached from the terminal or shell:<\/p>\n<pre>nohup <strong>appToRunInBg.sh<\/strong> &amp;<\/pre>\n<p>If you have started jobs in the background but need to detach them from your terminal session:<\/p>\n<pre>disown <strong>jobId<\/strong><\/pre>\n<p>Using the <code>&lt;<\/code> operator. Inputting the content of a file to a command:<\/p>\n<pre>cat &lt; <strong>fileName.txt<\/strong><\/pre>\n<p>Using the <code>&lt;&lt;<\/code> operator. It is excellent for scripting commands:<\/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>, and does not retain files on reboots.<\/li>\n<\/ul>\n<\/li>\n<li><code>\/var\/tmp<\/code>\n<ul>\n<li>never on <strong>tmpfs<\/strong>, retains files on reboots.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Automation of 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>Converting Markdown to PDF:<\/p>\n<pre>pandoc -o <strong>new.pdf original.md<\/strong><\/pre>\n<p>Manipulating 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>It refers to the standard input of the shell if data in been piped.<\/li>\n<\/ul>\n<\/li>\n<li><strong>&#8211;empty<\/strong>\n<ul>\n<li>Tells qpdf to not expect an input file and to use piped data. Requires using <strong>&#8212;<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<li><strong>&#8211;encrypt<\/strong>\n<ul>\n<li>requires two password entries: for a viewer and for an editor. Both can be the same, but if different, they will obey the security restrictions.<\/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 the 6-digit TOTP from a seed directly from the command line.<\/p>\n<pre>oathtool --totp -b <strong>SEED<\/strong><\/pre>\n<p>Similar to <code>&gt;<\/code> writing to a file, <code>sponge<\/code> buffers until it is over, then writes at once. Important when multiple processes are simultaneously writing to the same file.<\/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 copy\/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 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 very dangerous tool to configure your Gnome desktop (like Regedit on Windows):<\/p>\n<pre>sudo apt install dconf-editor -y<\/pre>\n<p>Find, enable, and disable the backlight of the keyboard (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 timeout for the keyboard backlight (in seconds):<\/p>\n<pre>sudo nano \/sys\/devices\/platform\/dell-laptop\/leds\/dell::kbd_backlight\/stop_timeout<\/pre>\n<p>Setting the timezone and adjusting 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 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>Allow the Ubuntu 20.04 system to Hibernate:<\/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 to be the default auto login for Raspbian (<strong>autologin-user=pi<\/strong>, change <strong>pi<\/strong> to 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>Removing 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 directory:<\/p>\n<pre>sudo dpkg -i *.deb<\/pre>\n<p>See used space in disk and RAM (try each and see how it works):<\/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>See <strong>progress<\/strong> while copying or transferring big files:<\/p>\n<pre>pv <strong>file.zip<\/strong> &gt; <strong>\/tmp\/file.zip<\/strong><\/pre>\n<p>Block ping response 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-oriented 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>Converting images in batches:<\/p>\n<pre>mogrify -format <strong>jpg<\/strong> *.png<\/pre>\n<p>Batch resizing 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>Converting iPhone&#8217;s .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>Converting iPhone&#8217;s .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>Returning to the previous directory:<\/p>\n<pre>cd <strong>-<\/strong><\/pre>\n<pre>pushd \/var\r\n...\r\npopd<\/pre>\n<p>Matrix screensaver on 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 in the history of commands.<\/li>\n<\/ul>\n<hr id=\"Kali\" \/>\n<p><strong>KALI TIPS<\/strong><\/p>\n<p>Switches on and off a theme that makes Kali look like Windows 10 to &#8220;hide in plain sight&#8221;.<\/p>\n<pre>kali-undercover<\/pre>\n<p>Fixing Kali issue after 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, go to the start menu and search for <strong>Passwords and Keys<\/strong>.<\/p>\n<p>Disabling 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>Flag 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>Adjusting the vertical and horizontal position of the 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 shows the names of the displays, then replaces DP-1-3 with the desired display 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 (sks Soft Reboot) operation 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 the VNC:<\/p>\n<pre>ssh <strong>userName@192.168.1.10<\/strong> -L 5900:localhost:5900<\/pre>\n<p>Some PDF applications 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> -t\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 1GB file for download or any other test:<\/p>\n<pre>sudo dd if=\/dev\/zero of=<strong>1gb.zip<\/strong> bs=1 count=0 seek=$[1024*1024*1024]<\/pre>\n<p>Using DD to write an ISO file to a USB drive:<\/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>\/dirtectory\/file.txt<\/strong>\r\nwc -L <strong>\/dirtectory\/file.txt<\/strong><\/pre>\n<p>Search for files that contain the &#8220;text&#8221;:<\/p>\n<pre>grep -l '<strong>text<\/strong>' *.*<\/pre>\n<p>Search for a &#8216;text&#8217; 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>Look for the position and line of an occurrence of a byte (in hex) that happens 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 if not match to the pattern):<\/p>\n<pre>cat fileName | grep <strong>-v<\/strong> 'string'<\/pre>\n<p>Searching for a file:<\/p>\n<pre>grep -R '<strong>password<\/strong>' --include='*.py' --color \/path<\/pre>\n<p>Print the content in reverse order of the lines:<\/p>\n<pre>tac <strong>file.txt<\/strong><\/pre>\n<p>Wrap up the output to fit in 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>Comparing files:<\/p>\n<pre>diff <strong>file1.txt file2.txt<\/strong><\/pre>\n<p>Gathering information about a file:<\/p>\n<pre>file <strong>file.zip<\/strong>\r\nstat <strong>file.txt<\/strong><\/pre>\n<p>Print the content of a binary file:<\/p>\n<pre>strings <strong>binaryFile<\/strong><\/pre>\n<p>Looking inside binary files expressed in hex format:<\/p>\n<pre>xxd <strong>binaryFile<\/strong>\r\nxxd -s 0x000123abc <strong>binaryFile<\/strong> | head -n 5<\/pre>\n<p>Note: in the second example, it seeks the provided offset and only prints 5 lines. It is particularly useful when searching for the content in a specific position that is in the middle of the file and perhaps broke an application\/script.<\/p>\n<p>Print numbers from 1 to 10 separated by a space:<\/p>\n<pre>echo <strong>{1..10}<\/strong><\/pre>\n<p>Usage of <strong>cut<\/strong>, -d &#8221; &#8221; informs that the delimiter between columns is the space character, and -f 4 informs the column you want o retrieve.<\/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>, <strong>-d &#8221; &#8220;<\/strong> request to delete the spaces, replace each lowercase by uppercase and replace spaces by return key (next-line), <strong>-s &#8220;a&#8221;<\/strong> squeezes the characters leaving only one occurrence of it, <strong>-d [:digit:]<\/strong> leave only digits, but <strong>-cd [:digit:]<\/strong> remove the digits and leave only the numbers.<\/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>Inverting 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>Enabling the external USB driver to become datastores:<\/p>\n<pre>\/etc\/init.d\/usbarbitrator stop\r\nchkconfig usbarbitrator off\r\nls \/dev\/disks\/<\/pre>\n<p>Preparing 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: the <strong><span style=\"color: #ff0000;\">mpx.vmhba33:C0:T0:L0<\/span><\/strong> shall be replaced with the local USB direct access of your disk, 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 model, add the repositories, and run the installation.<\/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 the hardware on the present system, an installation command will be presented. Most likely this.<\/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 kernel module, <code>nouveau<\/code>\u00a0which is frequently a cause of conflict with the ones provided by NVIDIA.<\/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>Check first if the specific model has an installer at the official NVIDIA website [<a href=\"https:\/\/www.nvidia.com\/en-us\/drivers\/\">Link<\/a>].<\/p>\n<p>For some modules, the following might be the installation route.<\/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\/old hardware can be installed as follows. Se examples.<\/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>\u00a0nvidia-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 check.<\/p>\n<pre>sudo reboot\r\nsudo lsmod | grep nvidia\r\nsudo nvidia-smi<\/pre>\n<p>Hold (lock) the package to prevent upgrade.<\/p>\n<pre>sudo apt-mark hold <strong>nvidia-legacy-390xx-driver<\/strong><\/pre>\n<p>If it is intended 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<p>&nbsp;<\/p>\n<hr id=\"AMD\" \/>\n<p><strong>AMD GPU Drivers<\/strong><\/p>\n<pre>wget https:\/\/repo.radeon.com\/amdgpu-install\/latest\/ubuntu\/noble\/<strong>amdgpu-install_6.2.60202-1_all.deb<\/strong>\r\nsudo dpkg -i amdgpu-install*.deb\r\nsudo apt update &amp;&amp; sudo apt upgrade -y\r\nsudo amdgpu-install -y --accept-eula --opencl=rocr --opengl=mesa --vulkan=pro<\/pre>\n<p>Checking installation:<\/p>\n<pre>sudo dmesg | grep -i amdgpu\r\nsudo lshw -c video<\/pre>\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":279,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions"}],"predecessor-version":[{"id":5507,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions\/5507"}],"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}]}}