Contact

Bret M. Webb, Ph.D., P.E., D.CE
Professor
University of South Alabama
150 Jaguar Drive, SH3142
Mobile, AL 36688 USA
Phone: (251) 460-6174
Fax: (251) 461-1400
Email: bwebb@southalabama.edu

Research Positions

None available at this time

Current Research Assistants

SE Students
Garland Pennison

 

MSCE Students
Patrick Hautau
Marshall Hayden
Kate Haynes
Justin Lowlavar
Vijaya Satya Lohitha Mukkamala
Jackie Wittmann

 

Undergraduate Students
Derek Kelly
Rh'Monte Wilson

Former Students

MSCE Students
Bryan Groza (2016)
Kari Servold (2015)
Chris Marr (2013)
Richard Allen (2013)
Miyuki Matthews (2012)

 

Post Docs
Jon Risinger
Jungwoo Lee

Follow Me

Live Site Traffic

Archives

This is a collection of Linux/Unix tips that I have compiled over the past five years or so. Some of these tips were provided by Brian Barr, whom also provided the motivation for maintaining such a page for our CFD group, friends, and strangers alike. Please understand that all of the information contained in these tips may or may not be suitable for your specific system. Be sure to substitute your specific system information where appropriate.


Mounting a Linux LVM volume

Linux LVM partitions do not mount the same way as the ext2 and ext3 partitions that you may be used to. Consider the following example from a dual boot (Windows XP + CentOS) machine.

Aspell doesn’t work in my terminal

I suppose there is a compatibility issue between aspell and the gnome-terminal. I don’t know exactly what is wrong, but there is an easy way to get past it. Open up xterm (by typing xterm at the CLI) and use aspell in there. That’s it.

Here and There… A useful trick

For all of you working on csh- or tcsh-land, you may find the following aliases useful:

alias here ‘setenv THERE_PWD `echo $PWD`’

alias there ‘cd $THERE_PWD’

Of course, this would also work for all of you bash people, but export would have to be substituted for the setenv command. The syntax with bash is also slightly different.

Mounting external drives

Here is a bit of advice on how to search for and mount new disks when they don’t automatically mount on the Linux machines. It is NOT necessary to reboot a machine just to have it recognize a drive.

The new CentOS distributions that we have on all of our Linux machines have USB Plug-n-Play capability. The OS will automatically detect an external USB drive, but will only ‘automount’ it if doing so does not conflict with explicit mount instructions written in /etc/fstab. It is always best to physically mount an external drive through the command line, or by inserting a line in /etc/fstab, as the drives will not disappear when the user logs out.

What to do when your disk doesn’t automount to the desktop…
(1) First you need to determine what the logical mount point is for the device you just plugged in. Try running ‘df -h’ or ‘mount’ to see what is already mounted to the machine. For instance, you might have an external USB drive with the logical mount point of /dev/sdb1 and the physical location of /media/usbdrive. Now that you know what is already mounted, you need to find the logical name of the new device…
(2) To determine the logical mount point of the new device, run ‘cat /proc/diskstats’ and see if there are any new devices listed. Newest entries are closest to the bottom. If, for instance, there is a listing for /dev/sdb# but it is not currently mounted on your machine, then that is the logical name of the newest device.
(3) Check to see if there is already an explicit mount command for that device listed in /etc/fstab. For instance, if the new device found in ‘cat /proc/diskstats’ is /dev/sdb1 and there is an entry in /etc/fstab for:
/dev/sdb1 —> /media/usbdrive
Just type ‘mount -a’ to automatically mount all of the devices listed in the /etc/fstab file.
(4) If no entry exists in /etc/fstab and the device does not automount to the desktop, then you’ll need to mount it manually with (using the example from above):
#> mount -t ext3 /dev/sdb1 /media/some_new_folder_name
(5) Of course, this example specified the mount type ‘-t’ as a linux-formatted ‘ext3’ drive. If the drive has not been formatted for ext3—new USB drives are formatted for Windows (vfat)—try to mount it as a ‘vfat’ drive. If you want to format the drive for Linux (ext3), see the next entry below.

Preparing a new external disk (USB/FireWire) for Linux

All of those fancy new external USB/FireWire disks come formatted as FAT32 disks… yuck. We don’t want to use that type of disk for Linux machines, because the file permissions can get a little messed up. So, there are two things we need to do for any brand new disk: (1) Create a partition (provides a partition table) and (2) format the disk for ext3. An example follows after two important notes…

Before you begin:

Please take note that all of the specific /dev/### device information used in the example will be unique to your machine. Therefore, you should not follow the example verbatim… you’ll need to figure out WHICH device you actually need to partition and format. One way to determine the logical mount point of a new device is to compare what is listed by running ‘df’ or ‘mount’ with what shows up in:
#> cat /proc/diskstats

Also, the new disk that you are formatting SHOULD NOT be mounted to the machine during the format process. It is also necessary to disable fstab-sync prior to formatting to prevent the machine from trying to ‘automount’ the disk during the process.

Disabling fstab-sync:

Follow these steps to disable/enable fstab-sync before/after formatting a new disk:

Disabling…

(1) #> cd /etc/hal/device.d/
(2) #> rm 50-fstab-sync.hal
(3) #> ln -s /bin/false 50-fstab-sync.hal

Enabling…

(1) #> cd /etc/hal/device.d/
(2) #> rm 50-fstab-sync.hal
(3) #> ln -s /usr/sbin/fstab-sync 50-fstab-sync.hal

Format example using fdisk:

Here is an example of how the process works.

Writing data to an external tape drive

So, I finally managed to get the old tape drive from Palm working on Wave. Here are the steps for writing/reading to/from tapes.

Checking tape drive status ~

If you need to check the status of the tape drive try:
#> mt -f /dev/st0 status

Writing data to tape ~

From within the directory that you want to write to tape (if on a machine other than the local machine… local meaning the one with the tape drive):
#> tar cvf – . | ssh <machine_hostname_with_tapedrive> dd of=/dev/st0 bs=20b

Good practice: write contents of that tape to an external file ~

Note, the following command will produce output to your shell. You could also append a ‘> foo.txt’ to the end of the following command to direct shell output to a file.
#> ssh <machine_hostname_with_tapedrive> dd if=/dev/st0 bs=20b | tar tf – .

Reading the data back from the tape ~

From the remote computer, execute:
#> ssh <machine_hostname_with_tapedrive> dd if=/dev/st0 bs=20b | tar xvf – .

And if you just one to fetch one file, try this ~

Note: this must be done while logged into the local machine (machine with tape drive).
#> tar -xvf /dev/st0 /full/path/to/file/that/you/want

Troubleshooting ~

Make sure SCSI tape module (st) is loaded:

#> modprobe st

So, you need the kernel-source for your distro?

These steps should save you some time, trouble and many headaches. In the even that you neglected to read the release notes for FC3…eh-hem…the FC project has decided not to supply the kernel-source in order to prevent redundancy. You see, the kernel-source tree can be extracted from the kernel-*.src.rpm if you absolutely need it. In my case, I needed to supply the –kernel-source-path when (re)installing the latest NVIDIA drivers (more on NVIDIA drivers below…) after rebooting with a new kernel. So, here are the steps that you should follow in order to extract the kernel-source tree from the kernel-*.src.rpm:
Step (1). Go find the kernel-*.src.rpm (#> locate kernel-*.src.rpm) or download it from the Internets. For instance, you could get it from here.
Step (2). Now you must install the rpm. As root, execute #> rpm -Uvh kernel-*.src.rpm
Step (3). The previous step should have created a kernel-2.6.spec (or similarly kernel-2.4.spec if you’re still on that kernel) file in the /usr/src/redhat/SPECS/ directory. You must build the rpm against this .spec file to get the binaries and source.
As root, execute #> rpmbuild -bp –target=noarch /usr/src/redhat/SPECS/kernel-2.6.spec
Step (4). Create the necessary symbolic links for your directory tree:
#> cd /usr/src
#> ln -s redhat/BUILD/kernel-2.6.10/linux-2.6.10/ linux
#> ln -s redhat/BUILD/kernel-2.6.10/linux-2.6.10/ linux-2.6.10
Step (5). Now we need to make the new .config files:
#> cd /usr/src/linux-2.6.10
#> make mrproper
#> cp /usr/src/linux-2.6.10/configs/kernel-2.6.10-i686.config /usr/src/linux-2.6.10/.config
#> make oldconfig
#> make menuconfig
#> make

Now, you have a kernel-source tree under /usr/src/linux-2.6.10 just like you would if you had been supplied the kernel-source in the first place. Note that the kernel numbers (i.e. 2.6, 2.6.10, etc.) and system architecture numbers (i.e. i686) may be different for your situation. Replace with correct numbers/information where necessary. I was able to install the new NVIDIA drivers by executing:
#> sh NVIDIA-Linux-x86-1.0-###-pkg1.run –kernel-source-path /usr/src/linux-2.6.10
Good luck!

Your system reboot hangs at ‘Checking For New Hardware’

This is occasionally a problem with these systems, often initiated by the KUDZU configuration detector.
The quickest solution I have found to this (probably not the best/safest) is to turn the kudzu manager off:
#> chkconfig kudzu off
Alternatively, you may use:
#> chkconfig kudzu on
Or even:
#> chkconfig kudzu
Another way to solve this problem is to shut the machine off and then select ‘I’ to enable the interactive boot-loader where you can select ‘n’ for the option to run kudzu.
If this is the case, select ‘y’ for all other boot-loader options.

Rebuilding Your fglrx Video Drivers (for ATI Radeon cards)

If you just rebooted your machine with a new linux kernel, then you may need to recompile the kernel module for the fglrx drivers to work properly.
Type lsmod from the command line and see if there is an entry for ‘fglrx’.
If there is not, then you’ll need to do the following…
Click here to download the latest driver for your ATI card (may need to run lspci to determine what card series you have).
Our group…click here for Radeon 8500 series or higher.
Here are additional installation instructions for the ATI drivers.
Building the fglrx kernel module:
1. cd /lib/modules/fglrx/build_mod
2. sh make.sh
Installing the fglrx kernel module:
3. cd /lib/modules/fglrx
4. sh make_install.sh
Note any error messages that appear during this process.
If running glxgears gives you frame rates of less than about 1500 fps, chances are you have not installed your video drivers properly 🙁
The following message (or similar) should appear when the ATI kernel module has been installed successfully:
==============================
– creating symlink
– recreating module dependency list
– trying a sample load of the kernel module
Warning: loading /lib/modules/x.x.xx-x/kernel/drivers/char/drm/fglrx.o will taint the kernel: non-GPL license – Proprietary. (C) 20XX – ATI Technologies, Starnberg, GERMANY
See http://www.tux.org/lkml/#export-tainted for information about tainted modules
Module fglrx loaded, with warnings done.

Login Hangs

When having login problems, bring up terminal console (runlevel 3…no X) with:
ctrl+alt+(F1 – F6)
Login as: yourself
Try to start X by typing,
#> startx

More on Rebooting With NVIDIA Drivers

When booting your system with a fresh linux kernel, it will be necessary to reinstall your NVIDIA video drivers. You’ll know this is the case if you get a big box on your screen telling you that it couldn’t configure the X display.
For the newest drivers, click here, but on our machines you can use the one in /usr/local/.
Follow these steps below:
1. Do not allow Xfconfig to fix the NVIDIA problem (this is the box I was talking about)
2. Login as root at the black screen
3. #> cd /usr/local (this is specific to our machines)
4. #> sh NVIDIA-Linux-x86-blah_blah_blah.run
5. Now select these choices as they appear: Accept, Yes, Yes, OK, OK
6. Now you should be back at the black screen
7. #> ps aux | grep gdm
8. #> kill -9 pid_for_gdm-binary
Now, the X should come back up and everything should be fine.
Try running, glxgears from CLI to ensure nvidia is working properly.

…still having problems with NVIDIA?

When rebooting with a new kernel, unless the kernel-source was also installed the nvidia driver self-extracting binary script will not be able to compile the driver information into the new kernel module.
This situation typically occurs when a user has bypassed the up2date service offered by RedHat to find a new kernel.
Often times, the user will not (or cannot) install the kernel-source prior to rebooting, thus causing the compiling problem.
If this error should occur during the nvidia driver installation, follow these steps:
1) Find the current kernel version using either of these commands…
#> uname -r
#> cat /proc/version
2) Check to see if the correct kernel-source is installed (just in case)…
#> rpm -qa | grep kernel-source
3) Find/download the corresponding kernel-source-‘uname -r‘ rpm and install it.
4) Try to run the nvidia install script again

Understanding and Setting Permissions

Reading file and directory permissions with: ls -sl
Click here.

Boot Mounting Problems

Booting into a read-only environment.
This situation presents itself infrequently, but when it does you cannot modify any files.
Here is an example of an occurrence…
A linux box wouldn’t boot properly and reported a problem with an ext2 filesystem on one of the partitions it was trying to mount.
The only option was to drop into a ‘repair shell’ to run e2fsck/fsck on the various partitions to see which one was having trouble.
As it so happens there were other problems that prompted this to happen: the only listings in /etc/fstab were for the cdrom and floppy drives.
Nothing else was being mounted, with the exception of the root partition / .
It was impossible to mount filesystems or edit files (like /etc/fstab) in the read-only environment, but there is a way around it…
#> mount -o remount,rw /dev/hdb5 /
This mounts the root partition / as a read-write filesystem and by doing so you should be able to edit files and mount other filesystems…ugh!

And if you need to repair a filesystem…

…then you should read this.

Backup Important Stuff With RSYNC!

Are you working on something important (like a thesis) and want to keep a mirror of your files on a different machine for backup purposes?
Of course, you could set up a sophisticated CVS repository but it can be complicated for the novice user.
The RSYNC command allows you to ‘Remotely SYNChronize’ two directories on different host machines.
For example, I kept an updated (daily) version of my entire thesis directory on a different machine while I was writing by using a combination of RSYNC and CRONTAB.
This came in handy on more than one occasion, especially living in a lightning-prone area!
Here’s the basic usage that you would execute on the backup machine:
#> rsync -avz -e ssh remoteuser@remotehost:/remote/dir /this/dir/
This will synchronize /this/dir (on the backup machine) with the /remote/dir (on the machine with the important stuff).
Albeit a bit confusing in this example, ‘remote’ refers to the machine that has the stuff that you want to backup/mirror.
Keep in mind that the files in /remote/dir on remotehost will NOT be changed.
If you wanted to make a daily backup of /remote/dir on ‘thishost’, then add the following line (for nightly backups at 11pm) to the crontab file on ‘thishost’:
#> crontab -e (opens the crontab file for editing)
00 23 * * * /usr/bin/rsync -avz -e ssh remoteuser@remotehost:/remote/dir/ /this/dir/

Looking for System Information?

Kernel Version
There are a number of ways to find information about the current system configuration.
#> uname -a
This prints the current kernel version, hostname, hardware platform, and operating system.
Kernel Version and GCC Info
#> cat /proc/version
This returns Linux kernel info and GCC version.
Machine Info
To find information about the processor…
#> cat /proc/cpuinfo
#> cat /proc/meminfo

PCI/Card Info
#> cat /proc/pci or
#> lspci

Setting Default Boot Runlevel

In order to specify the default runlevel during the boot process, edit the file /etc/inittab.
This comes in handy if you are having problems with video drivers or your X display.
The runlevel options are as follows:
# Default runlevel. The runlevels used by RHS are:
# 0 – halt (Do NOT set initdefault to this)
# 1 – Single user mode
# 2 – Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 – Full multiuser mode
# 4 – unused
# 5 – X11
# 6 – reboot (Do NOT set initdefault to this)

#
Replace the <#> below with the desired runlevel specifier:
id:#:initdefault:

Want to Set the Default OS in the GRUB Bootloader?

If you need to specify the default kernel (or operating system if your machine is a dual-boot) for the GRUB bootloader to use during a reboot (note: this comes in handy when you don’t have access to your machine via mouse or keyboard…like when they run out of batteries!), edit the file /etc/grub.conf.
This file has a list of all possible kernels (and operating systems) to use during the boot process and to set the default value, change the first line of the file…
default= some_number
I believe the numbering in the list starts with 0 (zero).

Reinstalling CentOS on our Machines

If you need to re-install a version (new or old) of CentOS on a Linux box that is currently in use (i.e. has /home partition(s)), here is a list of things you’ll need to backup and keep handy for the re-installation process.
# Necessary #####################################
1) Make a new directory in /home ( /home/root-temp ) and copy everything from /root directory to it…don’t forget to copy files that may be in subdirectories in /root
2) Copy the contents of the root crontab file to a .txt file
3) Copy the following files from the /etc directory:
– passwd
– group
– shadow
– modules.conf
– fstab
– resolv.conf
– hosts
4) Copy all of the files in the /etc/ssh directory.
5) Copy the sources.list file in /etc/apt
6) May wish to make a copy of your working XF86Config from /etc/X11
7) If you have anything written to your crontab file, copy it to another file.
8) Copy/tar/compress any important stuff under /usr directory (matlab, tecplot, etc.)
9) Copy/tar/compress ifc compilers in /opt directory.
# Optional ######################################
A) Write the following info to a file:
– IP address: xxx.xxx.xxx.xxx
– Host Name: xxxx.coastal.usouthal.edu
– Net Mask: 255.255.255.0
– Gateway: xxx.xxx.xxx.1
– DNS-1: xxx.xxx.xxx.xxx
– DNS-2: xxx.xxx.xxx.xxx
– DNS-3: xxx.xxx.xxx.xxx
– DNS search: usouthal.edu
# Before Re-install #############################
1) Change default run-level to 3 in /etc/inittab (id:3:initdefault:)
2) This will permit you to copy all of your saved files over while X is disabled.
3) Should be able to type #> startx or #> telinit 5 to bring up X.

Is that RPM Installed on My Machine?

If you need to determine whether a certain rpm is installed on your system, try…
#> rpm -qa | grep part_of_name
For instance, I could run #> rpm -qa | grep Real to see what version of RealPlayer I am using.
The output is…
RealPlayer-10.0.4.750-20050401

Get Rid of that Frozen X Display…

To disable X and switch to single-user mode, use…
#> telinit 3
To enable X and switch to multi-user mode, use…
#> telinit 5

Want to Run/Load Something During Boot?

Add your necessary info or a call to some shell script to the file /etc/rc.d/rc.local


Thanks to Brian Barr for the following…

Initial Security

On your new shiny install of Linux, you probably have a bunch of stuff that doesn’t need to (or maybe shouldn’t) be running.
Look at the links in /etc/rc.d/rc5.d (on RedHat anyways…). Services get started with the “S??servicename” scripts.
Get rid of the ones you don’t want (as root) with:
chkconfig –del servicename
Check your handywork with a portscan (try ‘nmap’). On a normal *work* station the only ports that should be open are ssh, X, and printer.
The more that are open (that’s different than filtered…) leaves more chance to be hacked.

Burning CDs

For a graphical tool, you may want to check out xcdroast.

Make an ISO file from some directory :
mkisofs -f -R -r -l -J -o FOO.ISO src_directory

Mounting ISOs loopback:
mount -t iso9660 -o ro,loop=/dev/loop0 FOO.ISO /mnt/mount_point

Burn an ISO to a CD-R:
1) Check your device: cdrecord -scanbus
2) Assuming step 1) told you your writer was 0,0,0, write it with:
cdrecord -v speed=12 dev=0,0,0 -data FOO.ISO

Burning DVDs

You can fit about 4.4 GB on a DVD. All the drives we have are DVD+RW. Media for DVD-(R/RW/RAM) won’t work (think Betamax and VHS).
To format a DVD+RW use dvd+rw-format. (No need to do it on DVD+R)
To write files to DVD+RW, no need to make an ISO first! Just arrange the files you want to burn (maybe make a separate directory in /tmp?),
then use this command (assumes that your drive is /dev/scd0, check what the link /dev/cdrom points to…):
growisofs -Z /dev/scd0 some_directory/
growisofs -Z /dev/cdrom -f -R -r -l -J some_directory/

NOTE: see ‘man mkisofs’ for what the second set of flags does…

Installing a new kernel

About the only thing that apt-get won’t do automatically is install a new kernel for you. As root, you can do this:
apt-get update
apt-get install kernel

Now it will tell you that kernel is a “virtual” package, and you have to specifya version number. Always install the corresponding kernel-source as well:
apt-get install kernel#2.4.20-18.8
apt-get install kernel-source#2.4.20-18.8

NVIDIA drivers and a new kernel

I think that as of 2.4.20, the old drivers don’t work anymore.
The latest (as of 6/10/03) were 1.0-4363. Check here to get the latest drivers.
Now you just have to run their installer script…

Old instructions below for nostalgia:

If you install a new kernel, and you had been using the Nvidia drivers, X will fail. But at least on RedHat 8 it will die gracefully.
At the text login, do this:
You need to rebuild the Nvidia rpm’s for the new kernel (requires the kernel source, you did get that right???).
In /usr/src/redhat/SPECS run as root rpmbuild -bb NVIDIA*
In /usr/src/redhat/RPMS/i386 run rpm -Uvh –force NVIDIA*
Now reboot, or do startx
Of course, the way around this would be to boot in init level 3 (no X). Then individuals find it out the hard way…

Use CVS!

Setting up CVS to manage your code:
1) To your .cshrc file: setenv CVSROOT ~/cvs_models
2) cvs init
3) cvs import -m “Imported sources” modelname yourname version (e.g. cvs import -m “Imported…” ekman barr start)
4) cvs checkout ekman
5) cvs release -d ekman (to cleanup)

If apt-get/up2date hangs:

If rpm/apt gets messed up, they have files scattered everywhere:
1) Config files for apt are in /etc/apt – but that’s generally not the problem
2) Config files for up2date are found in /etc/sysconfig/rhn
3) Apt stores packages and info in /var/state/apt and /var/cache/apt/archives
4) rpm/up2date will save packages in /var/spool/up2date
5) The rpm database is in /var/lib/rpm.
If rpm or apt hangs, try deleting /var/lib/rpm/__db* and kill all apt, rpm, and up2date jobs that are running.
If it still hangs, try rpm –rebuilddb.

Fun with tar:

My favorite way to move files is with ‘tar’ and ‘|’…
from the Tru64 manpage for tar (the linux page doesn’t have this):
cd fromdir; tar cf – . | (cd todir; tar xpf -)

Of course, to back up those precious files from your machine to some machine
called ‘tapey’ that has a tape drive, try this starting in the directory
that you want to save:
tar cvf – . | ssh tapey dd of=/dev/tape/tape0 bs=20b
You may have to figure out what the actual tape device name is, on our alphas(Tru64) it is /dev/tape/tape0.

To read that same data back to your machine, try this:
ssh tapey dd if=/dev/tape/tape0 bs=20b | tar xvf – .

To extract just 1 file try this (on the machine with the tape drive): tar -xvf /dev/tape/tape0 /Full/Path/To/File/that_you_want.txt

Movies from sequential images

Assuming your have a directory PNG that holds a group of png files, make a list:
find PNG/ ! -type d | sort > list
find the size of one frame ‘tcprobe -i PNG/file001.png
use that size when passing your list to transcode:
transcode -i list -x imlist,null -y ffmpeg,null -F mpeg4 -g WIDTHxHEIGHT -z -f 15 -o movie.avi -H 0
You might need to specify ‘-z’ to flip your images…
Look in /usr/lib/transcode for your export options if you don’t want an MPEG4 file.

Screenshots:

You need Image Magick installed (it is by default under RH, I think…).
Have your material you want snapped in a window that doesn’t overlap a terminal.
In the terminal, typ ‘import screenshot.jpg‘. The cursor will change shape.
Click in the window that you want to save. View with ‘gqview’ or ‘gimp’.
Or for the whole desktop use: ‘import -window root screenshot.jpg
This provides a full description.

Building an RPM from source:

To build a binary RPM from source, check this out. These instructions are only brief. Please refer to the RPM-HOWTO for further reference. * Download the source package to your machine.
* Become root: su –
* Install the SRPM: rpm -Uvh
* Go to the SPECS directory (/usr/src/redhat/SPECS or /usr/src/packages/SPECS) cd /usr/src/redhat
* Look for the specfile. (package.spec)
* Tell RPM to build that thing: rpm -ba
Watch the following messages. RPM does tar -zxf package.tar.gz, configure, make, make install (into a temporary dir), and finally, it puts together the .rpm and .src.rpm packages.
After that, you should end up with a binary and a source package. They are located under /usr/src/redhat/RPMS/your_arch and /usr/src/redhat/SRPMS

Leave a Reply

Your email address will not be published. Required fields are marked *