Linux Commands – top ten or thereabouts

Linux Commands – top ten or thereabouts

Commands I’m forever Googling…

CommandDoes what?Example
historyPrints previously executed commandshistory
!!
!n
!-n
Re-executes a previous command:
!! – last command (inc sudo !!)
!n – command at history line n
!-n – n commands ago
!!
sudo !!
!702
!-1
pwdPrint Working Directorypwd
rmdirRemove empty Directoryrmdir
rmRemove any Directorrm
locatefind filelocate -l hello*
dfdisk spacedf -m
dudisk usagedu Documents
ls -lah
ls -alSr
LiSt directory with file sizes
in size order (S), in reverse (r)
ls -lah
ls -alSr
psProcess Statusps aux (note “aux” are a, u & x options)
servicelist enabled services
detail specific service
service –status-all
service <service-name> status
calshow this month
show any month
cal
cal 10 1971
diff
find
grep
&run in background
md5sum
netstat
freefree -h -s 3
free -m
mysqldump
tail /path/to/fileprints the last 10 lines of the filetail ./Documents/my_file.txt
sudo tail -f /var/log/syslog
tail -f /path/to/fileprints the last 10 lines and keeps live updating
the output as its added to – useful for live
viewing an updating/live log
sudo systemd-resolve –flush-cachesflush client dns cache (not on Raspbian)
scpSecure CoPy
In this –> example scp copies a file named “file.name” from “host” to the same filename (“.”) on the local machine

scp user@host:file.name .

And package management…

aptapt-get / -cacheDoes what?
apt installapt-get installInstalls package
apt removeapt-get removeRemoves package
apt purgeapt-get purgeRemoves with config
apt updateapt-get updateRefreshes repository
apt upgradeapt-get upgradeUpgrades all upgradeables
apt autoremoveapt-get autoremoveRemoves unwanteds
apt full-upgradeapt-get dist-upgradeUpgrades, handles dependencies
apt searchapt-cache searchSearches for packages
apt showapt-cache showPackage details
Thanks to https://itsfoss.com/apt-vs-apt-get-difference/

Nano…

Esc + $ Enables soft line wrappingEsc + $ is achieved by pressing and releasing <Esc> then holding <Shift> and typing <4> (Shift+4 = $)

A few Node-RED goodies…

sudo systemctl start node-redRestart Node-RED
cd .node-red
sudo nano settings.js
Edit settings
sudo crontab -eEdit crontab

A few MacOS ones too…

open .Open current folder in Finder from Terminal

MySQL…

To list the size of each database:

select table_schema, sum((data_length+index_length)/1024/1024) AS MB from information_schema.tables group by 1;

Leave a Reply

Your email address will not be published. Required fields are marked *