Useful Linux Terminal commands


I search enough for useful Linux terminal commands, I usually rely on command history, but thought I’d start recording them here.
Here are a couple for starters…

Search recursive folders for files containing keywords, returning file name
grep -r -l "linux"

Search command history for keywords, history number returned
history | grep linux

Remove history line 2001
history -d 2001

Run code in background from terminal – I can’t believe that I’ve been using Linux for ~13 years and have only just found this; just add & to the end of the string!
[whatever code you're running] &

Search recursive directories and change text within files
rpl -R TextYouWantToReplace NewTextToAdd

Count rows in file
cat FileName.csv | wc -l
wc -l cache.db

Show first n rows in file
head +10 FileName.csv | cat -n

Delete last 10 rows in original file
sed -i 1,10d cache.db

Remove lines 1-10 from cache.db and save as cache_new.db
sed '1,1000d' cache.db > cache_new.db