Linux For Cynics One user's experiences with Linux

18Jan/111

How to use vi-mode in bash

If you are a fan of vi you probably want everything under the sun to work like vim does. To use vi-style input in Terminal, all you have to do is add this line to your .bashrc file:

set -o vi

If you just want to try it out, you can just type that in Terminal, and it will be in vi mode for the rest of your session. Keep in mind that vi has two modes - insert and command. To switch between them, hit ESC.

Now, if you haven't used vi before, here're some useful commands: (Remember, hit ESC to get into command mode).

h	 Move cursor left
l	 Move cursor right
A	 Move cursor to end of line and put in insert mode
0	 (zero) Move cursor to beginning of line (doesn't put in insert mode) 
i	 Put into insert mode at current position
a	 Put into insert mode after current position
dd	 Delete line (saved for pasting)
D	 Delete text after current cursor position (saved for pasting)
p	 Paste text that was deleted
j	 Move up through history commands
k	 Move down through history commands
u	 Undo
Filed under: command line 1 Comment
14Jan/110

How to Setup Synergy

Synergy?

Synergy is a program that runs on Windows/Linux/Mac and allows for the sharing of a keyboard and mouse between multiple machines. Synergy is a client/server architecture -where there is one server and multiple clients connect to it. Synergy configures the sharing by specifying which screen is to left/right/above/below others.

Setup

This tutorial assumes that you want the Linux box to be the synergy server and the Windows box will connect to this server.
This tutorial also assumes that your Linux screen is to the left of your Windows screen - but that is easily changeable. This tutorial assumes you are running Fedora or Ubuntu. Most of the information in this tutorial comes from http://www.mattcutts.com/blog/how-to-configure-synergy-in-six-steps/ and other tutorials.

Server Side (Linux Box) Instructions

Install Synergy

Open a Terminal and, if running Fedora, run the command:

sudo yum install synergy

Or in Ubuntu:

sudo apt-get install synergy

This will download and install the latest version of synergy we have access to.

Configure Server Settings

As root, create a configuration file in the /etc directory called "synergy.conf":

sudo gedit /etc/synergy.conf

In it add configuration that looks something like this:

section: screens
linuxbox:
windowspc:
end
section: aliases
windowspc:
<YOUR PC NAME>
linuxbox:
<YOUR LINUX NAME>.local
end
section: links
linuxbox:
left = windowspc
windowspc:
right = linuxbox
end
section: options
screenSaverSync = false
# My KVM uses Scroll Lock to switch screens, so set the
# hotkey to lock the cursor to the screen to something else
keystroke(f12) = lockCursorToScreen(toggle)
end

In the above configuration, replace:

<YOUR PC NAME> - with your PC's machine name.

This can be found by going to the Control Panel, and then opening System. Then clicking the Computer Name tab.
It should be something like - BOBSWINDERPSPC.

<YOUR LINUX NAME> - with your Linux machine's name.

This can be found by running the following command in the Terminal:

uname -a

It'll be something like my-linux-box.

Client Side (Windows Box) Instructions

Install and Configure Windows Client.
On the Windows machine, go and download Synergy from here:
http://synergy-plus.googlecode.com/files/synergy-plus-1.3.4-Windows-x86-r1.exe (direct link).

After installing this application, open the application and set the program to:

Use another computer's shared keyboard and mouse (client)

Then for the Other Computer's host name, use the name of the Linux box you discovered earlier. Something like:
my-linux-box.local

Connecting

Test out your configuration
On your Linux machine, from the Terminal, run:

synergys -f --config /etc/synergy.conf

This will start the Synergy server in test mode with your configuration file.

Now on the Windows machine, click the "Test" button to start the Windows client.

You should now be able to move your mouse back and forth between machines.
(Try copy and pasting as well! RAD!)

Setting and Forgetting

We want these programs to run automatically on startup.

Windows Client

For the Windows client, you can click the "AutoStart" button and start it up when your computer starts up. If it won't let you save this configuration, make sure you are running Synergy with administrator rights.

Linux Server

Here we want to create a new startup process that has the synergy server starting with the configuration file we wrote.

Click the System drop-down menu and then navigate to Preferences -> Personal -> Sessions

Click the Add Button

For name: Synergy server
For command:

/usr/bin/synergys --config /etc/synergy.conf

You can leave comment blank

Security

By default, synergy is unsecured. This means someone could sniff the traffic it sends over the network.

Some information on encrypting this traffic using ssh can be found:
http://www.cs.uu.nl/technical/services/ssh/putty/puttyfw.html

Another tutorial for setting up ssh based encryption for synergy can be found here:
http://tech.jonathangardner.net/wiki/Synergy_%2B_Putty_on_Windows

7Jan/110

Linux Aliases in .bashrc

About .bashrc

The ~/.bashrc is a hidden file that lives in your home directory that is loaded every time you access the command line(shell) from your Linux box.

Here, you can provide significant customizations to improve your terminal experience and quickly access things you want to use frequently.

This short guide is about adding aliases to this file to provide you with quick shortcuts to commonly used tools.

Alias?

An alias in the Linux command line is similar to a short-cut in Windows. It maps a string to one or more shell commands.
This can provide quick access to commonly used tools or allow you to create new tools out of existing Linux commands.

Let's look at an example:

alias e='gedit'

This aliases the string "e" to the command "gedit". So every time I type "e" in the Terminal, that will be mapped to the "gedit" command which will open a text editor. So I could type something like:

$ e some_file.txt

And that would open gedit with the file some_file.txt loaded.

Making Your Own

In the Terminal, open your .bashrc file:

$ gedit ~/.bashrc

Somewhere in this file, after the initial setup, add your aliases. Here are my current aliases, with comments:

#aliases
# opens a directory in the GUI
alias o='nautilus'
# maps gedit to e
alias e='gedit'
# maps gedit to edit
alias edit='gedit'
# allows me to use grep with the recursive and color flag enabled
# much more powerful!
alias g="grep -rn --color"

Try them out!

In the terminal, try:

$ o .

A new window should open with your current directory displayed.

Now go to some directory like your Project's Sandbox and try out

g SomeText .

Which will recursively search for this text in all your files and display it will coloring.

(Hit Ctrl+c to stop the search prematurely)

Filed under: How to No Comments
2Jan/110

The Best FTP Client for Linux

screenshot-midnight commander
Just use midnight commander.

1Jan/110

Desktop Linux Sucks

Maybe not as much as it used to, but it's still terrible. However, I find it preferable to the alternatives. With a little work, I can even get Linux to make my PC useful and do neat things. This blog is about that process.

Filed under: Opinion No Comments