Linux Notes

To find out what version of a distro you're running, do

cat /etc/redhat-release
cat /etc/fedora-release
cat debian_version

Table of Contents

HOWTOs and other docs

Red Hat comes with some documentation in /usr/share/doc. HOWTOs are maintained by the Linux Documentation Project. I downloaded their single-page set (each HOWTO is a single web page) and stored them here.

TO DO


Upgrading the BIOS in the laptop

Web to http://www.hp.com/cposupport/swindexes/hppavilion9472_swen.html and follw the directions.


Installing Linux

Pre-partitioning the disk
Linux distributions come ready to install into a computer, but not ready to install into a dual-boot configuration. When Linux distribution documentation discusses partitioning, it usually discusses how to make multiple partitions for use by Linux, and skips over how to partition an existing Windows disk into two partitions. You need to partition your existing disk, containing Windows, before you can start the installation of Linux.

To do this, you first "defragment" your Windows data, which compresses it into the beginning of the existing Windows partition. Then you use FIPS or PartitionMagic to change the end-of-partition marker, effectively creating two partitions on the disk drive. Then you install Linux into the second partition, perhaps with multiple Linux partitions in the second partition.

Using FIPS to partition a disk
Using PartitionMagic to partition a disk


Cleaning up startup

On ibex, I did the following to get rid of red "FAILURE" messages during startup
chkconfig smartd off
chkconfig sendmail off

Shutting down a Linux system

To shut down now, I just do "halt" or "reboot". To shut down in the future, use the "shutdown" command. To do it today at 11:00pm, use "shutdown -h 23:00". For example, to shut down nagman tomorrow morning at 5:45, I used
nagman# at 5:45am tomorrow
warning: commands will be executed using /bin/sh
at> /sbin/shutdown -h now
at> 
job 1 at 2005-10-08 05:45
nagman# atq
1       2005-10-08 05:45 a root
nagman# 
	

Set the time

PCs have a hardware clock and a software clock. The hardware clock is powered by a battery. The software clock is not, and is explicitly set by the operating system at boot time.

You set the hardware clock using the BIOS or from inside an OS. There are two basic times you might want to set the clock to: to GMT or local time.

If the hardware clock is set to Greenwich Mean Time or GMT, then when the OS sets the software clock, it adds an offset to make the current time displayed by the system be correct. Thus, the hardware clock is different than the software clock.

If the hardware clock is set to the current local time, then when the OS sets the software clock, no offset is added.

It's natural to set the hardware clock to GMT and let the OS supply an offset at boot time. Once again, we can thank Microsoft for screwing this up: Windows 2000 requires the hardware clock to be set to local time. Since the hardware clock is a shared resource used by both Windows 2000 and Linux on the laptop, we have to configure Linux to behave with a hardware clock set to local time.

To tell Linux that the hardware clock is local time instead of GMT, use the timeconfig tool. Hit the space bar until the "Hardware clock set to GMT" field is a space (unset) and not an asterisk (true). Set the zone to "US/Mountain". FYI, timeconfig just edits /etc/sysconfig/clock.


Set up system startup variables

As root, edit the /etc/rc.config file. Set the following values:

We always use DHCP to set up networking - see DHCP configuration under SUSE Linux. The dhcpcd daemon will edit the /etc/resolv.conf file as needed, so we don't need the SuSE startup code to mess with it. With CREATE_RESOLVCONF set to "no", the NAMESERVER and SEARCHLIST parameters have no meaning, so set them to "" to avoid confusion. If you don't set SMTP to yes, you get "post: problem initializing server: [BHST] No server" when you try to send mail.

When you set the above variables, they don't necessarily propagate where they need to. For instance, setting FROM_HEADER in the rc.config file has no effect until SuSECOnfig is run. SuSEConfig uses the value to edit the sendmail.cf file. I don't know how to run SuSEConfig directly, but I know that if I use YAST to delete a package, YAST will run SuSEConfig before it exits. So whenever you edit the rc.config file, run YAST to make SuSEConfdig run, then reboot. Some variables to possibly set in rc.config, via YAST:

INITRD_MODULES="usbcore"  ???
NETCONFIG="_0" (we have just the 3com dock card)
START_USB="yes" ???
ntop?
START_FBB="no"  ???
CREATE_RPLAY_CONF="yes"   ???
    

Set the /etc/hosts file and hostname

If you don't explicitly set the system's "hostname", it defaults to localhost.localdomain or linux. This isn't real useful, because a unique hostname is needed for things like conditional shell or emacs startup files. The hostname should relate to the system's DNS name, if possible.

Under Red Hat Linux, edit the /etc/sysconfig/network file. Change localhost.localdomain to, like, "ibex". Don't put in the domain part. If you do only this, GNOME will complain when it starts, so you have to edit the /etc/hosts file to add a line like

128.117.11.101 ibex.ucar.edu
So I don't understand what a machine's hostname is when it's not connected to a network and therefore doesn't have an IP address.

On my home RedHat system, this is hard, because I get a different IP address from NCAR's terminal server every time I dial in. So set the hostname to, I dunno, peteshome.

emacs /etc/sysconfig/network
HOSTNAME=peteshome

On the laptop, the host name was be set up when you set the FQHOSTNAME parameter in the /etc/rc.config file. See Set up system startup variables section of this page.


Set up DNS

The laptop learns DNS servers via DHCP. The dhcpcd client program edits the /etc/resolv.conf file, but it usually puts in a partial DNS search path, and it doesn't put in a domain name at all. To fix this, I wrote a Perl script named /root/fixresolv.pl that is meant to be run after the dhcpcd program. To run it, I made /etc/rc.local contain

. /usr/local/bin/getscheme.sh
getscheme

if [[ ${SCHEME} = 'home' || ${SCHEME} = 'work' || ${SCHEME} = 'ucarnet' ]]; then
/root/fixresolv.pl
fi
Note: if Netscape has trouble resolving "linux.local" or "localhost", the problem is probably due to a dead Apache web server, not a name resolving problem.

Note also that the "host" command uses DNS, just like the "nslookup" command. There doesn't seem to be a command-line program that does a "gethostbyname" call, so it's not obvious how to be sure that the /etc/hosts file is being accessed before DNS. One way to do it is to run strace on your program and look for it trying to open /etc/hosts. Sigh.

The home system connects through the ISDN router, so it can't learn DNS servers, so I have to configure DNS servers explicitly. Put the following in the /etc/resolv.conf file:

domain ucar.edu
nameserver 128.117.64.250
nameserver 128.117.8.94
search ucar.edu scd.ucar.edu

Set up user accounts


Set up sudo

To execute commands as root, use the sudo command. On Ubuntu systems, there isn't even a root account, so you have to use sudo. For sudo to work for a user, the user has to be in the admin group. For finer granularity of protection, see "man sudoers" and then as root, use visudo to edit the /etc/sudoers file. Add this line to the end of the file:
siemsen ALL = NOPASSWD: ALL
Do man 5 sudoers for more info.

Turn off locate/find annoyance

As a convenience, the "locate" command can be used to find files fast. The locate command depends on a database, which is updated periodically. It's updateb by a cron job defined in /etc/cron.daily (which is run because it's referenced in /etc/crontab). It's very annoying, as the cron jobs scans the entire disk, making noise and slowing things down.

I rarely use locate. By default, my Red Hat system runs updatedb daily. To make it run much more rarely, I did

as root
mv /etc/cron.daily/slocate.cron /etc/cron.monthly
To turn the feature off competely under SUSE, set the RUN_UPDATEDB parameter in the /etc/rc.config file. See Set up system startup variables section. When RUN_UPDATEDB is set to "no", the /etc/cron.daily/aaa_base_updatedb script, which runs daily, will skip updating the database.

LCD brightness

The Sony VAIO will dim the LCD screen when the battery power drops below a certain level, and leave it dim. To fix it in Linux, do:
setbrightness 255
To make this be locked in all the time, add the line to the end of /etc/rc.d/emperor.

Booting into Windows will reset the brightness to the highest value.


Floppy

To mount a floppy, use, like,

sudo mount /dev/fd0 /mnt
cd /mnt
sudo umount /mnt


Windows 2000 partition

Per the /etc/fstab file, for Linux to access the Windows 2000 partition, it has to be a FAT32 partition. Do this:

mount /win
umount /win


home desktop

I have an HP DeskJet 712C. It's a "PPA" printer, as described at http://www.httptech.com/ppa. A driver for the printer is available there. I downloaded ppa-0.8.6.tar.gz. When gunzip'd and untar'd, this creates a directory named pbm2ppa-0.8.6, which is a little confusing. Anyway...
cd /usr/src/pbm2ppa-0.8.6
make 720
cp pbm2ppa /usr/local/bin
cp pbmtpg /usr/local/bin
Then, as described in the README.REDHAT file, edit the file named /usr/lib/rhs/rhs-printfilters/printerdb and add the following block of text:
StartEntry: DeskJet720C
GSDriver: pbm
Description: {HP DeskJet 720C}
About: { \
This driver supports the HP DeskJet 720C inkjet printer. \
It does does not support color printing. \
IMPORTANT! Insert \
"- | pbm2ppa -" \
in the "Extra GS Otions" field.\
}
Resolution: {600} {600} {}
EndEntry
Then run printtool, select Add, select Select, select HP DeskJet 720C, and as described in the README.REDHAT file, in the Extra GS Options field, put this:
- | pbm2ppa -
then select OK to exit printool. The result of all this is that printtool has edited the /etc/printcap file to define a printer named lp0.

As root, print a calibration page with

pbmtpg | pbm2ppa > /dev/lp0
The result should be a grid, as explained in the file named /usr/local/pbm2ppa-0.8.6/CALIBRATION. Then, as explained in the INSTALL-MORE file, set up the rest of the mess. First, set up a script to print PostScript files:
cat >/usr/local/bin/print
#!/bin/sh
cat $1 | \
gs -sDEVICE=pbmraw -q -dNOPAUSE -r600 -sOutputFile=- - | \
/usr/local/bin/pbm2ppa - - >/dev/lp0
^D
chmod 755 print
Then, set up a similar script to print text files:
cat >/usr/local/bin/printascii
#!/bin/sh
enscript -p- $1 | \
gs -sDEVICE=pbmraw -q -dNOPAUSE -r600 -sOutputFile=- - | \
/usr/local/bin/pbm2ppa - - >/dev/lp0
^D
chmod 755 printascii
This is fine, but doesn't allow "standard" printing using the lpr command. This means, for instance, that Netscape won't know how to print to the printer. To print from Netscape, tell Netscape to use the new print script that you just created. Don't follow the last set of instructions in the INSTALL-MORE file, because that'll do stuff that's incompatible with printtool. I tried and failed.


Configure the Web

Do the following to allow siemsen to edit the local Web directory:
cd /home chown -R siemsen * chgrp -R datacomm *

Services

For security turn off services that I'll never use. Edit /etc/inetd.conf. Comment out the lines for telnet, gopher, shell, login, pop-2, pop-3, imap, finger, time, and auth.


KDE

Go to the KDE home page. If you click on
  1. Download
  2. stable
  3. latest
  4. distribution
  5. rpm
  6. RedHat
  7. Official-RH-6.x
  8. i386
You'll find links to the pieces of KDE. They each have to be downloaded individually. That's a pain through NCAR's firewalls, but...

cd /usr/src
mkdir KDE
cd KDE
ftp gate.ucar.edu
anonymous@ftp.varesearch.com
Pete Siemsen
cd pub/mirrors/kde/stable/latest
cd distribution/rpm/RedHat/Official-RH-6.x/i386
* get aktion-0.3.6-3.i386.rpm
* get kdeadmin-1.1.2-3.i386.rpm
* get kdebase-1.1.2-11.i386.rpm
* get kdebase-lowcolor-icons-1.1.2-11.i386.rpm
* get kdegames-1.1.2-2.i386.rpm
* get kdegraphics-1.1.2-2.i386.rpm
get kdelibs-1.1.2-9.i386.rpm
get kdelibs-devel-1.1.2-9.i386.rpm
get kdemultimedia-1.1.2-3.i386.rpm
get kdenetwork-1.1.2-4.i386.rpm
get kdesupport-1.1.2-3.i386.rpm
get kdetoys-1.1.2-2.i386.rpm
get kdeutils-1.1.2-2.i386.rpm
get kdpms-0.2.7-6.i386.rpm
get korganizer-1.1.1-2.i386.rpm
get kpilot-3.1b9-3.i386.rpm
get kpppload-1.04-6.i386.rpm
get qt1x-1.44-4.i386.rpm
get qt1x-devel-1.44-4.i386.rpm
quit

scotty

Scotty is a network management system. See the Scotty/tkined home page.
cd /usr/src
gunzip scotty-2.1.10.tar.gz
tar xf scotty-2.1.10.tar
rm scotty-2.1.10.tar
cd scotty-2.1.10
From the README file, you'll find that scotty requires at least Tcl8.0.3 and Tk8.0.3. To find out what version of Tcl you have installed, use
rpm -q tcl
Next,
cd unix
./configure
make
make install
make sinstall
chmod +x /usr/src/scotty-2.1.10/unix/tkined
/usr/lib/tnm2.1.10 and /usr/lib/tkined1.4.10 and /usr/bin.

Now that this is finished, you'd expect the scotty and tkined binaries to be in some usual place. They aren't. Instead they're in /usr/src/scotty-2.1.10/unix/scotty and /usr/src/scotty-2.1.10/unix/tkined. Strange.

Log in as a normal user to run them. A tutorial for getting started with tkined is available from the tkined main page. A PostScript version of a paper describing all of Scotty is also available.


GxSNMP

Web to the GxSNMP home page.

bash

Under Linux, bash is the default shell, so I created a .bashrc from the existing .kshrc. Root's .bashrc gets executed when a user does a "su", so I can have a single shared .bashrc on all systems, used my siemsen and root accounts.

Modify the .bashrc to make it convenient to halt or reboot even if you're not root.

chmod a+s /sbin/halt /sbin/reboot
(in .bashrc)
alias halt='/sbin/halt'
alias reboot='/sbin/reboot'

GNOME or KDE

By default, Red Hat Linuxes use GNOME. To change to KDE, edit /etc/sysconfig/desktop and set DESKTOP to "KDE".

As of April 2004, I use KDE. See my KDE page for more info.

I used GNOME for years. When I upgraded from Red Hat 7.3 to Red Hat Fedora Core 1 in 2004, GNOME was upgraded to 2.4. Amazingly, it became less useful. For instance, the menu editor disappeared. Google searches turned up only piss-poor documentation for the new manually-edit-files method for making menus. Also, GNOME people4b apparently began pretending that window managers don't exist, maybe to be more friendly to computer illiterates. GNOME 2.4 came with a built-in window manager named "metacity", but it wasn't documented as far as I could tell. Metacity was much less capable than sawfish. For instance, there seems to be no way to make windows pop to the top by clicking mouse button 1 on the window. These changes happened with the standard lack of decent documentation that GNOME has always had. I decided to see if KDE is less unfriendly.

What do you know - KDE behaves almost as I like by default. Focus follows mouse, button 1 pops windows to the top, and there's a menu editor available by right-clicking on the "start" button. I made the switch from GNOME to KDE, but I forgot how. It seems that I should run "switchdesk kde", but my brad-new Fedora Core 2 distro says KDE isn't installed, even though the release notes say it is.


cron

Make it stop running daily "find" jobs that look for and delete core files.

mv /etc/cron.daily/aaa_base_clean_core /etc/cron.monthly

rpms (NCAR/SCD repository)

I periodically run the Red Hat Update Agent to update my software. It doesn't do everything. Greg Woods maintains a repository of up-to-date RPMs on fileserver. To use it, do

service portmap start
service iptables stop
mount linstall.ucar.edu:/install2 /mnt
cd /mnt/rhfc1/Fedora/RPMS
rpm -Fvh *.rpm
umount /mnt
service portmap stop
service iptables start

Increase maximal mount count

Whenever you boot, the kernel checks how many times each disk has been mounted. If it has been mounted more than some threshold valu (20 by default) then the disk gets fsck'd. The default is too low for system like mine that often get booted 2 times a day. I asked the folks at EmperorLinux how to change it. as a result, I did
as root tune2fs -c 51 /dev/hda7 tune2fs -c 53 /dev/hda1