Posts

Showing posts from 2016

Finding non ascii characters in a text file

stackoverflow link http://stackoverflow.com/questions/3001177/how-do-i-grep-for-all-non-ascii-characters-in-unix My favorite out of this: grep -P "[\x80-\xFF]" file.xml This was really useful when compiling AWS Cloudformation templates since you can't have certain characters in the JSON.

Ubuntu thunar-like disk mounting from the command line

I always forget how to do this, so why not create a quick page to remind myself. Logged in through the GUI it is easy to use thunar, but from the command line I use these steps: # create the luks volume sudo cryptsetup luksOpen /dev/sdc1 Verbatim1TB # mount the disk like thunar udisksctl mount -b /dev/mapper/Verbatim1TB Voila!

Arbitrary cpu load on linux

https://www.devin.com/lookbusy/ Lookbusy is super awesome. It doesn't just take the CPU to 100% like other utilities.. Wtih AWS, especially t2.small instances, I want to play with the cpu around the credit burning limit and this tool allows me to do that so easily.  I'm not sure how the curve works yet, but I'm going to explore that next.     wget 'https://www.devin.com/lookbusy/download/lookbusy-1.4.tar.gz'     tar zxvf lookbusy-1.4.tar.gz     ./configure     make     ./lookbusy --cpu-uti=45-55 --cpu-mode=curve     ./lookbusy --cpu-uti=15-25 --cpu-mode=curve  # t2.small     ./lookbusy --cpu-uti=19

Using ecryptfs to mount encrypted directories

Rather than encrypted every backup file individually I find it useful to just put an ecryptfs overlay on a couple of directories and just write directly to them letting ecrypt take care of the encryption. In this example, I have a local drive that I write my daily incremental gnu tar file to.  I then rsync that directory's contents to a mirror directory house on the IT microsoft network drive.  This code snipet mounts the 2 ecrypt directories.  I run this after rebooting my box since I don't want  to store the passphrase anywhere. ECRYPT_OPTIONS="key=passphrase,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_passthrough=n,ecryptfs_enable_filename_crypto=n" sudo mount -t ecryptfs /scratch/myuser/encrypted /scratch/myuser/encrypted                                   -o "${ECRYPT_OPTIONS}" || exit 4 sudo mount -t ecryptfs /mnt/dos/home/myuser/MyDocuments/encrypted /mnt/dos/home/myuser/MyDocuments/encrypted -o "${ECRYPT_OPTIONS}" || exit 5

Configure XFCE default browser application

To see what you are configured for now:     xdg-settings get default-web-browser Then to find that file:     locate `xdg-settings get default-web-browser` For me that was     /usr/share/applications/google-chrome.desktop I started with that file and edited so it called chrome the way I do (I run multiple sessions of chrome and wanted a default open to go to a specific one.     cp /usr/share/applications/google-chrome.desktop  ~/.local/share/applications/custom-google-chrome.desktop Edit that file to your liking and then set xdg (NO PATH to the file)   xdg-settings set default-web-browser custom-google-chrome.desktop Now test   xdg-open https://www.google.com