How to Encrypt and Decrypt Files and Directories Using Tar and OpenSSL

To package, compress and encrypt:
tar cz path_to_source | openssl enc -e -aes256 -out encrypted.tar.gz

To decrypt, decompress and extract
openssl enc -d -aes256 -in encrypted.tar.gz | tar xz

How to binary compare the contents of two directories on Linux (recursively)

Run the following in both directories (change the output filename for the second):
find . -print0 | LC_ALL=C sort -z | xargs -0r md5sum > ../dir1.md5 2>&1

Compare the two resulting text files with eg. diff.
If you're interested only in files (and don't care for potential empty directories), then add -type f to the arguments of find.

All sorts of free "programming" fonts with an online test app

"The most complete resource for monospace fonts on the web." - and it sure is. Smile

How to fix tcpdump error with file permission denied

The referenced page describes that a potential reason for a "permission denied" message while trying to run tcpdump can come from Ubuntu's apparmor profiles. The syslog will contain something like this (if you run tcpdump with the "-r" switch to read from a packet capture dump):
Jan 15 14:09:21 somehost kernel: [877965.617109] type=1400 audit(1452863361.199:133): apparmor="DENIED" operation="open" profile="/usr/sbin/tcpdump" name="/home/someuser/capture-21980_2016-01-14T15-37-01.dump" pid=9724 comm="tcpdump" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000

You can check the apparmor profile here: /etc/apparmor.d/usr.sbin.tcpdump
The reason for the above error message was the filename ... the apparmor profile grants read permission only on files with the ".pcap" extension. Simply renaming the file solved my problem. However if you really have to work around something in the profile, you can add your own rules to /etc/apparmor.d/local/usr.sbin.tcpdump which is included in the main profile at the end (thus you can override everything that was set in the main profile).

How to mount HFS+ drive and ignore permissions

bindfs is the answer. It will take an already mounted file system and provide a view of it with whichever uid you'd like:

sudo apt-get install bindfs
mkdir ~/myUIDdiskFoo
sudo bindfs -u $(id -u) -g $(id -g) /media/diskFoo ~/myUIDdiskFoo

The same answer is available on this Superuser post too. Of course the "/media/diskFoo" path represents the mount point of the already mounted HFS volume.

External storage permissions in Android (up to KitKat, i.e. 4.4)

A very nice post on how the external storage permission system evolved, where did it get in KitKat and how it is implemented. For the changes in Lollipop read this:

Useful tools for Android development/tinkering

"Here are some development tools useful for working with Android."

How to find secret codes (entered via the dialer) in Android apps

"To find all "Secret Codes", special properties and other hidden phone features and settings, used in the GT-I9300. The secret codes are not so secret, but
are often used to activate and manipulate many settings, such as debug modes, network connections, factory test modes etc. It is an unfortunate choice of
words but we will stick to this definition nonetheless for simplicity, since it is also used in the source code by Samsung and AOS. Do not confuse secret
codes with VSC (Vertical Service Codes), USSD (Unstructured Supplementary Service Data) or other MMI (Man Machine Interface) codes.

Although there are many "standard" codes common to many Samsung phones, they do vary to some extent. This is because their functionality often depend on
the particular hardware, in particular the baseband processor (aka radio, DSP, BP or CP) and the multiplexer chips that switches the various internal USB paths, for example between MHL, BP and AP.

This is an informative reference thread on these features. If you have relevant additional information you'd like to share, please post it here."

How to compile tcpdump for Android 5.* (Lollipop)

The linked github project (chatch/tcpdump-android) contains a shell-script to compile libpcap + tcpdump for ARM based Android devices. However it's a bit outdated, it was never maintained after the initial commits. The source ( for the script is outdated as well. I've taken the time to update the script to the most current libpcap+tcpdump+ndk versions and added Lollipop compatiblity (i.e. PIE support).

Nocache - utility to minimize filesystem caching effects

"The nocache tool tries to minimize the effect an application has on the Linux file system cache. This is done by intercepting the open and close system calls and calling posix_fadvise with the POSIX_FADV_DONTNEED parameter. Because the library remembers which pages (ie., 4K-blocks of the file) were already in file system cache when the file was opened, these will not be marked as "don't need", because other applications might need that, although they are not actively used (think: hot standby). Use case: backup processes that should not interfere with the present state of the cache."

Syndicate content