Posts Tagged linux

Debugging Wifi on Ubuntu Linux

To actually get ubuntu to give you some logging when connecting to wifi (you know so that you can act according to some information rather than at random):

  1. Become superuser
  2. Run killall NetworkManager
  3. Run NetworkManager –no-daemon

This will then give you output for every stage of the connection process.

Network manager is (I believe) the tool that handles the overall process of opening a wifi connection using different processes (iwlist, iwconfig, wpa_supplicant etc) to do the actual connection.

Notes

Messages of the form “supplication connection state change number -> number” are (i think) from wpa_supplicant. Someone who isn’t me should change NetworkManager so that these are written in english. For now note that the states mean the following:

0 – WPA is disconnected
1 – WPA is inactive (no enabled connections and wpa isn’t trying to connect
2 – WPA is scanning
3 – WPA is associating (a loose-form of connection)
4 – WPA is associated
5 – WPA 4-way hand shake
6 – WPA group handshake
7 – WPA completed

I was seeing a lot of 3 -> 0 state changes when I was debugging. [This was taken from the wpa_supplicant source code in src/common/defs.h]

Add comment March 7, 2009

Backing up one’s home directory with tar

This is something that should be fairly easy. However in practice there are some problems:

  1. Tar has a proliferation of options and can be an effort to use – at least if you are using it infrequently
  2. One’s home directory often contains large files (like perfectly legally downloaded music and videos), which you don’t really want to back up repeatedly.
  3. Some applications put rather large things in hidden directories under your home directory

There are various solutions:
(more…)

3 comments April 20, 2008

Fixing catastrophic mistakes with apt-get

Story for the patientDecorative Picture

I managed to utterly break a linux installation yesterday, by trying to install a single package with apt-get. Apt helpfully decided to suggest removing a number of important packages, and I absentmindedly agreed.

The lesson learned here would be that you should always press ‘n’ immediately and think whenever apt suggests removing more than a couple of packages, if I didn’t know this. I suppose the real lesson is just to be less dim, but alas this never seems to work. Another lesson is to especially be less dim when you only have a wireless internet connection and you decide to remove the things that make it work.

Anyway, I found a moderately nice way of reverting these damaging changes.

Although apt does not do any logging, it uses dpkg for installation (on debian type systems at least) and dpkg does do logging.

Looking at /var/log/dpkg.log I found that it neatly recorded all of dpkg’s operations so I was able to get a list of all the packages I had absentmindedly removed by using some crpytic shell commands:

cat /var/log/dpkg.log | grep remove | cut -d " " -s -f 4 > ~/removed-packages

I then could reinstall these with:

apt-get install `cat removed-packages`.

Hurrah for copious logging and shell textual data processing… or something like that.

Summary for the impatient:

Apt doesn’t store a log, but dpkg does and apt uses dpkg. The relevant log file is /var/log/dpkg.log. To get a list of the removed packages, and install them again you can run:

cat /var/log/dpkg.log | grep remove | cut -d " " -s -f 4 > ~/removed-packages; apt-get install `cat ~/removed-packages`

as a root user.

1 comment March 11, 2008

How to stop the bell ringing in bash

To stop bash from trying to ring the bell add

set bell-style none

to the /etc/inputrc file. You can also be added to a local ~/.inputrc file – but this won’t work if
you log in as root.

Also, note that this won’t stop other applications from trying to ring the
bell – for this it might be best to switch off the bell at BIOS level.

See man bash.

Other applications whose bells you might like to stop:

less: Use the -q option. This can be acheived permanently by adding alias less=”less -q” to your .bashrc file.

man: man uses the $PAGER environment variable to display man pages, or the default pager (normally less) otherwise. Therefore add export PAGER=”less -q” to your .bashrc file.

vim: By default vim rings the bell. To stop this type set vb t_vb= at the colon-line, or add it to your .vimrc file.

emacs: Set the variable ring-bell-function to a function that doesn’t do anything. (setq ring-bell-function (lambda () nil)

1 comment March 9, 2008

How to not break your hands when using key combinations (using *nix)

I find that trying to use both hands when entering key combinations feels slightly less inclined to cause injury than using the same hand. For example, instead of pressing control-C with only your left hand, you hold the control button with your right hand and with you left hand press a control button. This approach seems to limit the degree to which you need to contort your fingers – however I’m not a doctor, so perhaps you shouldn’t believe what I say.

As one might expect, there is a slight hurdle to jump to retrain oneself to use a completely new set of keybindings, which just happen to be pressing the same keys.

Before one can set out on such a mission there are some problems with the alt key that need to be negotiated. The alt key on the right-hand side is used as a modifier to enter interesting characters.By rebinding it so as to behave like the alt key on the right hand-side, you can perform alt-containing key combinations with either hand.

This rebinding can be done for one session by typing the following commands into the shell:

xmodmap -e "keycode 113 = Alt_L"
#This should make the left hand alt key (key 113) behave like a left handed alt.
xmodmap -e "clear mod5"
#This should stop any key (and particular key 113) from being used to insert non-latin characters.

To make this permament one needs to modify the .xmodmap file in one’s home directory – or create it should it not exist. The arguments to the -e options are then added to this file. .xmodmap should then be executed by xmodmap when X starts.

For the purpose of cutting and pasting, the new section added to one’s .xmodmap file looks like:

<pre>
keycode 113 = Alt_L
clear mod5
</pre>

Notes

See “man xmodmap” for more details on how it works.

If your love for bizarre characters exceeds you desire for possible less contorted hands, you could try rebinding a different key to act as ‘mod5′. I might recommend using the windows (super) and context menu keys for this.

You should be able to do this with the ‘add’ command – though not that this takes keysyms rather than keycodes as arguments. (This will, hopefully, make sense after consulting the manual).

On windows one can use the freeware program Sharpkeys to carry out this change. This works by setting changing an appropriate registry key.

Add comment March 9, 2008


Meta

Facets

Add new tag AOP apt aspect oriented programming assumes knowledge autiobiographical bash scripts bell books clarity code samples configuration console emacs for the benefit of google functional programming graphical design hacks higher-order functions howtos intention revealing programming keyboard links linux note to self opinions parsing patterns philosophising philosophizing programming python random ideas refactoring removing packages stories succinct svn systems stuff theoretical philosophizing typing vim viper work ethic you probably don't want to read this

Archives

Pages

 

November 2009
M T W T F S S
« Aug    
 1
2345678
9101112131415
16171819202122
23242526272829
30