Linux Configuration Tips

This is the collection of Linux-related tips and tricks, mostly administration and configuration that helps to integrate Linux system into Windows office environment.

Last edited: Jan 19 2007


Contents


To check Hard Drive speed
# /sbin/hdparm -Tt /dev/hdx /dev/hdy 
		  

where 'x' and 'y' (etc.) are the drive letters you wish to test. It will give you a transfer rate readout.

[Up]


Command execution at graphical startup

From the redhat-devel-list mailing list:

I had a little trouble with this myself. I tracked down the (problem??) to /etc/X11/xdm/Xsession. ~/.xsession is supposed to be executed upon startup of X from xdm (or kdm), but it is not unless to choose default. The default option falls through the case statement and then executes ~/.xsession. So just copy /etc/X11/xdm/Xsession to ~/.xsession and edit as necessary, then choose default from the KDM login screen or edit ~/.wmrc and replace text with default. Here is a copy of mine:

#!/bin/sh
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

# User defined key mapping
xmodmap -e "keycode 22 = BackSpace"

# GOLD key
xmodmap -e "keycode 77 = KP_F1"

if [ -f $userresources ]; then
    xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
    xmodmap $usermodmap
fi

# Let everybody have access
xhost+

# start some nice programs
#fvwm
#fvwm2
#enlightenment
exec startkde
		  

[Up]


Default Runlevel

Default runlevel is set in /etc/inittab

# default runlevel

id:2:initdefault:
		  

Meaning of the numbers:

[Up]


Setting up remote logins

Run GNOME Menu Editor and for each category (epoch | skynet | other) add an entry to the App in the GNOME Foot:

rxvt -tn xterm -cr red -fn 10x20 -sr -sl 200 -title "epoch@polonius" -e rlogin -l epoch3 tpepc20
		  

Where options are:

[Up]


Hostname/IP address Resolution with WINS

In /etc/samba/smb.conf file, set:

[global]
   name resolve order = wins lmhosts bcast host
   wins server = 172.16.1.1
   wins proxy = yes
		  

Start your Linuxconf and set your eth0 to use DHCP service. Also make sure samba services are started by bootup procedure. Restart you machine and you should be getting dynamically assigned IP address and your hostname should be resolved by DNS/WINS correctly.

[Up]


Printing to the Windows Print Queue

1. First, SAMBA should be properly configured. In /etc/samba/smb.conf file, set:

[global]
        workgroup = MARYLAND
        netbios name = vlg
        server string = Samba Server
        security = user
        password server = *
        log level = 1
        os level = 1
        dns proxy = No
        encrypt passwords = yes
        smb passwd file = /etc/samba/smbpasswd
        username map = /etc/samba/smbusers

[homes]
        comment = Home Directories
        browseable = no
        writable = yes
        read only = no

[printers]
        comment = All Printers
        security = Server
        path = /var/spool/samba
        browseable = No
        guest ok = no
        printable = Yes
        public = Yes
        create mode = 0700
		  

2. Create a user named vgrinche with linuxconf tool.

3. Create SAMBA password file:

# smbpasswd -a vgrinche
		  

4. Install enscript from RH CD-ROM.

5. Login as root (# su - )

6. Run RH printtool utility and set:

7. Create mount points:

# mkdir /mnt/pascal
# mkdir /mnt/pascal/Epoch
# mkdir /mnt/pascal/V2V3
		  

8. Add mount points to /etc/fstab

//pascal/Epoch/ /mnt/pascal/Epoch  smbfs  username=vgrinche,noauto,ro,user 0 0
//pascal/V2V3/  /mnt/pascal/V2V3   smbfs  username=vgrinche,noauto,ro,user 0 0
		  

Optionally, you can specify password after username as password=PASSWORD

If you don't know the printer's name, or it has been changed, you can always find it out with LinNeighborhood. Browse EUCLID share - all the printers are listed there.

[Up]


Mounting Windows Shares

The two commands mount -t smbfs and smbmount are essentially equivalent with slight but subtle differences. If you use one command to mount a share, you have to use the same command to unmount the share.

Their syntax is almost identical:

smbmount //server/share /mountpoint [-o options]

mount -t smbfs //server/share /mountpoint [-o options]
		  

If you use smbmount, the user who issues the smbmount command must own the mount point. This is true even if you create an /etc/fstab entry to allow users to mount shares. smbmount works better if you want allow individual users to mount remote shares.

Avaliable options:

By default, many Samba installations give the smbmnt program (helper program for smbmount) superuser privileges for execution only. If ordinary user must be able to use these programs, it must be set user ID (suid) root:

$ chmod a+s /usr/bin/smbmnt /usr/bin/smbumount
		  

EXAMPLE:

// Mount 

smbmount //HILBERT/goes /export/home/vlad/Documents/GOES_RPM \
  -o username=VGRINCHE,password=MY_SECRET,uid=vlad,gid=epoch,fmask=666,dmask=777

// Unmount

smbumount /export/home/vlad/Documents/GOES_RPM
		  

[Up]


Configuring Time Feed

Time feed is taken from outside (internet) sources.

  1. Download xntp3.*.rpm package
  2. Edit /etc/ntp.conf configuration file, and add following lines to it:
    server          tick.usno.navy.mil      prefer
    server          tock.usno.navy.mil      prefer
    server          time.nist.gov           prefer
    			  
  3. Restart xntpd server.

Time will slowly drift and synchronize with the outside servers.

[Up]


Configuring FTP daemon

By default, wu-ftpd package is not installed. Also, make sure that ksh is listed in /etc/shells file.

[Up]


Configuring rlogin

To allow logins from one account (vlad) to another (epoch3) on the same machine, change your ~/.rhosts file to look like:

vgrinche-nt vlad
		  

Change permissions of ~/.rhosts to 0400.

By default, ~/.rhosts file is ignored. To enable it, change PAM policy by commenting out line below in the file /etc/pam.d/rlogin

# auth       required    /lib/security/pam_securetty.so
		  

Now, try % rlogin vgrinche-nt -l epoch3 and it should not ask for password.

[Up]


Booting into damaged root filesystem

If LILO's MBR record or any part of your /boot directory is damaged and you can not login into your system anymore, last thing to try is booting with distirbution disk and telling it to mount your root partition as root (/). Pop in your RH cd-rom and type in at Linux: prompt

linux single root=/dev/hda1 initrd=
		  

To repair the installation, boot CD with

linux resque
		  

If the boot message scrolled too fast off the screen, and you haven't had a chance to see the error report, use Shift-Up/Down to scroll up/down the screen.

This is the way to remount various filesystems if you find yourself in "repair" mode and want to change some files:


mount proc /proc -t proc
mount /dev/hda2 / -o remounte,rw
mount /dev/hda1 /boot
		  

[Up]


Mounting /proc failed

Once in a blue moon I get this error message. Some people reported it happening after an upgrade.


Mounting proc filesystem dup2: Bad file descriptor
No such partition found ...
		  

Somehow the effect of the update modifed /dev/null to be a regular file with some sort of message in it ... hence "Bad file descriptor". To fix, login into repair mode, remount root filesystem as read-write, and restore /dev/null:


# mount -n -o remount,rw /
# rm -f /dev/null
# mknod -m 0666 /dev/null c 1 3
		  

[Up]


Downloading RedHat ISO distribution files

Downloads are slow and I might do them in pieces. Therefore, I use wget from GNU. Here is the rough script that does the job. I admit it is not perfect, but is sufficient for now:

wget --glob=on --tries=0  \
   ftp://anonymous:vlg%40zorro.com@distro.ibiblio.org
          //pub/linux/distributions/redhat/7.2/en/iso/i386/enigma-i386-disc?.iso

wget --glob=on --tries=0  \
   ftp://anonymous:vlg%40zorro.com@distro.ibiblio.org
         //pub/linux/distributions/redhat/7.2/en/iso/i386/enigma-SRPMS-disc?.iso
		  

[Up]


Making and using ext2 floppy

First, you format ext2 floppy with:

# su 
# /sbin/fdformat /dev/fd0H1440
# /sbin/mkfs -t ext2 -m 0 /dev/fd0H1440 1440
		  

Then, modify you /etc/fstab floppy entry. This would allow anyone to mount and modify floppy disk.

/dev/fd0 /mnt/floppy auto noauto,users,nosuid,nodev,rw,sync,noexec 0 0
		  

And finally, mount your floppy as user, and then change /mnt/floppy permissions to 0777. Otherwise, /sbin/mount would set directory's permissions to 0755 even if nosuid is specified! /sbin/mount is setuid binary.

# chmod 0777 /mnt/floppy
		  

[Up]


I have no "core" file and I must debug

The ulimit controls the size limit of serveral things in your Linux system, among them, the size of the core file. Issuing a ulimit -c 0 will tell Linux to disable core files. It is set in /etc/profile.

Another possible place for that limit being reinforced is in file /etc/security/limits.com It is a part of PAM system. The "soft" and "hard" refers to the kind of limits imposed.

[Up]


Apache Web Server Setup

Edit the Apache configuration file, /etc/httpd/conf/httpd.conf and add following lines:

<IfModule mod_userdir.c>
    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, use this directive instead of "UserDir disable":
    #
    UserDir public_html

</IfModule>
		  

<Directory "/export/home/vlad/public_html">
        AllowOverride FileInfo AuthConfig Limit
        Options MultiViews Indexes IncludesNoExec FollowSymLinks
        <Limit GET POST OPTIONS PROPFIND>
                Order allow,deny
                Allow from all
        </Limit>
        <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
                Order deny,allow
                Deny from all
        </Limit>
</Directory>
		  

<Files /export/home/vlad/public_html/SelfEmployment/index.html>
        Order allow,deny
        Deny from all
</Files>
		  

Then, restart you web server.

[Up]


Creating GNOME-2.0 Custom Menus

To create a custom menu, first add a directory entry, Logins.directory to ~/.gnome2/vfolders directory. The file should look something like this:

[Desktop Entry]
Name=Logins
Comment=Logins menu
Icon=gnome-util.png
Type=Directory
		  

Each item in the Logins menu is described by .desktop file. For example, a remote login to rpm@rpmdev1 account is described by ~/.gnome2/vfolders/Logins/rpm_rpmdev1.desktop, which looks like this:

[Desktop Entry]
Name=rpm@rpmdev1
Comment=
Exec=rxvt -ls -bg black -fg white -tn xterm -cr red -fn 10x20 -sr -sl 200 -title
         "rpm@rpmdev1" -e rlogin -l rpm rpmdev1
Icon=gnome-terminal.png
Type=Application
X-GNOME-DocPath=gnome-terminal/index.html
Categories=Logins;Utility
Encoding=UTF-8
X-Desktop-File-Install-Version=0.3
OnlyShowIn=GNOME;

		  

Notice the Categories entry. It is set to Logins;Utility. There is a dependency between that and the fact that there is Logins.directory file. This dependency is established by ~/.gnome2/vfolders/applications.vfolder-info file which is a modified copy of the system-wide file by the same name. The modifications add describe a new menu entry, Logins, and add a directory where *.desktop files for that entry can be found, ~/.gnome2/vfolders/Logins.

Here are the relevent modifications:

<VFoldersInfo>
   <MergeDir>/export/home/vlad/.gnome2/vfolders/Logins</MergeDir>
</VFoldersInfo>

<!-- Logins -->
<Folder>
   <Name>Logins</Name>
   <Desktop>Logins.directory</Desktop>
   <Query>
     <And>
       <Keyword>Logins</Keyword>
       <Keyword>Utility</Keyword>
       <Not>
          <Keyword>System</Keyword>
       </Not>
     </And>
   </Query>
   <DontShowIfEmpty/>
</Folder>
		  

System-wide files:

  1. /etc/gnome-vfs-2.0/vfolders/applications.folder-info
  2. /usr/share/gnome/vfolder/*.directory
  3. /usr/share/applications/*.desktop

Useful Links:

  1. Gnome2 Release Notes
  2. Menu Editing Guide
  3. Desktop Entry Standard

[Up]


Switching Window Managers

To switch between WMs, bring up Desktop Preferences->Advanced->Sessions window, find your running WM and change its status from respawn to normal. Then kill it, start another WM and save the session:


killall sawfish && sleep 5 && metacity && gnome-session-save &&
		  

[Up]


Make font size in Evolution bigger

To change the font size used in menus and other app text for non-Gnome apps, edit /etc/X11/fs/config:


// file: /etc/X11/fs/config

// 1. Swhitch order of these 2 lines:

/usr/X11R6/lib/X11/fonts/75dpi:unscaled,
/usr/X11R6/lib/X11/fonts/100dpi:unscaled,

// 2. Change the line:

    default-resolutions = 75,75,100,100
To:

    default-resolutions = 100,100,75,75

		  

[Up]


Allow Remote X Applications Mapping

If you want to remotely map X applications from a remote host to your desktop, you have to open TCP port 6000 for display :0.0. To find out if port 6000 is already open, run nmap command:

$ nmap 192.168.1.3

Interesting ports on 192.168.1.3:

PORT      STATE   SERVICE
22/tcp    open    ssh
443/tcp   open    https

MAC Address: XX:XX:XX:XX:XX:XX (D-link)

Nmap finished: 1 IP address (1 host up) scanned in 20.297 secs

		  

By default, port 6000 is disabled - the X server is started with --nolisten tcp option to disable remote logins.

By default, Fedora Core distributions which use the gdm login manager do not permit TCP connection to the X server. To enable, modify /usr/share/gdm/defaults.conf:

# defaults.conf
...
# If true this will basically append -nolisten tcp to every X command line, a
# good default to have (why is this a "negative" setting? because if it is
# false, you could still not allow it by setting command line of any particular
# server).  It's probably better to ship with this on since most users will not
# need this and it's more of a security risk then anything else.
# Note: Anytime we find a -query or -indirect on the command line we do not add
# a "-nolisten tcp", as then the query just wouldn't work, so this setting only
# affects truly local sessions.

DisallowTCP=false

		  

Close all of your X applications and restart gdm. On Fedora, this might require system reboot.

To check if your changed took effect, look at the Xorg invocation command:

$ ps -deaf | grep Xorg

root 2660 tty7 00:00:17 /usr/bin/Xorg :0 -audit 0 -auth /var/gdm/:0.Xauth -nolisten tcp vt7

		  

You should not see -nolisten tcp option enabled. Now, your xhost +MY_TRUSTED_X_HOST command should work.

[Up]


sendmail: Connection refused by [127.0.0.1]

You are trying to send an e-mail from your cron job, and all you get in the /var/log/mail is:

Dec 22 15:34:11 zorro sendmail[27803]: kBMKYBuF027803: 
            to=vlg[AT]users.sourceforge.net, ctladdr=vlg (4023/4023), 
            delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30178, 
            relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, 
            stat=Deferred: Connection refused by [127.0.0.1]
		  

Most likely, you don't have sendmail running. And as soon as you try to start it, you get this:

$ su
# /sbin/service sendmail start

/etc/mail/sendmail.cf
     cannot open '/etc/mail/local-host-names': Group writable directory

/etc/mail/sendmail.cf: 
     cannot open '/etc/mail/trusted-users': Group writable directory

		  

It appears that sendmail complains about permissions set on / root directory. Double-check that they are set to 755 and try again:

# cd /
# ls -ld

drwxrwxr-x 26 root root 4.0K Dec 21 11:39 ./

# chmod 755 /

# ls -ld

drwxr-xr-x 26 root root 4.0K Dec 21 11:39 ./
		  

Now, you should be able to start sendmail and send your e-mails.

[Up]


cannot execute [Argument list too long]

Try to remove gazillion log files with /bin/rm all at once, and you would get this:

$ rm -f *.log

-ksh: /bin/rm: /bin/rm: cannot execute [Argument list too long]

		  

So, rm utility complains that the system-wide ARG_MAX value that is used to setup an input buffer size to process the entire list will overflow. Good security measure, but, doesn't help you out with the task at hand.

To get around, use a combination of find, UNIX pipe, and xargs utilities. The rewrite of the original command would look something like this:

$ find  . -name '*.log' -print0 | xargs -0 rm -f
		  

find naturally finds the target file names, and feeds them one by one into the unnamed UNIX pipe. The -print0 argument instructs to print the full file name on the standard output which is going to the pine, followed by a null character (instead of the newline character that '-print’uses). When pipe becomes full, find blocks waiting for more space in the pipe to become available.

On the other end of the pipe, xargs command reads the next filename from the pipe, and executes the command specified with the filename parameter as an argument. The -0 argument instructs xargs to input items as terminated by a null character instead of by whitespace, and the quotes and backslash are not special (every character is taken literally).

getconf utility shows the system settings that most UNIX utilities rely on when allocating various resources including the memory buffers (such as ARG_MAX in our case).

$ getconf ARG_MAX

  131072
		  

[Up]


To install legacy NVidia driver

nVidia decided stop supporting certain old drivers. The nVidia card in my aging Dell Inspiron 8100 is NVIDIA GeForce2 MX/MX 400. And, of course, it is not supported. The latest nvidia driver spits out the following message to /var/log/Xorg.0.log log file:

(II) Primary Device is: PCI 01:00:0
(WW) NVIDIA(0): The NVIDIA GeForce2 Go GPU installed in this system is
(WW) NVIDIA(0):     supported through the NVIDIA 1.0-96xx Legacy drivers.
(WW) NVIDIA(0):     Please visit http://www.nvidia.com/object/unix.html for
(WW) NVIDIA(0):     more information.  The 1.0-9746 NVIDIA driver will ignore
(WW) NVIDIA(0):     this GPU.  Continuing probe...
(EE) No devices detected.
		  

As indicated, started with driver 1.0-9746, the card is no longer supported. However, livna repository carries the "legacy" drivers of 1.0-96xx series (1.0-9631 is the latest). You need to uninstall whatever the latest % yum update installed, and install the legacy driver instead:


# yum remove kmod-nvidia xorg-x11-drv-nvidia
# yum install kmod-nvidia-96xx
		  

[Up]


Setup Netgear Wireless Card

I have 108 Mbps Wireless PC WG511T Netgear card. The card has "Atheros Communications, Inc." AR5212 chip in it. The chip is supported by the madwifi driver you can get from Livna:

# yum install kmod-madwifi
		  

Inserting the card in PCMCI slot should load the driver:

PCI: Enabling device 02:00.0 (0000 -> 0002)
ath_pci: cache line size not set; forcing 32
ath0: mac 5.9 phy 4.3 5ghz radio 4.6
ath0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
ath0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
ath0: 802.11 address: 00:03:2f:1e:33:72
ath0: Atheros 5212: mem=0x20000000, irq=3
		  

Go to /etc/sysconfig/networking/devices and create ifcfg-ath0 configuration profile (managed mode, dhcp):

# ifcfg-ath0
DEVICE=ath0
BOOTPROTO=dhcp
ONBOOT=no
DHCP_HOSTNAME=
IPADDR=
DOMAIN=
NETMASK=
HWADDR=
USERCTL=yes
IPV5INIT=no
PEERDNS=yes
TYPE=Wireless
ESSID=Riga
CHANNEL=6
RATE=Auto

IPV6INIT=no
MODE=Master
		  
Also, create the key file, keys-ath0, if you are trying to connect to secure wireless network:
KEY=11122323433409098ADFd
		  

You are done - fire up system-config-network and enable the device.

For adhoc networks, change the MODE=Ad-Hoc in your ifcfg-ath0 file.

A couple of useful commands:


To scan for the networks:

# wlanconfig ath0 list scan

SSID            BSSID              CHAN RATE  S:N   INT CAPS
eddie           00:06:25:e8:3a:05    6   54M 36:0   100 EPs


		  

[Up]


Vladislav Grinchenko