List only directories with the Linux command line. This lists a directory with all folders listed first, then return only the listing of folders in the directory.
4.4 Tue Oct 09 jason@Yog-Sothoth 0: $ ls --color=auto --group-directories-first -Hul | head -n `echo */ | wc -w` total 3866624 drwxrwxrwx+ 6 jason jason 4096 Oct 9 10:55 6thRBAnnex-and-Invade.Altis drwxrwxrwx+ 3 jason jason 4096 Oct 9 10:55 altis_patrol_ops_nato.Altis drwxr-xrwx+ 3 jason jason 4096 Oct 9 10:55 ammo_box drwxr-xrwx+ 3 jason jason 4096 Oct 9 10:55 anona drwxr-xrwx+ 5 jason jason 4096 Oct 9 10:55 antarctica drwxr-xrwx+ 11 jason jason 4096 Oct 9 10:55 Arma3 drwxrwxrwx+ 11 jason jason 4096 Oct 9 10:55 asi_invade_annex-New.Altis drwxr-xrwx+ 3 jason jason 4096 Oct 9 10:55 backpack drwxrwxrwx+ 4 jason jason 12288 Oct 9 10:55 bdoom drwxr-xrwx+ 2 root root 4096 Oct 9 10:55 build drwxrwxrwx+ 5 jason jason 4096 Oct 9 10:55 capture_altis_nato_blufor.Altis drwxr-xrwx+ 7 jason jason 4096 Oct 9 10:55 co60_AW_I&A_TFTEdit.Altis drwxr-xrwx+ 3 jason jason 4096 Oct 9 10:55 Comics drwxr-xrwx+ 2 jason jason 4096 Oct 9 10:55 evil drwxr-xr-x+ 5 jason jason 4096 Oct 9 10:55 ipinfo drwxr-xr-x+ 2 root root 4096 Oct 9 10:55 Linux drwxr-xrwx+ 2 jason jason 12288 Oct 9 10:55 phone drwxrwxrwx+ 2 jason jason 4096 Oct 9 10:55 PHP drwxr-xrwx+ 2 jason jason 4096 Oct 9 10:55 pol drwxr-xr-x+ 3 jason jason 4096 Oct 9 10:55 progs drwxr-xrwx+ 4 jason jason 4096 Oct 9 10:55 sdrmac drwxr-xrwx+ 5 jason jason 4096 Oct 9 10:55 stuff drwxr-xrwx+ 2 jason jason 4096 Oct 9 10:55 sym drwxr-xrwx+ 6 jason jason 4096 Oct 9 10:55 sysinfo drwxr-xrwx+ 2 jason jason 4096 Oct 9 10:55 system drwxr-xrwx+ 3 jason jason 4096 Oct 9 10:55 tcptable drwxr-xrwx+ 11 jason jason 4096 Oct 8 13:47 TempestSDR drwxr-xrwx+ 3 jason jason 4096 Oct 9 10:55 thumbs drwxr-xrwx+ 3 jason jason 4096 Oct 9 10:55 vim drwxr-xrwx+ 3 jason jason 4096 Oct 9 10:55 website drwxrwxr-x+ 2 jason jason 4096 Oct 9 10:55 Windows |
Get the weather report for Sydney Australia with the command line.
4.4 Tue Oct 09 jason@Yog-Sothoth 0: $ curl -s 'http://wttr.in/~sydney?q&p' sydney \ / Partly cloudy _ /"".-. 21 °C \_( ). → 7 km/h /(___(__) 10 km 0.0 mm ┌─────────────┐ ┌──────────────────────────────┬───────────────────────┤ Tue 09 Oct ├───────────────────────┬──────────────────────────────┐ │ Morning │ Noon └──────┬──────┘ Evening │ Night │ ├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤ │ \ / Partly cloudy │ \ / Partly cloudy │ _`/"".-. Thundery outbr…│ _`/"".-. Thundery outbr…│ │ _ /"".-. 19 °C │ _ /"".-. 22-23 °C │ ,\_( ). 20 °C │ ,\_( ). 19 °C │ │ \_( ). ↘ 6-8 km/h │ \_( ). ↖ 9-10 km/h │ /(___(__) ↙ 13-21 km/h │ /(___(__) ← 6-11 km/h │ │ /(___(__) 20 km │ /(___(__) 20 km │ ⚡‘‘⚡‘‘ 19 km │ ⚡‘‘⚡‘‘ 19 km │ │ 0.0 mm | 0% │ 0.0 mm | 0% │ ‘ ‘ ‘ ‘ 0.1 mm | 45% │ ‘ ‘ ‘ ‘ 0.0 mm | 23% │ └──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘ ┌─────────────┐ ┌──────────────────────────────┬───────────────────────┤ Wed 10 Oct ├───────────────────────┬──────────────────────────────┐ │ Morning │ Noon └──────┬──────┘ Evening │ Night │ ├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤ │ .-. Moderate or he…│ _`/"".-. Thundery outbr…│ Overcast │ _`/"".-. Patchy rain po…│ │ ( ). 17 °C │ ,\_( ). 16 °C │ .--. 13-15 °C │ ,\_( ). 13-14 °C │ │ (___(__) ↖ 26-37 km/h │ /(___(__) ↖ 32-44 km/h │ .-( ). ↖ 31-42 km/h │ /(___(__) ↖ 27-37 km/h │ │ ‚‘⚡‘‚⚡‚‘ 12 km │ ⚡‘‘⚡‘‘ 11 km │ (___.__)__) 12 km │ ‘ ‘ ‘ ‘ 14 km │ │ ‚’‚’⚡’‚’ 0.4 mm | 24% │ ‘ ‘ ‘ ‘ 1.3 mm | 43% │ 0.1 mm | 59% │ ‘ ‘ ‘ ‘ 0.0 mm | 29% │ └──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘ ┌─────────────┐ ┌──────────────────────────────┬───────────────────────┤ Thu 11 Oct ├───────────────────────┬──────────────────────────────┐ │ Morning │ Noon └──────┬──────┘ Evening │ Night │ ├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤ │ _`/"".-. Light rain sho…│ Cloudy │ \ / Partly cloudy │ _`/"".-. Patchy rain po…│ │ ,\_( ). 13-14 °C │ .--. 15 °C │ _ /"".-. 14-15 °C │ ,\_( ). 14-15 °C │ │ /(___(__) ↖ 19-26 km/h │ .-( ). ↖ 20-25 km/h │ \_( ). ↖ 20-27 km/h │ /(___(__) ← 19-27 km/h │ │ ‘ ‘ ‘ ‘ 17 km │ (___.__)__) 17 km │ /(___(__) 18 km │ ‘ ‘ ‘ ‘ 17 km │ │ ‘ ‘ ‘ ‘ 0.1 mm | 26% │ 0.1 mm | 57% │ 0.1 mm | 51% │ ‘ ‘ ‘ ‘ 0.0 mm | 25% │ └──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘ Location: Sydney, NSW, Australia [-33.8548156,151.2164539] . |
Show all listening ports on your Linux system.
4.4 Tue Oct 09 jason@Yog-Sothoth 0: $ sudo netstat -tulpn | grep LISTEN --color=auto tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2722/dnsmasq tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 1293/systemd-resolv tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1524/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 3576/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1865/master tcp 0 0 127.0.0.1:9050 0.0.0.0:* LISTEN 1559/tor tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 1871/smbd tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1638/mysqld tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 1871/smbd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1671/apache2 tcp6 0 0 :::22 :::* LISTEN 1524/sshd tcp6 0 0 127.0.0.1:3350 :::* LISTEN 1557/xrdp-sesman tcp6 0 0 :::3389 :::* LISTEN 1574/xrdp tcp6 0 0 :::445 :::* LISTEN 1871/smbd tcp6 0 0 :::139 :::* LISTEN 1871/smbd |
How to convert a Wikipedia article to a text file using the Linux command line.
How to filter text with the sed command. This is useful for various shell tricks.
Search a binary file for various strings. In this example, I am searching a Windows 10 ISO for various text.
4.4 Tue Oct 09 jason@Yog-Sothoth 0: $ strings en_windows_10_enterprise_x64_dvd_6851151.iso | grep "Product key" %hs: Product key is not specified Product key installation succeeded Product key installation failed (0x%08X) ProductKeyFromSources:Product key found in pid.txt ProductKeyFromSources:Product key found in pid.txt/ei.cfg is valid pid_GetProductKeyFromSources:Product key found in pid.txt/ei.cfg is invalid pid_GetProductKeyFromSources:Product key found in pid.txt/ei.cfg is malformed Callback_Productkey_Validate_Unattend:Validating Product key. Callback_Productkey_Validate_Unattend:Validating Product key Callback_Productkey_Validate_Unattend:Product key is valid Callback_Productkey_Validate_Unattend:Product key in unattend file is invalid Callback_Productkey_Validate: Product key did not successfully pass validation. |