Wednesday, May 30, 2012

Become a Vi Master by Learning These 30+ Key Bindings


image

Vi is a powerful text editor included on most Linux systems. Many people swear by vi and find it faster than any other editor once they’ve learned its key bindings. You can even use vi key bindings in Bash.
We’ve already covered getting started with vi for beginners. If you haven’t used vi in a while, you might want to give that post a look to get a refresher on the basics.

Mode Switching

As a short recap, vi is a modal editor – there’s an insert mode and a standard command mode. In insert mode, vi functions similar to a normal text editor. In command mode, you take advantage of these key bindings.
  • i – Enter insert mode.
  • Escape – Leave insert mode. If you’re already in command mode, Escape does nothing, so you can press Escape to ensure you’re in command mode.

Moving the Cursor

Vi uses the hjkl keys to move the cursor in command mode. Early computer systems didn’t always have arrow keys, so these keys were used instead. One advantage of these keyboard shortcuts is that you don’t have to move your fingers from the home row to use them.
  • h – Move cursor left.
  • j – Move cursor down.
  • k – Move cursor left.
  • l – Move cursor right.
You can also use search commands to quickly move the cursor.
  • / – Type a / followed by some text you want to find and press Enter to quickly move your cursor to the location of the text in the file. For example, if you have the word iguana in your file, type /iguana and press Enter to quickly move the cursor there.
  • ? – Like /, but searches backwards.
  • f – Type an f followed by any character to quickly move the cursor to the next occurrence of the character on the current line. For example, if you have the line “Hello world” on a line and your cursor is at the beginning of the line, type fo to move to the o in Hello. Type fo again to move to the o in world.
  • F – Like f, but searches backwards.
  • % – Jump between the nearest (), [], or {} characters on the line.
Use these commands to quickly move to locations in the file:
  • H – Move cursor to highest (top) line in file.
  • M – Move cursor to middle line in file.
  • L – Move cursor to lowest (bottom) line in file.
  • #G – Type a number and then type G to go to that line in the file. For example, type 4G and press Enter to move to the fourth line in the file.
Moving between words:
  • w – Move forward a word.
  • #w – Move forward a number of words. For example, 2w moves forward two words.
  • b – Move back a word.
  • #b – Move back a number of words. For example, 3b moves back three words.
  • e – Move to end of the current word.

Copying & Pasting

Vi refers to the act of copying as “yanking.”
  • v – Press v and move the cursor to select a section of text.
  • y – Copy (yank) the selected text.
  • p – Paste at cursor.
  • x – Cuts the selected text. Cuts the character under the cursor if no text is selected
  • r – Type r and then type another character to replace the character under the cursor.

Combining Commands

Some commands – including the y and v commands above and the d (delete) command accept cursor motion commands.
For example, when you press d to delete some text, nothing will happen until you enter a cursor motion command. For example:
  • dw – Deletes the next word.
  • db – Deletes the previous word
  • de – Deletes to the end of the current word.
  • dL – Deletes all text below the cursor in the file.
  • d/unicorn – After pressing Enter, deletes all text between the cursor and the word “unicorn” in the current file.
  • dd – Deletes an entire line.
As you can see, the combination of combining a command with a cursor movement command is very powerful.

Repeat & Undo

Vi’s repeat command is very powerful, as it can repeat complex, combined commands.
  • u – Undo.
  • . – The . repeats the last full command.  The insert command also functions as a command here. For example, type iunicorn and press Escape. You can then use the . key to insert the word unicorn at the cursor.

Bonus: Using Vi Key Bindings in Bash

Once you’ve mastered the vi key bindings, you may want to use them elsewhere on your system. No problem – you can set the Bash shell to use vi-style key bindings.
Try this out in the current session by running the following command in a Bash terminal:
set -o vi
Bash will start in insert mode – press Escape to enter command mode and use these key bindings.
If you like this, you can add the command to your ~/.bashrc file and it will be automatically run each time you log in. Use the vi .bashrc command to open and edit the file in vi.

This isn’t a complete list of key bindings for vi, but it should help you flex your vi wings and learn to fly. This list of key bindings at Harvard’s website is more complete and has more information, although it’s less organized and harder to digest all at once.

Friday, May 25, 2012

How To Change Your IP Address Using Tor Browser Bundle




An IP Address (Internet Protocol Address) is essentially your digital fingerprint on the internet. Wherever you visit websites or use Internet services, your IP is also transmitted and recorded in the logs kept on those servers. The legal practical use of these IPs are for security purposes. For example if someone from another country tries to login to your Facebook account, the page will recognize that the IP address is from a different location and he won’t be able to log in.

So, Why do I need to Hide my IP Address?
As i said above, your IP is your digital fingerprint. So, if you’re doing something you’re not supposed to be doing, someone can grab your IP address and track you down.
The bottom line is this: Your IP address was never meant to be a secret. Whatever you do on the Internet, your IP address is known not only to you, but to your ISP and the admins of the site you’re connecting with. So, you are telling them your IP just by using your network.
If you like to keep your privacy online, it’s necessary to change your IP address.

There are many methods to change or hide your IP address, but in this tutorial I am going how to show you how to do that by using the Tor Browser Bundle. This bundle contains everything you need to anonymously browse the Internet. This package requires no installation. Just extract it and run.
Here is a step-by-step video guide that will show you how to install and use Tor Browser Bundle:
(Video: Watch this video on the post page)
Hope you find this tutorial useful. Enjoy ;)

Thursday, May 24, 2012

How to Install Android Apps to the SD Card by Default & Move Almost Any App to the SD Card



image
Android apps install to the internal storage by default, but you can also set the SD card as your default install location. This trick allows you to move almost any app to the SD card – no root access required.
This tweak requires Android 2.2 or later. To change the default install location, you’ll need to use the ADB, or Android Debug Bridge, utility included with Google’s Android SDK.

Enable USB Debugging

First, you’ll need to enable USB debugging on your Android device. Open the Settings screen, tap Applications, and select Development.
Tap the USB Debugging checkbox to enable it. This will enable debug mode, allowing you to change the settings on your Android device from your computer. You may want to disable debug mode after completing this process.

Install the Android SDK

You’ll need to download and install Google’s Android SDK on your computer. If you don’t already have Oracle’s Java JDK installed on your computer, you’ll have to download and install it before installing the Android SDK.
After you’ve installed both the JDK and Android SDK, launch the SDK Manager from your Start menu.
The ADB utility isn’t installed by default. It’s included in the Android SDK Platform-tools package – select this package and click the Install button to download and install it.
After the process completes, connect your Android device to your computer with its included USB cable. Windows should locate the device and install the appropriate drivers automatically. If it doesn’t, you may have to download and install the appropriate drivers from your Android device’s manufacturer. Do not mount the device after connecting it – just plug it in.

Using ADB

Open a Windows Explorer window and navigate to the android-sdk\platform-toolsfolder. On Windows, you’ll find this folder at C:\Program Files (x86)\Android\android-sdk\platform-tools by default. Check C:\Program Files\Android\android-sdk\platform-tools if you’re using a 32-bit version of Windows.
Launch a Command Prompt window in this folder by pressing and holding the Shift button, right-clicking in the folder, and selecting Open command window here.
Run the adb devices command and you should see your connected Android device.
Run the following command to set the default install location to your SD card:
adb shell pm setInstallLocation 2
If you want to revert this change later and install apps to the internal storage by default, run this command:
adb shell pm setInstallLocation 0
0 represents your device’s internal storage, and is the default. 2 represents the external storage, whether it’s an SD card or USB storage.

Moving Apps to SD Card

Apps that refused to leave your system storage can now be moved to the external storage. For instance, below you’ll see screenshots of the Slacker Radio app. Before the change was made, the Move to USB Storage button was grayed out. After the change was made, the button is enabled and the app can be moved.
To move an app to the SD card, open the Settings screen, tap Applications, and select Manage Applications. Select the app you want to move and tap the Move button on its details screen.

A Warning

Some apps shouldn’t be installed to your SD card and should remain installed on the internal storage. The external storage is unavailable when your Android device is mounted on your computer, so apps that remain running all the time should be left on your internal storage. Widgets, launchers, animated wallpapers, and anything you want to use while your Android’s SD card is mounted on your computer should be left on the internal storage.

Tuesday, May 22, 2012

2 Alternatives to GNU Screen for Linux Terminal Multitasking We’ve written about using GNU Screen to multitask in the Linux terminal in the past. GNU Screen is the granddaddy of these programs, but tmux and dvtm+dtach are other solutions you may prefer. Tmux is an improved rewrite of GNU Screen. Dvtm is a console multiplexer inspired by tiling window managers, and dtach adds the ability to detach from and reattach to dvtm sessions. Tmux As a rewrite of GNU Screen, tmux offers a variety of improvements. Some of the most important include a client-server model, which allows you to connect to a tmux session from multiple locations, and a cleaner configuration file format. Check out tmux’s FAQ to discover a list of ways it differs from GNU Screen. Use this command to install tmux on Ubuntu: sudo apt-get install tmux If you’re using another distribution, you’ll likely find it in your distribution’s package manager. To launch tmux after installing it, just run the tmux command. Unlike Screen, tmux comes with a status bar by default. To open an additional terminal window, use the Mod-c keyboard shortcut. The default modifer key combination is Ctrl-b. This means that you’ll have to press Ctrl-b and then c to create a new window. Each new window you open will appear in the status bar. By default, tmux only shows one window on the screen at a time. Here are some important keyboard shortcuts to get you started: Mod-X – Kill the current terminal. Mod-n – Focus next window. Mod-p – Focus previous window. Mod-# – Focus the specified window, where # is a number between 0 and 9. Mod-’ – Prompt for a window to select. Mod-% – Split the current window into two horizontally. Mod-” – Split the current window into two vertically To detach from the current session, use the Mod-d keyboard shortcut. To reattach to a session, run the following command: tmux attach For more keyboard shortcuts, run the man tmux command or read tmux’s manual on the web. Dvtm & Dtach Unlike GNU Screen and tmux, dvtm doesn’t allow you to disconnect and reattach to sessions. You’ll have to run dvtm with dtach to detach from and reattach to your sessions. Run this command to install dvtm and dtach on Ubuntu: sudo apt-get install dvtm dtach These programs should be available in other distribution’s software repositories, too. Run the dvtm command to launch dvtm. You’ll see a single terminal window. To open additional terminal windows, use the Mod-c keyboard shortcut. The default modifier key combination is Ctrl-g. This means that you’ll need to press Ctrl-g and then c to open a new terminal window. Like a tiling window manager, dvtm will lay out the terminal windows automatically. Unlike the other utilities, it displays them all on the screen by default. Here are some important keyboard shortcuts to get you started: Mod-x – Close the current window. Mod-j – Focus next window. Mod-k – Focus previous window. Mod-# – Focus the specified window, where # is the number of the window. Mod-q - Quit dvtm. For a full list, run the man dvtm command or check out dvtm’s manual page on the web. Dvtm also supports the mouse. For example, you can click one of the windows to select it. To detach from a dvtm session and reattach to it later, you’ll have to run it with the dtach command. To launch dvtm with dtach, use the following command: dtach -c /tmp/dvtm-session -r winch dvtm To detach from a dvtm session that’s been started with dtach, use the Ctrl-\ keyboard shortcut. To reattach to your dvtm session later, use the following command: dtach -a /tmp/dvtm-session -r winch You can use dtach to run, detach from, and reattach to other applications, too.


ximage

We’ve written about using GNU Screen to multitask in the Linux terminal in the past. GNU Screen is the granddaddy of these programs, but tmux and dvtm+dtach are other solutions you may prefer.
Tmux is an improved rewrite of GNU Screen. Dvtm is a console multiplexer inspired by tiling window managers, and dtach adds the ability to detach from and reattach to dvtm sessions.

Tmux

As a rewrite of GNU Screen, tmux offers a variety of improvements. Some of the most important include a client-server model, which allows you to connect to a tmux session from multiple locations, and a cleaner configuration file format. Check out tmux’s FAQ to discover a list of ways it differs from GNU Screen.
Use this command to install tmux on Ubuntu:
sudo apt-get install tmux
If you’re using another distribution, you’ll likely find it in your distribution’s package manager.
To launch tmux after installing it, just run the tmux command. Unlike Screen, tmux comes with a status bar by default.
To open an additional terminal window, use the Mod-c keyboard shortcut. The default modifer key combination is Ctrl-b. This means that you’ll have to press Ctrl-b and then cto create a new window.
Each new window you open will appear in the status bar. By default, tmux only shows one window on the screen at a time.
Here are some important keyboard shortcuts to get you started:
Mod-X – Kill the current terminal.
Mod-n – Focus next window.
Mod-p – Focus previous window.
Mod-# – Focus the specified window, where # is a number between 0 and 9.
Mod-’ – Prompt for a window to select.
Mod-% – Split the current window into two horizontally.
Mod-” – Split the current window into two vertically

To detach from the current session, use the Mod-d keyboard shortcut.
To reattach to a session, run the following command:
tmux attach
For more keyboard shortcuts, run the man tmux command or read tmux’s manual on the web.

Dvtm & Dtach

Unlike GNU Screen and tmux, dvtm doesn’t allow you to disconnect and reattach to sessions. You’ll have to run dvtm with dtach to detach from and reattach to your sessions.
Run this command to install dvtm and dtach on Ubuntu:
sudo apt-get install dvtm dtach
These programs should be available in other distribution’s software repositories, too.
Run the dvtm command to launch dvtm. You’ll see a single terminal window.
To open additional terminal windows, use the Mod-c keyboard shortcut. The default modifier key combination is Ctrl-g. This means that you’ll need to press Ctrl-g and then cto open a new terminal window.
Like a tiling window manager, dvtm will lay out the terminal windows automatically. Unlike the other utilities, it displays them all on the screen by default.
Here are some important keyboard shortcuts to get you started:
Mod-x – Close the current window.
Mod-j – Focus next window.
Mod-k – Focus previous window.
Mod-# – Focus the specified window, where # is the number of the window.
Mod-q - Quit dvtm.
For a full list, run the man dvtm command or check out dvtm’s manual page on the web.
Dvtm also supports the mouse. For example, you can click one of the windows to select it.
To detach from a dvtm session and reattach to it later, you’ll have to run it with the dtach command. To launch dvtm with dtach, use the following command:
dtach -c /tmp/dvtm-session -r winch dvtm
To detach from a dvtm session that’s been started with dtach, use the Ctrl-\ keyboard shortcut.
To reattach to your dvtm session later, use the following command:
dtach -a /tmp/dvtm-session -r winch
You can use dtach to run, detach from, and reattach to other applications, too.

Monday, May 21, 2012

47 Keyboard Shortcuts That Work in All Web Browsers


browser keyboard shortcuts header

Each major web browser shares a large number of keyboard shortcuts in common. Whether you’re using Mozilla Firefox, Google Chrome, Internet Explorer, Apple Safari, or Opera – these keyboard shortcuts will work in your browser.
Each browser also has some of its own, browser-specific shortcuts, but learning the ones they have in common will serve you well as you switch between different browsers and computers. This list includes a few mouse actions, too.

Tabs

Ctrl+1-8 – Switch to the specified tab, counting from the left.
Ctrl+9 – Switch to the last tab.
Ctrl+Tab – Switch to the next tab – in other words, the tab on the right. (Ctrl+Page Upalso works, but not in Internet Explorer.)
Ctrl+Shift+Tab – Switch to the previous tab – in other words, the tab on the left. (Ctrl+Page Down also works, but not in Internet Explorer.)
Ctrl+WCtrl+F4 – Close the current tab.
Ctrl+Shift+T – Reopen the last closed tab.
Ctrl+T – Open a new tab.
Ctrl+N – Open a new browser window.
Alt+F4 – Close the current window. (Works in all applications.)

Mouse Actions for Tabs

Middle Click a Tab – Close the tab.
Ctrl+Left Click, Middle Click – Open a link in a background tab.
Shift+Left Click – Open a link in a new browser window.
Ctrl+Shift+Left Click – Open a link in a foreground tab.

Navigation

Alt+Left Arrow, Backspace – Back.
Alt+Right Arrow, Shift+Backspace – Forward.
F5 – Reload.
Shift+F5 – Reload and skip the cache, re-downloading the entire website.
Escape – Stop.
Alt+Home – Open homepage.

Zooming

Ctrl and +, Ctrl+Mousewheel Up – Zoom in.
Ctrl and -, Ctrl+Mousewheel Down — Zoom out.
Ctrl+0 – Default zoom level.
F11 – Full-screen mode.

Scrolling

SpacePage Down – Scroll down a frame.
Page Up – Scroll up a frame.
Home – Top of page.
End – Bottom of page.
Middle Click – Scroll with the mouse.

Address Bar

Ctrl+LAlt+DF6 – Focus the address bar so you can begin typing.
Ctrl+Enter – Prefix www. and append .com to the text in the address bar, and then load the website. For example, type howtogeek into the address bar and press Ctrl+Enter to open www.howtogeek.com.
Alt+Enter – Open the location in the address bar in a new tab.

Search

Ctrl+KCtrl+E – Focus the browser’s built-in search box or focus the address bar if the browser doesn’t have a dedicated search box. (Ctrl+K doesn’t work in IE, Ctrl+E does.)
Alt+Enter – Perform a search from the search box in a new tab.
Ctrl+FF3 – Open the in-page search box to search on the current page.
Ctrl+GF3 – Find the next match of the searched text on the page.
Ctrl+Shift+GShift+F3 – Find the previous match of the searched text on the page.

History & Bookmarks

Ctrl+H – Open the browsing history.
Ctrl+J – Open the download history.
Ctrl+D – Bookmark the current website.
Ctrl+Shift+Del – Open the Clear Browsing History window.

Other Functions

Ctrl+P – Print the current page.
Ctrl+S – Save the current page to your computer.
Ctrl+O – Open a file from your computer.
Ctrl+U – Open the current page’s source code. (Not in IE.)
F12 – Open Developer Tools. (Not in Firefox.)

Does one of these keyboard shortcuts not work in a specific browser, or is there another important one we missed here? Leave a comment and let us know.

Saturday, May 19, 2012

How To Hide Passwords in an Encrypted Drive Even the FBI Can’t Get Into


3696386615_2e5538e680_o

Encryption tools exist to protect your privacy… and also to make you feel like you’re an awesome spy. Today we’ll use a portable USB drive to hold all of your passwords encrypted in a virtual disk hidden inside a file.
Certain kinds of cryptography were once called “weapons of mass destruction” because certain people thought it was so dangerous. Although clever people are making it good security more and more difficult, encryption tools like the one we’ll be using today are readily available, free, and provide a high level of security that is nearly impossible to break into if done properly. Put on your spy mask and keep reading to find out how to build the perfect encrypted password safe.
And for the skeptics that are curious about the “FBI” claim in our headline, you can read up on Operation Satyagraha, where money launderer Daniel Dantas has successfully encrypted his data and kept the FBI at bay for as long as a year with the very tools we’re going to use today.

Step 1: Get A Reliable USB Drive

If you’re like many geeks, you’ve had your fair share of USB keydrives die on you. The cheap ten dollar drives may not be hardy enough to put a vault of your most important passwords on, so you may have to get a little spendy and pick up one that will last for a while. How-to Geek doesn’t endorse any particular brand of USB drives, but the author has had a lot of success with the Lacie Iamakey seriesLifehacker has featured them onseveral occasions, and they take a beating and keep your data safe. Use any brand that you think is good enough to hold keys to your online life—feel free to take the author’s recommendation with all the grains of salt you see fit.

Step 2: Create An Encrypted Drive or File with Truecrypt

A lot of software exists for encrypting files, but Truecrypt is a very solid choice. The two features we’re interested in are the ability to encrypt hidden files and the ability to run Truecrypt as portable software. You’ll need both if you ever intend to use your encrypted password key on any machine that isn’t your own.
We’ve done several great guides on how to use TrueCrypt, so we’re not going to delve too deeply into the details today. Here we’ll go over our a basic installation of a portable version of TrueCrypt on your USB disk. To begin, run the TrueCrypt installer and select “Extract” to install it on the USB disk.
And if you prefer, check out our previous guides to the program if you want to try and make your spy drive some other way.

TrueCrypt can’t be used “transparently” as a portable EXE file. This basically means that you’ll need administrator control over a machine to use it as a portable application. If this is okay to you, simply hit yes to go on to the next step. If not, you won’t really be able to open your encrypted drive on any machine but one with TrueCrypt installed, effectively tying it to your home PC. For today’s example, we’ll just be extracting it to the USB disk.
Extract the TrueCrypt files to any folder on the disk.
Find the TrueCrypt.exe file on your USB disk and run it. You’ll have to give that pesky administrator permission to start the program.
With TrueCrypt open, find “Create New Volume.”
We’ll be creating a volume hidden inside a file. Again, since we’ve already covered it, we’re going to be brief. For a more detailed article on creating a hidden volume with TrueCrypt (including how to create a hidden volume inside a hidden volume) check out our older article on hidden TrueCrypt volumes.
TrueCrypt asks us to pick a file to use as our hidden volume. Pick an empty, inconspicuous junk file. Don’t use anything important, because this file will be overwritten with your encrypted volume once you’re done.
With your volume file selected, click next to go onward.
TrueCrypt supports lots of different Encryptions Algorithms, but the default one will work well enough. Research them all if you care to, or just use the default AES encryption.
You’ll pick a size for your virtual disk. Unless your disk is full of big files, it might get noticed if it is too large. But don’t make it too small, because you might not be able to fit the portable application in the virtual disk.
Once that’s done, input a password or passphrase and optional keyfiles. You should probably be able to remember any password, but it should be secure enough that brute force methods of password cracking won’t break it easily.
TrueCrypt (and KeePass as well) can use practically any kind of file as part of the password. This can add extra layers of security beyond any password to your hidden volume. Simply be careful in your choice of file, since any change to the file’s contents may mean that it will no longer open your volume, and your data may be lost forever. When you’re done picking (or not using) keyfiles, hit OK, then hit Next on the “Outer Volume” screen.
Click format when you’re done looking at the random strings generated by your mouse movements.
Last warning—you’re overwriting the file you picked. Make sure you don’t use one you intend to keep!
You can now mount your “outer volume” on this screen and go on to create a “hidden volume” if you wish.
It’s pretty easy and can provide yet another layer to your labyrinth of encryption. But for our demonstration today, we’ll be skipping this step and mounting our drive to install KeePass.

Step 3: Mount the Hidden Drive and Install KeePass Portable

With TrueCrypt open, you can now open your hidden volume using your password and keyfile or keyfiles. Once you’ve mounted your virtual disk, you can open it by double clicking it in TrueCrypt.
If you’re following along, you’ll find that your new virtual disk is empty.
If you haven’t already, you can download KeePass portable to use on your new USB disk. You can download the standard version and only keep your passwords on the encrypted drive, but the portable version is also free and very easy to install on a USB disk.
Double click the installer to put the portable app on your (currently mounted) virtual disk.
In our example earlier, we mounted our encrypted disk as “G:” so we simply install KeePassPortable in that directory.
KeePass is a simple an intuitive program to use. It will generate and store long passwords as secure as we know how to make them. Even though the best practice may be turning towards passphrases over passwords, KeePass will store any either kind and recall it for you whenever you need to break into your accounts.
Assuming you’ve got the portable app installed, run it and select the option to create a new Password Database file. Like TrueCrypt, you can elect to use a password and keyfile, recommended to add security beyond a simple password or phrase. Just remember, the same rule applies—don’t use a file that is likely to change, because you may lock yourself out of your password safe forever if it does.
We won’t go into the wonders of KeePass today, since we’ve already covered them ages and ages ago and the program hasn’t functionally changed all that much. But, once you’ve created your password database, save it to the encrypted drive (G:/ in our example) to keep it away from prying eyes.
For a more in-depth write up on KeePass, check out our previous write-up, with the basics and great tips on how to use it.

Step 4: Your Passwords are Now Safe From The KGB

Now that you’ve got your passwords locked away in an encrypted vault, you can rest assured they’re safe from all but the most insanely dedicated of users. So what else do you want to use your new cryptographic powers for? Sensitive, personal files can be stored here, and other portable apps can be installed in your hidden virtual disk. Why not tell us about your experience with TrueCrypt in the comments, or simply email your thoughts to ericgoodnight@howtogeek.com.