Posts tagged: debian

Useful apt commands

By , 2012-10-29 14:46

apt-cache search [searchterm]

search local apt-cache for a package  containing [searchterm]

apt-file list [packagename]

lists all files associated with [packagename], even if the package is not installed

apt-file search [/path/to/file]

search for the package that “owns” [/path/to/file]

apt-cache madison [packagename]

displays all available versions of [packagename]

apt-get install [packagename]=[version]

force apt to install a specific version of a package

ALSA: cannot find card ‘0’ when using USB sound card

By , 2012-02-24 10:16

I was trying to get my Alix board to properly output audio. It has no VGA and no onboard sound card, so I’m using a USB to audio adapater. The card was detected, all appropriate snd- modules loaded according to lsmod, and it showed up in /proc/asound/cards. Problem is it was card1, and alsamixer and most programs use card0 by default.

It seems that Debian configures snd-usb-audio in /etc/modprobe.d/alsa-base.conf with the index=2 option to prevent it from being the primary card. To disable this behaviour, simply comment out the line.

 

Original answer:

So are you using a USB sound card as your audio device?It looks like you might have removed some audio device from your computer, that is why card0 is missing, where as usb card is configured as card1.

Edit /etc/modprobe.d/alsa-base.conf, include/modify the line for snd-usb-audio

snd-usb-audio index=0

This would update snd-usb-audio to card0, in case you want that as the first card.

via Debian User Forums • View topic – ALSA: cannot find card ‘0’.

Why I use Debian and Ubuntu (Apt)

By , 2011-12-21 10:35

OK, rant time.

Way back in the day (I mean 2001 or so), I used to use rpm-based distros. Red Hat, Mandriva – or rather Mandrake- and they worked fine. As long as you didn’t have to install any packages. To be fair, this was in the early days of package managers and the like, and I was a novice Linux user at the time. Mandrake had put in a good effort with urpmi, but I still had to visit sites like http://rpm.pbone.net/ and http://rpmfind.net/ very often to find this or that package.

Then, in 2004/2005, I discovered Ubuntu. (The OS, not the philosophy. Ha ha.) It was a world of difference. Need a program? apt-get install program would automagically fetch and install it for you. Don’t know the name of the package, or exactly what you’re looking for? apt-cache search can help. If that package you want installed has dependencies, and those have dependencies? No problem, everything gets pulled in and the proposed changes are listed for you. The other advantage was that seemingly any program I could possibly want was available in a Debian/Ubuntu repo.

Fast forward to today. I’ve pretty much been using Debian based distros since then, although I have tried Arch and Slax, and possibly many others that I can’t remember right now. All my servers run either Debian or Ubuntu Server, and my Linux PCs are Ubuntu or Arch. Package management has become so easy that I rarely ever have to worry about it, unless I’m trying to make some major changes outside of repo packages.

Recently, however, I’ve started using some RPM distros again, to see how things have been on that side of the fence. It’s been mostly CentOS and a few CentOS/PBX distros (Elastix, Trixbox, pbxinaflash…). I have to say though, I can’t believe the state of the package management system. CentOS has got yum, which seems to be good in principle, but somehow I’ve seen it massively fail in ways that Apt never has for me. The first issue is not really to do with the package manager, but more the repositories.

For example, we had a service on a server at work that absolutely required “Arial”. In Ubuntu or Debian, all you have to do is enable the non-free repo, or an Arch, use one of the excellent AUR frontends such as yaourt. Then install msttcorefonts (Debian) or ttf-ms-fonts (Arch). The package manager will fetch the MS fonts package and its dependency, cabextract. It then downloads each of the fonts’ self-extracting EXEs from sourceforge, cabextracts them, then installs them to the appropriate fonts directory. Now, on the CentOS 5 server, no such luck.

$ yum install msttcorefonts
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.nexicom.net
 * extras: centos.mirror.nexicom.net
 * updates: centos.mirror.nexicom.net
Excluding Packages from CentOS-5 - Addons
Finished
Excluding Packages from CentOS-5 - Base
Finished
Excluding Packages from CentOS-5 - Extras
Finished
Excluding Packages from CentOS-5 - Updates
Finished
Setting up Install Process
No package msttcorefonts available.
Nothing to do
$

Awesome. Time to break out the manual package manager, AKA Google. Which brings me to the corefonts sourceforge project homepage, fortunately with clear instructions on how to install on an rpm-based system.

  1. Make sure you have the following rpm-packages installed from from your favourite distribution. Any version should do.
    • rpm-build
    • wget
    • A package that provides the ttmkfdir utility. For example
      • For Fedora Core and Red Hat Enterprise Linux 4, ttmkfdir
      • For old redhat releases, XFree86-font-utils
      • For mandrake-8.2, freetype-tools
  2. Install the cabextract utility. For users of Fedora Core it is available from extras. Others may want to compile it themselves from source, or download the source rpm from fedora extras and rebuild.
  3. Download the latest msttcorefonts spec file from here
  4. If you haven’t done so already, set up an rpm build environment in your home directory. You can to this by adding the line %_topdir %(echo $HOME)/rpmbuild to your $HOME/.rpmmacros and create the directories $HOME/rpmbuild/BUILD and $HOME/rpmbuild/RPMS/noarch
  5. Build the binary rpm with this command:
    $ rpmbuild -bb msttcorefonts-2.0-1.spec

    This will download the fonts from a Sourcforge mirror (about 8 megs) and repackage them so that they can be easily installed.

  6. Install the newly built rpm using the following command (you will need to be root):
    # rpm -ivh $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm

Sounds like fun. Let’s try and see if we’re lucky.

yum install wget rpm-build cabextract

Cool! rpm-build was installed! but wait, how about wget and cabextract? It didn’t mention those!

wget is probably installed, but let’s try anyway:

$ wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.

OK, how about cabextract?

$ cabextract
sh: cabextract: command not found

Well then, that’s wonderful. Thanks for mentioning that you didn’t install cabextract, yum.

Fortunately the good people at corefonts provided a link to the download for cabextract, and fortunately, my server is i386 (I know it doesn’t seem like it from the screenshot), so I can use the pre-built RPM. (For those who need it, the x86_64 package) Now to the final step.

$ wget -O - http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec | rpm -bb msttcorefonts-2.0-1.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.77304
+ umask 022+ cd /usr/src/redhat/BUILD

[… a hundred or so lines…]

Wrote: /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.22861
+ umask 022
+ cd /usr/src/redhat/BUILD
+ '[' /var/tmp/msttcorefonts-root '!=' / ']'
+ rm -rf /var/tmp/msttcorefonts-root
+ exit 0

Phew, that’s a lot of output. Well exit 0, that’s good. Aaand “Wrote: /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm”. cool!

And finally:

$ rpm -ivh /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm
Preparing...                ########################################### [100%]
   1:msttcorefonts          ########################################### [100%]
$

(Another thing that bugs me – no success message! After all that, not even a Yay! Package installed!? I’m disappointed, rpm.)

For illustrative purposes, Debian:

# apt-get install msttcorefonts
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  cabextract ttf-liberation ttf-mscorefonts-installer
The following NEW packages will be installed:
  cabextract msttcorefonts ttf-liberation ttf-mscorefonts-installer
0 upgraded, 4 newly installed, 0 to remove and 4 not upgraded.
Need to get 1103kB of archives.
After this operation, 2109kB of additional disk space will be used.
Do you want to continue [Y/n]? Y

[…]

All fonts downloaded and installed.
Updating fontconfig cache for /usr/share/fonts/truetype/msttcorefonts
Setting up msttcorefonts (2.7) ...
Setting up ttf-liberation (1.04.93-1) ...
Updating fontconfig cache for /usr/share/fonts/truetype/ttf-liberation

Wasn’t that easier? Also, a nice plain English message saying what was done: “All fonts downloaded and installed.” Take notes, rpm.

For completeness’ sake, Arch:

$ yaourt -S ttf-ms-fonts

==> Downloading ttf-ms-fonts PKGBUILD from AUR...
x PKGBUILD
x ttf-ms-fonts.install
x LICENSE

[…]

==> ttf-ms-fonts dependencies:
 - fontconfig (already installed)
 - xorg-fonts-encodings (already installed)
 - xorg-font-utils (already installed)
 - cabextract (package found)

[…]

Targets (1): ttf-ms-fonts-2.0-8

Total Download Size:    0.00 MB
Total Installed Size:   5.49 MB

Proceed with installation? [Y/n]
(1/1) checking package integrity                                         [########################################] 100%
(1/1) checking for file conflicts                                        [########################################] 100%
(1/1) installing ttf-ms-fonts                                            [########################################] 100%
Updating font cache... done.
$

A bit more user interaction, but that’s the point of Arch.

So, to summarize:

Arch/Debian package management > rpm package management (CentOS).

And that’s the end of my rant for today.

Quick and dirty bash script to apt-get update all OpenVZ containers

By , 2011-11-30 22:29

It’s a bit of a pain having to run upgrades on all servers. I could of course, set up unattended upgrades, but I always liked initiating the upgrade process myself. So I wrote a little bash script that will initiate apt-get update and apt-get upgrade on all running OpenVZ containers.

Note that this only works for Debian-based distros. So Debian, *buntu, Linux Mint and the like.

It’s very rough, no error-handling or safeguards, so use at your own risk. Works for me, but YMMV.

#!/bin/bash
#Delete temp file
rm /tmp/tmp-script.sh
#Get running VZ
CTIDS=$(vzlist | awk '{print $1}' | sed -e '/CTID/d' -e ':a;N;$!ba;s/\n/ /g' )
# Echo list of running IDs
echo "$CTIDS"
CTIDarray=($CTIDS)
for x in ${CTIDarray[@]}
do
    echo "#/bin/bash" > /tmp/tmp-script.sh
    chmod +x /tmp/tmp-script.sh
    echo vzctl exec $x "apt-get update &&;  apt-get -y upgrade" >> /tmp/tmp-script.sh
    screen -d -m /tmp/tmp-script.sh
done
#Delete temp file
rm /tmp/tmp-script.sh
#Show running screens
screen -x

First, we rm the /tmp/tmp-script.sh. Starting off with very bad form, I know, feeling lazy right now. Then I use awk and sed to get the IDs of running containers from the output of the vzlist command, and place them on a single line, separated by spaces. Those IDs are than put in an array, so that the update command can be called using a for loop.

For some reason, I couldn’t get screen to launch the

vzctl exec $x "apt-get update &&  apt-get -y upgrade"

command directly, hence the hideous use of a temp file. If anyone can fix/improve this, I would be glad to hear from you!

MythTV/Proxmox (OpenVZ) multi-role server from hell

By , 2009-09-01 22:35

So… I just spent two hours trying to get MythTV running properly on my OpenVZ server (installed via the Proxmox VE bare-metal installer). This is starting to be a lot harder than I thought it would be…

As seen in my previous post, I installed the 2.6.26-2-openvz-amd64 kernel and headers, and compiled v4l-dvb from mercurial, and fixed a little bug with vzctl. Today, I installed the firmware files for my Hauppage HVR-1600 (see MythTV wiki page), added the Debian-multimedia repo and installed MythTV (apt-get install mythtv). Then I realized I needed X to use mythtv-setup, so for some reason I decided to install KDE 3.5. KDE installed fine (minus some missing files for the kdm theme… wonder why these aren’t included in the kdm package or a dependency…). I then proceeded to create a password for the mythtv user ($passwd mythtv as root) and then run mythtv-setup as the mythtv user. I managed to add the sources and scan for channels, but when I tried to “Watch TV”, I was told that the primary backend wasn’t running.

I tried some troubleshooting, but it’s getting kinda late and I’m lacking sleep (as you can probably tell from my grammar), so I decided to try installing a shiny new Intel Pro 1000 Desktop (82574L) PCIe x1 Ethernet card to get my server some gigabit love. Should be simple, right? Intel cards have good driver support, with the e100 and e1000 drivers, so much so that VM solutions like VMware and VirtualBox chose to emulate them as guest hardware. Well, this was not the case today. I popped the card in to a free PCIe x1 slot and powered on the PC. Link lights went on and all looked fine and dandy. But once the machine fully booted up (takes a while with all those OpenVZ containers 😉 ), ifconfig showed only the eth0 interface, which is my built-in Realtek/nForce controller. Some further probing with lspci and dmesg showed that the card is alive, but that the e1000 driver didn’t even bother to start up.

At this point, I GIVE UP for tonight. I’m cold from sitting down in the basement, tired from lack of sleep, and frustrated from uncooperative Linux servers.

No streaming TV for me tonight, but I suppose I should be glad that at least the blog is still up and running.

Which brings to mind http://xkcd.com/349/

40% of OpenBSD installs lead to shark attacks. It's their only standing security issue.

Upgrading Proxmox VE kernel

By , 2009-08-31 16:19

I currently am running this blog from an OpenVZ server managed via Proxmox VE. One issue I had with this setup is that the Proxmox 1.3 installer by default comes with a relatively old kernel (2.6.24), and I want a newer kernel (>=2.6.26, so that I can use my cx18-based TV tuner). Fortunately, Proxmox is just a customized version of Debian Lenny, so I just installed the linux-image-2.6.26-2-openvz-amd64 package from apt, then ran update-initramfs -u and update-grub.

After updating the kernel, however, I was unable to start any of my virtual machines from the Proxmox Web UI. Looking at the system log showed a message about vzctl being 32-bit; problem solved by updating vzctl via apt.

Now I’m attempting to compile v4l-dvb…. fingers crossed!

hg clone http://linuxtv.org/hg/v4l-dvb

Custom theme by me. Based on Panorama by Themocracy