Difference between revisions of "Ubuntu notes"

From Noah.org
Jump to navigationJump to search
Line 33: Line 33:
 
<pre>
 
<pre>
 
screen /dev/ttyUSB0 115200,cs8,-parenb,-cstopb,-hupcl
 
screen /dev/ttyUSB0 115200,cs8,-parenb,-cstopb,-hupcl
</pre>
 
 
== Mixing apt-get and aptitude ==
 
 
I often switch back and forth between using `apt-get` and `aptitude`. I put `apt-get` in scripts or use it from the command-line, but I usually use `aptitude` for browsing, searching, and installing packages by hand. So, is it OK to mix the different apt front-ends such as `apt-get` and `aptitude`? The answer is, "sort of". It's harmless for installing packages, but if you remove a package that was installed by one of the other front-ends then they can get confused and you might end up with packages remaining installed that you don't need or having packages that you manually installed automatically removed for you. Each front-end keeps its own separate database of which files you manually specified for installation and the package dependencies that were installed automatically to satisfy your manual request. So later, if you decide to remove a package, the front-end uses its database to decide if it should remove the dependency packages or not. The problem is they each have their own database that isn't shared.
 
 
One solution is to use 'apt-mark-sync'. I generally use `aptitude` most of the time, so I treat `aptitude` as the master. I run this command to keep the other front-ends in sync:
 
 
<pre>
 
apt-mark-sync aptitude all
 
 
</pre>
 
</pre>
  
Line 67: Line 57:
 
</pre>
 
</pre>
  
== unknown group in statusoverride file ==
+
== rc.d maintenance ==
 +
 
 +
This covers `sysv-rc-conf` and `update-rc.d`.
 +
 
 +
 
 +
=== sysv-rc-conf ===
 +
 
 +
The `sysv-rc-conf` command similar to RedHat's `chkconfig`. It is intended as an easy user interface to the rc.d links.
 +
It’s a replacement for programs like ntsysv(8) or rcconf(8).
  
This has only happened to me once, but you may also see an error like this when using a package manager:
+
If you just run it with no options it will start a curses console GUI. It's pretty simple to use.
  
 
<pre>
 
<pre>
dpkg: syntax error: unknown group `Debian-exim' in statusoverride file
+
sysv-rc-conf
E: Sub-process /usr/bin/dpkg returned an error code (2)
 
 
</pre>
 
</pre>
  
This is due to a faulty package removal. The package maintainer may have forgotten to remove the override when uninstalling a package. Usually it is safe to fix this by manually running something like the following:
+
You can also perform all actions through CLI options similar to `chkconfig` except there are no --add and --del options. You don't need them -- just put your new start-stop script in /etc/init.d and use the 'on' or 'off' described commands below. The 'on' and 'off' commands work on run-level 2,3,4,5 by default.
  
 
<pre>
 
<pre>
dpkg-statoverride --remove /etc/exim4/passwd.client
+
sysv-rc-conf --list
 +
sysv-rc-conf --list consolekit
 +
sysv-rc-conf consolekit on
 +
sysv-rc-conf consolekit off
 
</pre>
 
</pre>
  
== How to unmark all packages marked to be upgraded in aptitude ==
+
=== update-rc.d ===
  
If you hit 'U' to mark all upgradable packages to be you may change your mind and decide that you don't want to risk upgrading 20 different system critical packages. The trick is that it difficult to convince Aptitude to forget about these queued packages. You can select each one and hit '-' to unmark them, but that can be a drag is you have a lot of them in the list. Oddly, aptitude does not provide a way to unmark them all from inside the curses GUI, but you can easily do this from the command-line:
+
The `update-rc.d` command is more intended for use in scripts that manage rc.d links. Use this if you want to install new default links to a start-stop script. It will do nothing if any links already exist. A start-stop should have a comment section that starts with '### BEGIN INIT INFO'. This is used to define the default run level actions. To install a new start-stop script with the defaults use this:
  
 
<pre>
 
<pre>
aptitude keep-all
+
update-rc.d foobar defaults
 
</pre>
 
</pre>
  
== selecting text in Aptitude ==
+
== ConsoleKit -- AKA console-kit-daemon ==
  
Aptitude takes control of the mouse which disables xterm mouse text selection. To override this simply hold SHIFT while you select text with the mouse.
+
You may see this daemon running and wonder what the hell it's for. It does a lot of stuff that I don't need at the moment. The simplest explanation is that ConsoleKit is used to implement "fast user switching" -- you know, where you can switch to a different user without logging the current user out. It is annoying that there are no man pages for it, but you can find some documentation under /usr/share/doc/consolekit. ConsoleKit was initially written by William Jon McCann. The homepage for it is here [http://freedesktop.org/wiki/Software/ConsoleKit http://freedesktop.org/wiki/Software/ConsoleKit].
  
== supporting old releases in apt ==
+
You can shutdown ConsoleKit -- this seems harmless:
 
 
Sometimes you find yourself needing to support an old release of Ubuntu and the original apt repositories are no longer supported or mirrored. Luckily, Ubuntu archives the old repositories at [http://old-releases.ubuntu.com/ubuntu/dists/ http://old-releases.ubuntu.com/ubuntu/dists/]. You will need to update your /etc/apt/source.list file. For example, if you wanted to have access to edgy you would add the following to the top of sources.list:  
 
  
 
<pre>
 
<pre>
deb http://old-releases.ubuntu.com/ubuntu/ edgy-updates main restricted
+
/etc/init.d/consolekit stop
deb http://old-releases.ubuntu.com/ubuntu/ edgy-security main restricted
 
deb http://old-releases.ubuntu.com/ubuntu/ edgy main restricted
 
deb http://old-releases.ubuntu.com/ubuntu/ edgy universe
 
deb http://old-releases.ubuntu.com/ubuntu/ edgy-security universe
 
 
</pre>
 
</pre>
  
== rc.d maintenance ==
+
== apt aptitude and other package managers ==
 +
 
 +
 
 +
=== Mixing apt-get and aptitude ===
 +
 
 +
See also [http://newbiedoc.berlios.de/wiki/Aptitude_-_using_together_with_Synaptic_and_Apt-get].
 +
 
 +
I often switch back and forth between using `apt-get` and `aptitude`. I put `apt-get` in scripts or use it from the command-line, but I usually use `aptitude` for browsing, searching, and installing packages by hand. So, is it OK to mix the different apt front-ends such as `apt-get` and `aptitude`? The answer is, "sort of". It's harmless for installing packages, but if you remove a package that was installed by one of the other front-ends then they can get confused and you might end up with packages remaining installed that you don't need or having packages that you manually installed automatically removed for you. Each front-end keeps its own separate database of which files you manually specified for installation and the package dependencies that were installed automatically to satisfy your manual request. So later, if you decide to remove a package, the front-end uses its database to decide if it should remove the dependency packages or not. The problem is they each have their own database that isn't shared.
 +
 
 +
One solution is to use 'apt-mark-sync'. I generally use `aptitude` most of the time, so I treat `aptitude` as the master. I run this command to keep the other front-ends in sync:
  
This covers `sysv-rc-conf` and `update-rc.d`.
+
<pre>
 +
apt-mark-sync aptitude all
 +
</pre>
  
 +
=== unknown group in statusoverride file ===
  
=== sysv-rc-conf ===
+
This has only happened to me once, but you may also see an error like this when using a package manager:
  
The `sysv-rc-conf` command similar to RedHat's `chkconfig`. It is intended as an easy user interface to the rc.d links.
+
<pre>
It’s a replacement for programs like ntsysv(8) or rcconf(8).
+
dpkg: syntax error: unknown group `Debian-exim' in statusoverride file
 +
E: Sub-process /usr/bin/dpkg returned an error code (2)
 +
</pre>
  
If you just run it with no options it will start a curses console GUI. It's pretty simple to use.
+
This is due to a faulty package removal. The package maintainer may have forgotten to remove the override when uninstalling a package. Usually it is safe to fix this by manually running something like the following:
  
 
<pre>
 
<pre>
sysv-rc-conf
+
dpkg-statoverride --remove /etc/exim4/passwd.client
 
</pre>
 
</pre>
  
You can also perform all actions through CLI options similar to `chkconfig` except there are no --add and --del options. You don't need them -- just put your new start-stop script in /etc/init.d and use the 'on' or 'off' described commands below. The 'on' and 'off' commands work on run-level 2,3,4,5 by default.
+
=== aptitude schedule query ===
 +
 
 +
This is a safe command to run. This shows what Aptitude has scheduled for install, delete, purge, etc.
  
 
<pre>
 
<pre>
sysv-rc-conf --list
+
aptitude install -sfD
sysv-rc-conf --list consolekit
 
sysv-rc-conf consolekit on
 
sysv-rc-conf consolekit off
 
 
</pre>
 
</pre>
  
=== update-rc.d ===
+
=== How to unmark all packages marked to be upgraded in aptitude ===
  
The `update-rc.d` command is more intended for use in scripts that manage rc.d links. Use this if you want to install new default links to a start-stop script. It will do nothing if any links already exist. A start-stop should have a comment section that starts with '### BEGIN INIT INFO'. This is used to define the default run level actions. To install a new start-stop script with the defaults use this:
+
If you hit 'U' to mark all upgradable packages to be you may change your mind and decide that you don't want to risk upgrading 20 different system critical packages. The trick is that it difficult to convince Aptitude to forget about these queued packages. You can select each one and hit '-' to unmark them, but that can be a drag is you have a lot of them in the list. Oddly, aptitude does not provide a way to unmark them all from inside the curses GUI, but you can easily do this from the command-line:
  
 
<pre>
 
<pre>
update-rc.d foobar defaults
+
aptitude keep-all
 
</pre>
 
</pre>
  
== ConsoleKit -- AKA console-kit-daemon ==
+
=== selecting text in Aptitude ===
 +
 
 +
Aptitude takes control of the mouse which disables xterm mouse text selection. To override this simply hold SHIFT while you select text with the mouse.
  
You may see this daemon running and wonder what the hell it's for. It does a lot of stuff that I don't need at the moment. The simplest explanation is that ConsoleKit is used to implement "fast user switching" -- you know, where you can switch to a different user without logging the current user out. It is annoying that there are no man pages for it, but you can find some documentation under /usr/share/doc/consolekit. ConsoleKit was initially written by William Jon McCann. The homepage for it is here [http://freedesktop.org/wiki/Software/ConsoleKit http://freedesktop.org/wiki/Software/ConsoleKit].
+
=== supporting old releases in apt ===
  
You can shutdown ConsoleKit -- this seems harmless:
+
Sometimes you find yourself needing to support an old release of Ubuntu and the original apt repositories are no longer supported or mirrored. Luckily, Ubuntu archives the old repositories at [http://old-releases.ubuntu.com/ubuntu/dists/ http://old-releases.ubuntu.com/ubuntu/dists/]. You will need to update your /etc/apt/source.list file. For example, if you wanted to have access to edgy you would add the following to the top of sources.list:  
  
 
<pre>
 
<pre>
/etc/init.d/consolekit stop
+
deb http://old-releases.ubuntu.com/ubuntu/ edgy-updates main restricted
 +
deb http://old-releases.ubuntu.com/ubuntu/ edgy-security main restricted
 +
deb http://old-releases.ubuntu.com/ubuntu/ edgy main restricted
 +
deb http://old-releases.ubuntu.com/ubuntu/ edgy universe
 +
deb http://old-releases.ubuntu.com/ubuntu/ edgy-security universe
 
</pre>
 
</pre>

Revision as of 11:00, 11 December 2008


I like Ubuntu. Every Linux distro has quirks, but I like working with Ubuntu quirks more than any others.

what security updates do I need?

Report which packages need security updates:

apt-get update
apt-get --dry-run upgrade | grep "^Inst" | grep "-security"

LiveCD serial console boot

Connect the RS-232 serial ports of two machines with a NULL Modem cable.

Select boot option and press F6 to display the kernel boot line. Something like the following:

kernel /boot/vmlinuz-2.6.15-26-386 root=/dev/hda5 ro quiet splash

Edit it to look something like this:

kernel /boot/vmlinuz-2.6.15-26-386 root=/dev/hda5 ro console=ttyS0,115200

On the other machine:

screen /dev/ttyUSB0 115200,cs8,-parenb,-cstopb,-hupcl

Set default binaries for MIME types

Use the 'update alternatives' system. To interactively set the default editor for any text editable MIME type:

sudo update-alternatives --config editor

Or just set it to Vim directly use one of the following:

sudo update-alternatives --set editor /usr/bin/vim.basic
sudo update-alternatives --set editor /usr/bin/vim.python 

some others that I like to set

sudo update-alternatives --set pager /usr/bin/vim-pager-wrapper
sudo update-alternatives --set x-terminal-emulator /usr/bin/urxvt
sudo update-alternatives --set www-browser /usr/bin/w3m
sudo update-alternatives --set x-www-browser /usr/bin/firefox

rc.d maintenance

This covers `sysv-rc-conf` and `update-rc.d`.


sysv-rc-conf

The `sysv-rc-conf` command similar to RedHat's `chkconfig`. It is intended as an easy user interface to the rc.d links. It’s a replacement for programs like ntsysv(8) or rcconf(8).

If you just run it with no options it will start a curses console GUI. It's pretty simple to use.

sysv-rc-conf

You can also perform all actions through CLI options similar to `chkconfig` except there are no --add and --del options. You don't need them -- just put your new start-stop script in /etc/init.d and use the 'on' or 'off' described commands below. The 'on' and 'off' commands work on run-level 2,3,4,5 by default.

sysv-rc-conf --list
sysv-rc-conf --list consolekit
sysv-rc-conf consolekit on
sysv-rc-conf consolekit off

update-rc.d

The `update-rc.d` command is more intended for use in scripts that manage rc.d links. Use this if you want to install new default links to a start-stop script. It will do nothing if any links already exist. A start-stop should have a comment section that starts with '### BEGIN INIT INFO'. This is used to define the default run level actions. To install a new start-stop script with the defaults use this:

update-rc.d foobar defaults

ConsoleKit -- AKA console-kit-daemon

You may see this daemon running and wonder what the hell it's for. It does a lot of stuff that I don't need at the moment. The simplest explanation is that ConsoleKit is used to implement "fast user switching" -- you know, where you can switch to a different user without logging the current user out. It is annoying that there are no man pages for it, but you can find some documentation under /usr/share/doc/consolekit. ConsoleKit was initially written by William Jon McCann. The homepage for it is here http://freedesktop.org/wiki/Software/ConsoleKit.

You can shutdown ConsoleKit -- this seems harmless:

/etc/init.d/consolekit stop

apt aptitude and other package managers

Mixing apt-get and aptitude

See also [1].

I often switch back and forth between using `apt-get` and `aptitude`. I put `apt-get` in scripts or use it from the command-line, but I usually use `aptitude` for browsing, searching, and installing packages by hand. So, is it OK to mix the different apt front-ends such as `apt-get` and `aptitude`? The answer is, "sort of". It's harmless for installing packages, but if you remove a package that was installed by one of the other front-ends then they can get confused and you might end up with packages remaining installed that you don't need or having packages that you manually installed automatically removed for you. Each front-end keeps its own separate database of which files you manually specified for installation and the package dependencies that were installed automatically to satisfy your manual request. So later, if you decide to remove a package, the front-end uses its database to decide if it should remove the dependency packages or not. The problem is they each have their own database that isn't shared.

One solution is to use 'apt-mark-sync'. I generally use `aptitude` most of the time, so I treat `aptitude` as the master. I run this command to keep the other front-ends in sync:

apt-mark-sync aptitude all

unknown group in statusoverride file

This has only happened to me once, but you may also see an error like this when using a package manager:

dpkg: syntax error: unknown group `Debian-exim' in statusoverride file 
E: Sub-process /usr/bin/dpkg returned an error code (2)

This is due to a faulty package removal. The package maintainer may have forgotten to remove the override when uninstalling a package. Usually it is safe to fix this by manually running something like the following:

dpkg-statoverride --remove /etc/exim4/passwd.client

aptitude schedule query

This is a safe command to run. This shows what Aptitude has scheduled for install, delete, purge, etc.

aptitude install -sfD

How to unmark all packages marked to be upgraded in aptitude

If you hit 'U' to mark all upgradable packages to be you may change your mind and decide that you don't want to risk upgrading 20 different system critical packages. The trick is that it difficult to convince Aptitude to forget about these queued packages. You can select each one and hit '-' to unmark them, but that can be a drag is you have a lot of them in the list. Oddly, aptitude does not provide a way to unmark them all from inside the curses GUI, but you can easily do this from the command-line:

aptitude keep-all

selecting text in Aptitude

Aptitude takes control of the mouse which disables xterm mouse text selection. To override this simply hold SHIFT while you select text with the mouse.

supporting old releases in apt

Sometimes you find yourself needing to support an old release of Ubuntu and the original apt repositories are no longer supported or mirrored. Luckily, Ubuntu archives the old repositories at http://old-releases.ubuntu.com/ubuntu/dists/. You will need to update your /etc/apt/source.list file. For example, if you wanted to have access to edgy you would add the following to the top of sources.list:

deb http://old-releases.ubuntu.com/ubuntu/ edgy-updates main restricted
deb http://old-releases.ubuntu.com/ubuntu/ edgy-security main restricted
deb http://old-releases.ubuntu.com/ubuntu/ edgy main restricted
deb http://old-releases.ubuntu.com/ubuntu/ edgy universe
deb http://old-releases.ubuntu.com/ubuntu/ edgy-security universe