Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

Monday, November 10, 2008

HOWTO: Use dpkg to Install .deb Files.

by Jon on November 27th, 2005

I’ve written about using apt-get to get and install debian packages. However, a recent comment by a reader brought the fact that I hadn’t written anything on what to do with a .deb file that exists on your system already either by download or other media.

Using the apt-get application is the quickest way to find and install debian packages. The installation part is done by an application
named dpkg. Dpkg doesn’t have to be used by apt-get, you can use it manually as well.

From the man dpkg command:

dpkg - a medium-level package manager for Debian

Whatever that means.

In keeping with GNU/Linux system security, only the superuser can use the dpkg application. Dpkg is a typical GNU/Linux application that is controlled by command-line switches. Possibly the most common use of dpkg is to install a local .deb file.

To install a .deb file, become root and use the command:

dpkg -i filename.deb

Dpkg can also be used to:

* dpkg –unpack: unpacks the file but does not install it
* dpkg –configure: presents whatever configuration options are available for the package
* dpkg –remove: removes a package

Some of the package manipulation commands are actually carried out by an application called dpkg-deb. In those cases, dpkg just acts as a front end to dpkg-deb and passes the commands to it.

Dpkg-deb can also be used to manipulate .deb files. Some of the more useful commands of dpkg-deb are:

dpkg-deb –show filename.deb

This will display the information for filename.deb. Normally, this is boring information like the application version (which is normally evident from the filename), but in some cases more interesting and useful information is displayed.

Consult the dpkg man page for information on the more arcane uses for dpkg.

Friday, June 29, 2007

Enabling and disabling services during start up in GNU/Linux

In any Linux distribution, some services are enabled to start at boot up by default. For example, on my machine, I have pcmcia, cron daemon, postfix mail transport agent ... just to name a few, which start during boot up. Usually, it is prudent to disable all services that are not needed as they are potential security risks, and also they unnecessarily waste hardware resources. For example, my machine does not have any pcmcia cards so I can safely disable it. Same is the case with postfix which is also not used.

So how do you disable these services so that they are not started at boot time?

The answer to that depends on the type of Linux distribution you are using. True, many Linux distributions including Ubuntu bundle with them a GUI front end to accomplish the task which makes it easier to enable and disable the system services. But there is no standard GUI utility common across all Linux distributions. And this makes it worth while to learn how to enable and disable the services via the command line.

But one thing is common for all Linux distributions which is that all the start-up scripts are stored in the '/etc/init.d/' directory. So if you want to say, enable apache webserver in different run levels, then you should have a script related to the apache webserver in the /etc/init.d/ directory. It is usually created at the time of installing the software. And in my machine (which runs Ubuntu), it is named apache2. Where as in Red Hat, it is named httpd. Usually, the script will have the same name as the process or daemon.

Here I will explain different ways of enabling and disabling the system services.

1) Red Hat Method

Red Hat and Red Hat based Linux distributions make use of the script called chkconfig to enable and disable the system services running in Linux.

For example, to enable the apache webserver to start in certain run levels, you use the chkconfig script to enable it in the desired run levels as follows:
# chkconfig httpd --add
# chkconfig httpd on --level 2,3,5
This will enable the apache webserver to automatically start in the run levels 2, 3 and 5. You can check this by running the command:
# chkconfig --list httpd
One can also disable the service by using the off flag as shown below:
# chkconfig httpd off
# chkconfig httpd --del
Red Hat also has a useful script called service which can be used to start or stop any service. Taking the previous example, to start apache webserver, you execute the command:
# service httpd start
and to stop the service...
# service httpd stop
The options being start, stop and restart which are self explanatory.

2) Debian Method

Debian Linux has its own script to enable and disable services across runlevels. It is called update-rc.d. Going by the above example, you can enable apache webserver as follows
# update-rc.d apache2 defaults
... this will enable the apache webserver to start in the default run levels of 2,3,4 and 5. Of course, you can do it explicitly by giving the run levels instead of the "defaults" keyword as follows:
# update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .
The above command modifies the sym-links in the respective /etc/rcX.d directories to start or stop the service in the destined runlevels. Here X stands for a value of 0 to 6 depending on the runlevel. One thing to note here is the dot (.) which is used to terminate the set which is important. Also 20 and 80 are the sequence codes which decides in what order of precedence the scripts in the /etc/init.d/ directory should be started or stopped.

And to disable the service in all the run levels, you execute the command:
# update-rc.d -f apache2 remove
Here -f option which stands for force is mandatory.

But if you want to enable the service only in runlevel 5, you do this instead:
# update-rc.d apache2  start 20 5 . stop 80 0 1 2 3 4 6 .
3) Gentoo Method
Gentoo also uses a script to enable or disable services during boot-up. The name of the script is rc-update . Gentoo has three default runlevels. Them being: boot, default and nonetwork. Suppose I want to add the apache webserver to start in the default runlevel, then I run the command:
# rc-update add apache2 default
... and to remove the webserver, it is as simple as :
# rc-update del apache2
To see all the running applications at your runlevel and their status, similar to what is achieved by chkconfig --list, you use the rc-status command.
# rc-status --all
4) The old fashioned way
I remember the first time I started using Linux, there were no such scripts to aid the user in enabling or disabling the services during start-up. You did it the old fashioned way which was creating or deleting symbolic links in the respective /etc/rcX.d/ directories. Here X in rcX.d is a number which stands for the runlevel. There can be two kinds of symbolic links in the /etc/rcX.d/ directories. One starts with the character 'S' followed by a number between 0 and 99 to denote the priority, followed by the name of the service you want to enable. The second kind of symlink has a name which starts with a 'K' followed by a number and then the name of the service you want to disable. So in any runlevel, at any given time, for each service, there should be only one symlink of the 'S' or 'K' variety but not both.

So taking the above example, suppose I want to enable apache webserver in the runlevel 5 but want to disable it in all other runlevels, I do the following:

First to enable the service for run level 5, I move into /etc/rc5.d/ directory and create a symlink to the apache service script residing in the /etc/init.d/ directory as follows:
# cd /etc/rc5.d/
# ln -s /etc/init.d/apache2 S20apache2
This creates a symbolic link in the /etc/rc5.d/ directory which the system interprets as - start (S) the apache service before all the services which have a priority number greater than 20.

If you do a long listing of the directory /etc/rc5.d in your system, you can find a lot of symlinks similar to the one below.
lrwxrwxrwx  1 root root 17 Mar 31 13:02 S20apache2 -> ../init.d/apache2
Now if I start a service, I will want to stop the service while rebooting or while moving to single user mode and so on. So in those run levels I have to create the symlinks starting with character 'K'. So going back to the apache2 service example, if I want to automatically stop the service when the system goes into runlevel 0, 1 or 6, I will have to create the symlinks as follows in the /etc/rc0.d, /etc/rc1.d/, /etc/rc6.d/ directories.
# ln -s /etc/init.d/apache2 K80apache2
One interesting aspect here is the priority. Lower the number, the higher is the priority. So since the starting priority of apache2 is 20 - that is apache starts way ahead of other services during startup, we give it a stopping priority of 80. There is no hard and fast rule for this but usually, you follow the formula as follows:

If you have 'N' as the priority number for starting a service, you use the number (100-N) for the stopping priority number and vice versa.

(link to original post)

Wednesday, January 24, 2007

Linux on a Lenovo T60

(Link to webpage)

So, work is letting me use a Lenovo T60. I put Gentoo GNU/Linux (2006.0) on it and decided to create a small page detailing the results.

If you're planning on using Debian External Content on model 2007-63g, I highly recommend Marco Kraus' installation guide External Content .

Specifications
  • Make/Model: Lenovo T60 (Model 2008-CTO)
  • Processor: Intel Core Duo (Centrino Duo) T2400 @ 1.83GHz, 2048 KiB L2 Cache
  • Graphics: ATI X1400 w/64MiB DDR-1 Video RAM
  • Memory: 1024MB
  • Storage: Hitachi 60GB 5400RPM SATA Disk Drive
  • Optical Drive: CDRW/DVD Drive (HL-DT-STCD-RW/DVD DRI)
  • Audio: Intel HD Audio Chipset
  • Wireless Networking: Intel PRO/Wireless 3945ABG
  • Wired Networking: Intel 82573L Gigabit Ethernet
  • Peripheral Networking: Bluetooth

All the goodies (lspci, dmesg, etc.) can be found here.

Hardware Table

Here's a list of the hardware in the laptop:

Component Model Status/Support Notes
Processor(s) Intel Core Duo (Centrino Duo) T2400 @ 1.83GHz, 2048 KiB L2 Cache Excellent Add CONFIG_X86_SMP and CONFIG_MTRR to your kernel, and you should be fine.
Memory 1024MB DDR2 Excellent Add CONFIG_HIGHMEM to your kernel config, otherwise you'll be capped at 896MB.
Graphics ATI X1400, 64MiB DDR-1 RAM Fair Well, this works fine with the VESA driver. However, ATI has some binary drivers External Content that seem to do the trick, too. Xvideo only started working in the 8.26.18 release, though.
IDE Controller Intel 82801GBM/GHM SATA Controller Excellent Works fine. Add CONFIG_SCSI_SATA, CONFIG_SCSI_SATA_AHCI, and CONFIG_SCSI_ATA_PIIX to your kernel. Probably beats the heck out of the Silicon Image junk in my Athlon64 box ...
Hard Disk Hitachi 60GB 5400RPM SATA Disk Drive Excellent Just.. works, like it should.
Optical Drive H-L Data Storage (Hitachi-LG) CD-RW/DVD GCC-4246N Bad libata.atapi_enabled still seems to have problems with AHCI, so disable it in the BIOS if you want to use the drive. Anyway, I burned an ISO image of the T60 BIOS, and the drive does work fine.
Audio Intel HD Audio Chipset Good Works fine w/ALSA. Use CONFIG_SND_HDA_INTEL in the kernel, and remember to run alsaconf, otherwise you won't get any sound. Use the PCM and Front volume controls to tweak the sound. I don't know what the Headphone volume control does, because it certainly doesn't modify the headphone output.
Wireless Networking Intel PRO/Wireless 8945ABG (802.11a/b/g) Fair Well, it works (tried w/802.11a), but Intel External Content needs to be whipped for requiring a binary-only regulatory daemon in addition to the binary-only firmware. The Gentoo package is somewhat brain-dead, too, since it requires net-wireless/ieee80211, which doesn't work if CONFIG_IEEE80211 is enabled. If you end up going this route, you'll have to disable CONFIG_IPW2100, CONFIG_IPW2200, CONFIG_PRISM54, and CONFIG_HOSTAP, since they require CONFIG_IEEE80211. (I suggest unpacking this in your home directory, and then just run ./load and ./unload manually)
Wired Networking Intel 82573L Gigabit Ethernet Good Works fine, enable CONFIG_E1000. The firmware on this seems to be buggy or something, because if I do a warm boot without a link (eg, no cable plugged in), I get "e1000_probe: The EEPROM Checksum Is Not Valid" when the e1000 module is loaded. This works on a cold boot, and when a cable is plugged in during a warm boot. Huh?
Peripheral Networking Broadcom BCM2045B Bluetooth 2.0 Receiver Excellent Works well w/my Logitech MX900 mouse. I suggest modularizing most (or all) of the Bluetooth options in the kernel, and emerging bluez-utils. Then, configure hidd to run at startup in /etc/conf.d/bluetooth, and rc-update -a bluetooth default. Gentoo's net.ppp scripts make jumping on the Internet via Bluetooth DUN a walk in the park.
Log

[Update 20060729] Updated most of the old stuff on the page. The kernel timing issue is in fact fixed in the released 2.6.17 kernel, and in distribution specific kernels, like Ubuntu External Content 's 2.6.15-26 patch. You don't need to do any hacking for ATI's drivers anymore, they build fine against 2.6.17 kernels.

[Update 20060422] I just realized that the optical drive hasn't ever worked. Correction, it hasn't ever been able to read media. I burned an ISO just fine w/cdrecord, since it uses its own SCSI library. Apparently with AHCI enabled, libata.atapi_enabled=1 does nothing, and there is no way of accessing this drive via /dev. So, disable AHCI to use your optical drive =(

[Update 20060418] There's an official (erm, hard-masked) ebuild for the 8.24.8 drivers, now. You still need to hack your kernel and change that line in firegl_public.c, though :)

[Update 20060417] I got the ATI video drivers to work, today. First, I hacked my kernel via the following:

  • Adding intermodule.o to the obj-y list in kernel/Makefile
  • Adding CONFIG_OBSOLETE_INTERMODULE=y to the end of my .config

That adds (yes, you can guess it) obselete inter_module functions to the kernel, since ATI's drivers are brain-dead and use them. Now, get an unofficial Gentoo ebuild from from this post External Content . Grab ati-driver-installer-8.24.8-x86.run and ati-driver-installer-8.24.8-x86_64.run from ATI External Content , and place them in /usr/portage/distfiles. Place the ebuild in /usr/portage/x11-drivers/ati-drivers (YES, this is bad, I know I should use PORTAGE_OVERLAY, but hopefully we'll see an official driver, soon, and won't have to worry) and run "ebuild ati-drivers-8.24.8.ebuild digest" to generate a digest. Next, go ahead and compile it, but interrupt the build right after it starts building the DRM module, and edit /var/tmp/portage/ati-drivers-8.24.8/work/common/lib/modules/fglrx/build_mod/firegl_public.c. Change MODULE_PARAM(firegl, "s"); to module_param(firegl, charp, 0);, then continue the build. If it works, awesome, if not - please wait for an official ebuild. Grab my dual-head xorg.conf below, if you want an example.

[Update 20060415] The first big problem I hit was a timer/clock issue, starting with a 2.6.15-gentoo-r1 kernel. Networking was just dog slow, and the system was dropping packets to hosts on the local LAN, along with some really weird latency. According to the kernel printk timestamps, only 30 seconds had gone by, when the system had been up for over 4 minutes. Also, not a good sign when keyboard repeat rate slows down and speeds up when you're just holding down a key.

The initial fix for this was to disable ACPI. Unfortunately, doing so prevented the SATA contoller to be detected. Disabling AHCI in the BIOS fixed this. However, the Intel audio module wouldn't load, and the Intel NIC didn't feel like transmitting or receiving any frames.

So, I jumped on the bleeding edge and got 2.6.17-rc1, then patched to -git9. I also set the timer frequency to 1000Hz (shouldn't have to do this, since 250Hz works perfectly on my IBM T42). I also made sure to enable the following:

CONFIG_IRQBALANCE=y
CONFIG_REGPARM=y

Maybe it was a combination of a couple things, but stuff started working. Every once and awhile I notice a small jitter here and there, which I don't think is normal, but the system feels much better, and SSH sessions are usable. wmnd External Content doesn't seem too happy, but I don't care right now. Grab my kernel .config here.

Sunday, September 17, 2006

Gentoo in the server room?

Link

When people think of Gentoo Linux, they usually associate it solely with Linux gurus who love to tinker with their operating system -- strictly on a desktop level, of course. But while it may be a challenging distraction for home users, Gentoo Linux is increasingly being used on Web servers -- a task traditionally relegated to BSD variants (FreeBSD, primarily) and commercial GNU/Linux distributions (Red Hat, primarily) as well as Windows. Is Gentoo truly ready for "real" work? Is it just some silly distraction for programmers, or can you really use this source-based operating system to your advantage in a production environment?

Before the hosting service company offered Gentoo-based servers for their various hosting services, FreeBSD was the operating system of choice for most of Tek Alchemy's customers. Nowadays most customers request Gentoo Linux on the machines they're paying to use. "Gentoo is a really nice distro," said Dave Thomas, a senior engineer with the company. "It's easy to work with and we can do a custom install with no XFree86 or other stuff that we don't need or want on the system." But you can get a similarly configured FreeBSD system up in less time and with reportedly greater reliability. What is it about Gentoo that people value in a Web server?

It may seem crude to ask that question, because by itself Gentoo Linux is one of the most advanced GNU/Linux distributions available. The Portage software management system delivers a great deal of power and convenience for administrators who need to keep software up-to-date for security reasons. A simple cron job can download and install updates for the base distribution plus whatever else you have installed. In many ways Gentoo is a lot like FreeBSD; the installation, configuration, and maintenance are very similar in practice. Also like FreeBSD, Gentoo doesn't have any fancy administration tools that would make it competitive with commercial distributions from Sun, Novell, Red Hat, and others. But there is a difference between a machine that hosts Apache, MySQL, and Sendmail on a rented server and a machine that runs local network services like NFS, NIS, and DHCP for the network that runs the business. Usually you'll find Red Hat or some other corporate-supported commercial distribution in the back room or on the sysadmin's desk, not a community-based distro. Gentoo makes a good rented server because of its speed and flexibility, but can it handle back room servers that enable the same hosting companies to make money off of their rented servers?

Gentoo as a production server

One company that eats its own dog food is Seven L Networks. It uses Gentoo Linux on almost all of its back room production servers as well as most of the hosting and dedicated servers that it rents out. It runs its mail services and its own company Web site, and stores all of its data backups on Gentoo-based computers. The only critical system that does not run Gentoo is the firewall, which is graced by the legendary OpenBSD.

"Todd Berman of the Mono project helped us out when we started up, and served as our sort of CTO," said Daniel Lang, a Seven L representative. "Todd pushed us to use Gentoo; he was really excited about its customizability and flexibility."

Lang also added that Seven L -- like Tek Alchemy -- has an excellent working relationship with the Gentoo project. "One of the things I like about Gentoo is the community. There's always lots of help available, and you're not afraid to ask questions, unlike some other distros."

Daniel went on to say that using Gentoo on the customer servers is a mixed experience; while it's easy to use and maintain, and the customers who prefer Gentoo are generally more knowledgable, it does take a long time to install. Seven L engineers will do a stage 2 Gentoo install -- meaning GCC, GlibC, and other necessary programs for bootstrapping are precompiled, but the base system is not -- and then use custom precompiled binaries for some of the programs that take a particularly long time to build from source. While Seven L currently uses the 2004.1 edition of Gentoo, it plans to switch to the new 2004.2 release soon. This is not much of an issue because starting from a stage 2 tarball and then updating the source code before compiling the system means that you're getting the latest edition of Gentoo Linux one way or the other.

The underestimated distro?

With operating systems -- especially GNU/Linux distributions -- the key to trouble-free operation is choosing the right tool for the right job. Gentoo can be made into several different tools; it can be a competent and speedy desktop system, it can be used to host chroot jails, or as a Web or email server. It can securely and safely store critical data backups, or host NFS directories.

What makes Gentoo Linux stand above other distros is not just its flexibility -- Slackware and Debian are just as flexible -- but its customizability. Whereas with Debian's stable distribution you're left using software that is months or years old (including the kernel), Gentoo uses the latest tested editions of the Linux kernel, the GNU project's userland utilities and compiler, and the more than 7,000 ported programs in Portage. Slackware, although just as moldable as Gentoo and Debian, does not have an automatically updatable package management system and compiles nothing from source by default.

Gentoo is not a hacker's toy; it is a professional's tool. Let's hear from some people who use Gentoo in production environments -- we already know it makes a good custom desktop. What else do you use Gentoo for?

Jem Matzan is the author of three books, a freelance journalist and the editor-in-chief of The Jem Report.