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.

sudo shutdown -r now
sudo apt-get upgrade
  • grep files like '*.haystack' for 'needle'

    grep -iHn needle *.haystack

    • grep -i = case-insensitive

    • grep -H = print out the name of the file before the matching line

    • grep -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 find is where to start, i.e. the current working directory

    • the pattern '*.haystack' has to be quote-enclosed to stop the shell expanding the wildcard

    • -mtime -5 means 'modification time less than five days ago. For files more than five days old, use -mtime +5

    • -exec has to be semi-colon terminated to tell find where the command ends, but the semi-colon has to be escaped to stop the shell treating it as the end of find

  • Find files exeeding a certain size:

    find . -type f -size +1M

    • find files of size 1MB or greater

  • Find files modified in the last day:

    find . -type f -mtime -1 | grep -v ./.git

    • the grep -v is because you probably aren't interested in repo transactions

From SuperUser.com.

  1. Open vim
  2. Set background colour blue (:color blue)
  3. Open monitor menu and select “Auto adjust”