A short reference and archive of tricks for things I’ve found handy at one point or another.


Files have base permissons of 666 and directories have base perms of 777.

Umask acts in a subtractive manner on the base permissions to determine the permissions for newly created files and directories.

A typical default umask is 002 meaning new files are 664 and directories 775. This means that the Owner and members of the Owner’s Group can read and write in those files/directories.

A restricted umask would be 077 which removes all perms from the Group and World permission bits.

An unrestricted or open umask would be 000, which would make the files and directories accessible to all.

See Also:

Process Groups

The following command lists pid, pgid, name of all process on the system:

ps axo

When you a have a pgid you can get all processes in group with:

pgrep --list-name --full --group 5263
pgrep -lfg 5263  # same as above just with short options

To kill a process group (killing all processes in the group) use a "-" prefix on the pgid when passing it to the kill command:

kill -TERM -5263

Determine Your Distro

  • cat /etc/*-release
  • lsb_release -a
  • uname

Sudoers File

Use this line to add yourself to the admin group so you can use sudo:

username ALL=(ALL) ALL

If you want even more (like me) you can use this line to give yourself passwordless access to sudo:



Passwordless Sudo is a large security risk. Your results may vary.

Password Crypting

The /etc/passwd file uses the crypt module to encrypt a user’s password in such a way that it can be securely checked while the plain text of the password is never stored.

This is fairly simple to do in python. The crypt function takes a key and a salt to generate the encrypted password string. To check the password you use the encrypted password itself as the salt and the output should be the crypted password again. As such it is possible to use the username as the original salt.

>>> import crypt

>>> username = 'user'
>>> password = 'passwd'

>>> # creating the encrypted password
>>> crypt.crypt(username, password)
... 'usPAg.bS1IKP6'

>>> # checking the password
>>> crypt.crypt(password, 'usPAg.bS1IKP6')
... 'usPAg.bS1IKP6'


Notice that the first 2 chars of the salt appear in the crypted output. This is a result of the simplicity of the encryption used here; it is also a cryptographic security hole providing brute force break-ability.



Some tools require enough reference info that they may have been extracted to their own reference files.


The man file has a pretty straight forward list of tests (use search "sTESTS" to find it quickly).

The -exec and -execdir flags are kinda weird. They take a bash command to run on the files that are found by the tests. In the command you can use {} to specify where to put the filename and ; to end the command; however, both of those need to be quoted properly so that the find command receives them:

find <startpath> <tests> -execdir cp '{}' ~/dest/ ';'

Notice that the {} and ; in the -execdir command are single quoted.

" "