Linux cribsheet
This is a personal cribsheet intended for my own use. If it's useful to you, great, but it doesn't cover the subject exhaustively.
Reboot
sudo shutdown -r now
Upgrade packages
sudo apt-get upgrade
Search
grep files like '*.haystack' for 'needle'
grep -iHn needle *.haystackgrep -i= case-insensitivegrep -H= print out the name of the file before the matching linegrep -n= print out the number of the matching line
Find files like '*.haystack' modified in the last five days and grep them for 'needle':
find . -name '*.haystack' -mtime -5 -exec grep -iHn needle {} \;the dot after
findis where to start, i.e. the current working directorythe pattern '*.haystack' has to be quote-enclosed to stop the shell expanding the wildcard
-mtime -5means 'modification time less than five days ago. For files more than five days old, use-mtime +5-exechas to be semi-colon terminated to tellfindwhere the command ends, but the semi-colon has to be escaped to stop the shell treating it as the end offind
Find files exeeding a certain size:
find . -type f -size +1Mfind files of size 1MB or greater
Find files modified in the last day:
find . -type f -mtime -1 | grep -v ./.gitthe
grep -vis because you probably aren't interested in repo transactions
Fix VGA display alignment
From SuperUser.com.
- Open
vim - Set background colour blue (
:color blue) - Open monitor menu and select “Auto adjust”