Tag: Linux

tmux and Example Config

I am a big fan of the tmux terminal multiplexer when SSH’ing into any hosts. Definitely check it out if you don’t know about it. By default tmux is pretty bare, but you can use my current .tmux.conf as a reference. The configuration file below will essentially create labels for each terminal showing the currently running program.

Example output produced by my .tmux.conf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
set-option -g default-terminal "xterm-256color"
#set-option -g default-terminal "screen-256color"

set-option -g status-fg white
set-option -g status-bg black
#set-option -g status-bg white

set-option -g prefix C-a
bind-key C-a last-window

#set-window-option -g mode-mouse on

setw -g window-status-current-attr underscore

set -g status-keys vi
setw -g mode-keys vi

Using sed to batch rename files

Image Resize for Windows is a handy utility for batch resizing images. I use that for batch resizing pictures, but the only thing about the resized pictures is that it puts “ (Custom)” or whatever size you specify in the filename. To rename the resized files you can use sed (if you have cygwin on Windows) to easily rename these files to what pattern you need. To do this a command like the following will do. This specific version will replace

find . -iname \*Custom\* | sed -e 's/\(.*\)\( (Custom)\)\(.*\)/mv "\0" "\1_small\3"/' | sh

Disclaimer: There are a gazillion ways to achieve this goal; this is just one of them.

Compiling what…?!!

Lol, I saw this earlier while compiling Samba4. It says “Compiling torture…” I wonder what it does 🙂

Compiling what!?!

“device not managed” in Ubuntu Karmic 9.10

I just finished upgrading my laptop to Ubuntu 9.10 (Karmic Koala). After the upgrade finished I noticed that for my wireless card the Network Manger applet in gnome claimed “device not managed.” A quick search revealed that this had happened in the past. I had to set managed=true in /etc/NetworkManager/nm-system-settings.conf. Doing this again and restarting the network service didn’t seem to fix the issue. After a few minutes of looking around in /etc/init.d I saw another service (network-manager!) that needed to be restarted. In summary is here is what you need to do.

1. Edit /etc/NetworkManager/nm-system-settings.conf and set managed=true

Specifically change the ‘managed’ under ifupdown…

1
2
[ifupdown]
managed=false

…to true.

1
2
[ifupdown]
managed=true

2. Restart networking and network-manager services.

You can always restart the computer, but where is the fun in that 🙂 To get things to work without restarting, run the following commands.

1
2
sudo /etc/init.d/network-manager restart
sudo /etc/init.d/networking restart

3. Have fun!

Change Ubuntu repository

The default Ubuntu repository is very busy and sometimes slow, especially around releases. So, one of the first things that I generally do after installing Ubuntu is change the repository to one that is generally more responsive. Synaptics has a nice features which it tests which repository might be best in your case, use that to figure out which one to use. In my case the MIT repository mostly seems to be very snappy. Below are the steps to changing the repository. Fortunately, it is all point-and-click.

1. Open Synaptic Package Manager (Ubuntu menu > System > Administration > Synaptic Package Manager).
2. Go to Settings menu, then “Repositories”

Choose "Repositories"

3. Under the first tab “Ubuntu Software” open the “Download from:” drop down and select other.

Choose "Other" from "Download from"

4. Here you have two options, first let Synaptic figure out the best server by clicking “Select Best Server” or pick one that I know generally works pretty good in US, the MIT repository (Under “United States” choose ubuntu.media.mit.edu).

Choose the MIT repository under "United States"

5. Click “Choose Server” and then close.
6. Now reload the repository and enjoy the faster download speeds 🙂

Slicehost vs. Linode? Or x86-64 vs x86-32?

Reading this post by David Welton it seems that Slicehost’s choice of x86-64 architecture wasn’t a good choice. x86-64 is supposed to have performance advantages, but David’s results are not showing any (in fact it seems proportionally slower). I am interested to see what Slicehost says about these results.

New computer, and “64-bit thoughts”

System properties showing the 64-bit Windows Vista

About a week and a half ago I built a new computer, and after doing a lot of research on 64-bit operating systems I finally decided that it was time that I switched. I am using plurals (operating system_s_) because once I switch to the new computer I was going to move the “older” one to become the server. One additional attraction for going to 64-bit on the main computer was that I was getting 4GB of RAM, which 32-bit Windows doesn’t completely utilize due to technical limitations.

Read full post...

screen is awesome!

Screenshot showing two windows sharing the same screen session

Linux/Unix has so many cool utilities for the command line and very often I find new things about the tools that I am already using. I have recently upgraded to dual screens at home (19” and 22” combo) and needed a command line window to be open on each screen. I have been using screen to have multiple sessions and keep my taskbar uncluttered1, but the multiple windows put an interesting spin on my screen usage. I wanted to be able to switch to any session in either window without having to detach and then reattach in a different window. So, I started reading the screen manual and noticed the -x command line argument. Guess what it does? Attach to a session which is already attached elsewhere (multi-display mode). Exactly what I was looking for!

By the way if you are looking a hosting service, make sure to checkout WebFaction. They have excellent packages and support, and have screen installed on their servers.

1Additionally, with screen you don’t have to open multiple SSH session if you are connected remotely.

Mapping Caps Lock to Backspace in Linux

One of the first things that I do after installing the operating system is remap the Caps Lock key to the Backspace key. This is because I have rarely seen any need for the Caps Lock key, while the Backspace is much more useful. You can remap this in Windows using a very nice program called SharpKeys. In Linux there are several ways to accomplish this. You can change the underlying keyboard layout, or if you do not use the terminal directly and instead use the command line interface only through X then you can accomplish this very easily by using xmodmap.

Basically there are two steps.

remove lock = Caps_Lock
keysym Caps_Lock = BackSpace

Save the above code to a file (~/bin/map_caps_lock_to_backspace.txt
, may I suggest), and then execute xmodmap map_caps_lock_to_backspace.txt. Try it out, assuming you are in an X session, now the Caps Lock key will act as Backspace!

There you have it. Now, to do this every time that X starts, you can add this to your favorite window manager (XFCE > Settings > Autostarted Application).