Ubuntu technical problems and solutions reference, a modern cookbook.
Gpg encryption is cool. It’s so cool, that I want to keep all my important files (that means back-up files) encrypted on my external storage.
Using gpg is fairly straight forward:
1) Generate a private key.
After answering some standard questions, the key is ready.
Note: You better not forget the password you choose, or else your encrypted files are lost forever.
2) Check you key:
This will display a list of all available keys.
3) Encrypt a file
gpg --encrypt --recipient 'key name' foo.txt
This will generate the encrypted file: foo.txt.gpg
4) Decrypt a file
gpg --output foo2.txt --decrypt foo.txt.gpg
foo2.txt file will be created.
So, until now I presented a quick guide to encrypt/decrypt a file. However, this wasn’t enough for me. I wanted to go a little further. I wanted to be able to encrypt folders as well, and the possibility to delete the original file, and keep only the encrypted one. So, I though I write my own function.
And so, tec was born.
In short tec stands for: tar, encrypt, clean. Long description: Tarballs and encrypts the TARGET using gpg (GnuPG) encrypton. Optionally it deletes the TARGET.
Just copy tec.sh into /usr/bin, and you’re good to go.
cd <download directory> sudo cp tec.sh /usr/bin
For general help, type:
# with delete option, to delete the original file, and keep the encrypted one tec.sh -dr <key> <file> # without delete option tec.sh -r <key> <file>
The project is in it’s early phases. Currently it only encrypts. For decryption the standard gpg commands have to be used. I plan to maintain the function, and try to add as much functionality as I can.
What if you want to add a new application in the “Open With Other Application…” section? Maybe you want to add that particular application as the default application to open certain type of files.
Here is an example of how I can add Vim as an option to open a text file. Vim will open the file in a new terminal session.
An .desktop file needs to be created in ~/.local/share/applications
So, let’s use vim for this purpose, it is just appropriate.
Press i to enter in edit mode and type in the following:
[Desktop Entry] Categories=; Comment=Edit file in Vim Exec=vim %f GenericName=Process Viewer Hidden=false Icon=vim Name=Vim Terminal=true Type=Application Version=1.0
after that, press ESC to exit the edit mode and type :wq to write to the file and quit.
That’s it. Now when you right click on a file, vim will be present in the list of Open With Other Application section, and you can add it as a default application.
Thanks for this answer to Marty Fried