h1

Linux Configuration In Office Environment

July 2, 2006

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


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.


Command execution at graphical startup

From the 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
                 


Default Runlevel

Default runlevel is set in /etc/inittab

# default runlevel
 
id:2:initdefault:
                 

Meaning of the numbers:

  • 0 –> system halt
  • 1 –> single user mode
  • 2 –> multiuser, without NFS
  • 3 –> full multiuser mode
  • 4 –> unused
  • 5 –> X11
  • 6 –> reboot


Setting up remote logins

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

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

Where options are:

  • -tn xterm – set TERM variable to xterm
  • -cr red – set cursor color “red”
  • -sr – set scrollbar to the right side of the terminal
  • -sl 200 – set scrollbar history to 200 lines


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.


Printing to Windows Print Queue

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

[global]
        workgroup = INTEGRAL
        netbios name = vgrinche-nt
        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:

  • Queue Name: lp
  • Queue Type: Windows Printer SMB
  • Share: //EUCLID/HP8150upstrs
  • User: vgrinche
  • Workgroup: INTEGRAL
  • Printer Driver: HP LaserJet 8150 (postscript driver)
  • Save and restart daemon

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.


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:

  • username=name     This option specifies the username to be used on the server. smbmount sends this name to the Windows server in order to gain access to files. If UNIX username is different from the Windows username, this is the option to use. You can specify user name, password, and Windows workgroup: -o username=VGRINCHE/INTEG%MYSECRET
  • password=passwd     If you don’t include this option with smbmount, the program prompts you for the password.
  • netbiosname=name     This option sets the name by which the client goes when it connects to the server. It defaults to your system’s host name.
  • uid=id     This option sets the apparent owner of the files on the local mounted filesystem. It can be either user name or a number.
  • gid=id      This option sets the apparent group ownership of the mounted files.
  • fmask=mask      This option sets the permissions used for remote files on the share once it is mounted. Typically, it is fmask=640.
  • dmask=mask      Same as above, but for directories.

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
                 


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
                         
  1. Restart xntpd server.

Time will slowly drift and synchronize with the outside servers.


Configuring FTP daemon

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


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.


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
                 


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
                 


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:vgrinche%40integ.com@distro.ibiblio.org
          //pub/linux/distributions/redhat/7.2/en/iso/i386/enigma-i386-disc?.iso
 
wget --glob=on --tries=0  \
   ftp://anonymous:vgrinche%40integ.com@distro.ibiblio.org
         //pub/linux/distributions/redhat/7.2/en/iso/i386/enigma-SRPMS-disc?.iso
                 


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
                 


I have no “core” 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.


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.


Creating GNOME2 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


Switching Between 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 &&
                 

 


Make bigger fonts in Evolution

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
 
                 

3 comments

  1. Usually I do not read article on blogs, however I wish to say that this write-up very compelled me to take a look at
    and do it! Your writing style has been surprised me.
    Thanks, very nice post.


  2. I know this web page provides quality based articles
    and other material, is there any other website which presents these stuff in quality?


  3. Hi, just wanted to mention, I enjoyed this article. It was inspiring.
    Keep on posting!



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: