5
Nov

Vim: Encrypting Text Files

   Posted by: mpete510   in Uncategorized

Text files are used everyday to store tons of information. Most of the time this information is plain and out in the open. Anyone can access it. If you want to keep this information private, encryption is a necessity. My favorite text editor, Vim, has the ability to encrypt its files by default.

Note:This tutorial is not meant to be a full blown class on Vim. I will provide the commands of what to do you need to do, but a basic understanding of Vim is recommended to complete this.

To begin, enter the following at a command line:

vim -x test.txt

For you visual users press Alt+F2 and enter the following into text box:

gvim -x test.txt

Note: The above commands work whether you are creating a new file, or are editing an old one.

At this point it will ask you for a password. I would recommend using something different than your normal password to log onto your computer. The password should also be lengthy (10+ chars!). Having a short password to encrypt anything leaves an opening for a hacker to gain access.

Now hit the i key to enter insert mode and type in your super secret text!

Exit insert mode by pressing the Escape key. Hit Shift+:, type in wq then press Enter. This will write your super secret text to the file and quit Vim.

Let’s try and output the file to see what it shows by using cat.

Output of text file with cat

Besides the VimCrypt at the beginning, the whole file is gibberish! This will keep any information that you have safe from prying eyes!

Tags: , , , ,

30
Oct

5 Nifty Linux Commands

   Posted by: mpete510   in linux

Here are 5 nifty commands that help me get work done.

1. The conventional way of deleting most files is to move them to the recycle bin, and at some point later in the future empty it. With sensitive files you do not want them sitting in the recycle bin for days or weeks. Even when deleted, with the right tools someone could still recover that file. Shred is an awesome command that allows you to completely nuke the file so that nobody will be able to recover it. From the description of shred on its man page:

“Overwrite the specified FILE(s) repeatedly, in order to make it  harder for even very expensive hardware probing to recover the data.”

Basically, it allows you to securely and safely delete an files that you may have. It does this by writing random data to the file multiple times (default is 25). Here’s the shred command and arguments that I usually run.

shred -uz foo.bar

The -z has the last write be zeroes and the -u deletes the file.

2. Have you ever run a command and had the output fly across the terminal? Pipe (|) the command to more! More lets you see the output from a command, one page at a time.

ls | more

3. Alias allows you to define a different name for a command. This can be handy for a ton of reasons. In Windows the cls command clears the command line. On Linux if you run cls you will get a “command not found” error, because clear is the correct command. To map cls to clear, type the following code at the command line.

alias cls=clear

4. Grep is a very useful command. Its man page has a good, short and succinct description.

grep - print lines matching a pattern”

It can search through files for the pattern, or results from other commands can be piped to it. Lets say that there is a Firefox process that is unresponsive on your system. Hitting the x in the top right of the window does not close it. What to do? You could use the ps command to pipe process information to grep which finds the information you need about the runaway process.

mikeyp@bender:~$ ps -ef | grep firefox
mikeyp    7077        1  8 20:59 ?         00:04:10 /usr/lib/firefox-3.0.3/firefox
mikeyp    8474  7039  0 21:49 pts/0    00:00:00 grep firefox

The first row is the unresponsive process and the second column is the process id. So now you can use the kill command to end the process.

kill -9 7077

5. Man is my #1 reference when I need to figure out exactly what a command is capable of. I regularly use it to research what arguments are available. Its very simple to use.

man command

You can use the arrow keys, pgup and pgdn to navigate through the manual. The q key will quit you out.

Tags: , ,