Bash test if file exists

Using bash I needed to check that a file exists, then do something. This one turns out to be super simple. I wanted to conditionally load a db file if it existed in this case. What I needed was, a check for the file in bash. Then execute the command …

Add user to existing group

This is dead simple. I often need to add a new user to the sudoer group, "sudo" by default. sudo usermod -a -G groupName userName So for adding a user to the sudoers group. sudo usermod -a -G sudo {username}

Linux add user

The simple way to add a user is to use the linux interactive mode. sudo adduser {username} Then let it guide you through the setup.

How to find large volumes on linux

Running linux machines sometimes it's needed to figure out what is taking up a large amount of room on a server. Here's an easy way to investigate large directories. du -h <dir> | grep '\[0-9:::.\]+G'

7z file encryption with password

Previously I've transferred file with a pgp key, but this is an ok alternative. 7za a -tzip -psuperSecurePassword -mem=AES256 file.doc file1.doc file2.doc You can also checkout the easier and more supported zip method.

Password protect a zip file

Sometime a simple encrypt with a password is needed. This isn't the most secure method (7z provides more secure methods), but is better than nothing. I simple way to do it is to create a zip password protected with all the files. zip --password yourpassword file.doc file1 …

How to set a password on pdf in Ubuntu

This one is super simple. sudo apt-get install pdftk pdftk input-file.pdf output output-file.pdf userpw mysupersecretpassword

Move files while preserving timestamps

A quick way to move files in linux while keeping their timestamps. In short mv doesn't support this. The work around is to copy instead. cp -p -r -l source/date target/ rm -rf source/data

How to call a python function by using a variable python

I needed to, in a programmatic way, determine the function name and then call the function. Here's an example use case. I have a bunch of functions called, ["function1", "function2", "function3", "function4", etc] Then I have a function that takes a number as a param. Then should return the proper …

Mozilla Developer Edition

I recently discovered Mozilla Developer Edition. {.alignnone width="832" height="456"} So far I've love it's inline ability to edit css. It's an entirely natural way to tweak the css on the fly.