open.itworld.com
  Search  
Security Home Page Security Webcasts Security White Papers Security Newsletters Security News Open Topics Careers ITworld Voices ITwhirled The Security site of ITworld.com

Unix Tip: Clearing the screen

ITworld.com 6/12/2007

Sandra Henry-Stocker, ITworld.com

Send in your Unix questions today! | See additional Unix tips and tricks

Every now and then I come across a system which, when I issue a request to clear the screen (i.e., the clear command), I get something like this instead:

oopsy# clear
ld.so.1: clear: fatal: libncurses.so.5: open failed: No such file or directory
Killed
Often, on encountering this problem, I simply growl, press enter a couple dozen times and continue working. When I'm in a particularly "fixit" mood, on the other hand, I figure I shouldn't be putting up with annoying configuration problems and decide to break my train of thought just long enough to tackle this distracting problem head-on.

So, what is going on when you get an error such as this?

First, we know it came about because I issued the "clear" command. Next, we see that the error was issued by ld.so.1 (the runtime linker). Third, we see that the linker wasn't able to open a particular shared object file; it couldn't find it. The shared object file, libncurses.so.5, as you might suspect is the curses library. Curses provides a set of functions that provide users with the ability to manipulate a terminal's display regardless of the terminal type; thus the problem arose when I attempted to clear the contents of a terminal window. The curses library contains routines to accomplish this task. When I ran into the error shown above, I figured that one of two things was true. Either the library wasn't installed on the system (maybe it had been removed) or the linker just couldn't find it. A quick scan of the system showed that the "missing" library was installed in /usr/local/lib.
oopsy# ls -l /usr/local/lib/libn*
-rwxr-xr-x   1 bin      bin       247760 May  1  2001 /usr/local/lib/libncurses++.a
-rw-r--r--   1 bin      bin       453732 May  1  2001 /usr/local/lib/libncurses.a
lrwxrwxrwx   1 root     root          15 May 20  2003 /usr/local/lib/libncurses.so -> libncurses.so.5
lrwxrwxrwx   1 root     root          17 May 20  2003 /usr/local/lib/libncurses.so.5 -> libncurses.so.5.2
-rw-r--r--   1 bin      bin       338384 May  1  2001 /usr/local/lib/libncurses.so.5.2
-rw-r--r--   1 bin      bin      3459752 May  1  2001 /usr/local/lib/libncurses_g.a
To understand why the linker couldn't find the library, you need to know something about how the linker locates object files in the first place. In short, it uses its own search path much like the shell uses the $PATH variable. By default, the linker's search path generally includes only /usr/lib. If libraries are installed on your server in other locations, you either need to append their directories to the LD_LIBRARY_PATH variable (which, by default, has no value) for your user accounts or you can amend the default search path using the crle (configure runtime linking environment) command. The crle command which, without arguments, displays the current search path for ld.so.1, indicated that /usr/local/lib was not included (refer to the second line of output below).
oopsy:/var/adm # crle

Configuration file [version 4]: /var/ld/ld.config
  Default Library Path (ELF):   /usr/lib	<== default path
  Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system default)

Command line:
  crle -c /var/ld/ld.config -l /usr/lib
Additional directories can be added to the linker's search path with the crle command. If you do this, make sure you specify the complete path, including the current directories. Otherwise, your linker will have trouble running even the most innocuous system commands. Most, if not all, system commands make use of shared object files in /usr/lib.

oopsy# crle -l /usr/lib:/usr/local/lib

Note that the path shown above includes the pre-existing as well as the new directories. When you issue a crle command like that shown above, crle will update the linker's configuration file -- /var/ld/ld.config. Unlike most configuration files on Solaris systems, this file is not a straight text file. Display its contents with "od -bc /var/ld/ld.config" if you would like to see what I mean). As a result, it will look odd if you use the cat command to display it or attempt to edit it with vi. Don't. Looking at crle's output after the command to redefine its search path, we see the /usr/local/lib directory has been added.
oopsy:/var/adm # crle

Configuration file [version 4]: /var/ld/ld.config
  Default Library Path (ELF):   /usr/lib:/usr/local/lib
  Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system
default)

Command line:
  crle -c /var/ld/ld.config -l /usr/lib:/usr/local/lib
Now, when I go to clear the screen, the command works properly and it should continue to do so through various logins and reboots.

oopsy# clear

On this topic

 

Sandra Henry-Stocker has been administering Unix systems for more than 18 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She currently works for TeleCommunication Systems, a wireless communications company, in Annapolis, Maryland, where no one else necessarily shares any of her opinions. She lives with her second family on a small farm on Maryland's Eastern Shore. Send comments and suggestions to bugfarm@gmail.com.




Sponsored Links

Sun Microsystems' - FREE 60 DAY TRIAL OFFER!
Test Sun's Newest Servers BEFORE YOU BUY. Plug Them In With Access To Full Technical Support.
TRY MICROSOFT DYNAMICS® CRM Online FREE
Get Microsoft Dynamics CRM capabilities without the investment in IT infrastructure and staffing.
New Webcast: How to PROFIT WITH REMOTE SUPPORT
Discover how REMOTE SUPPORT can fuel your IT business in ways you've never thought of before.
Sign up for a FREE NETWORK RISK ASSESSMENT!
MORE THAN 70% OF NETWORKS ARE INFECTED by hidden Malware. Find out if your network is infected now!
Used and Refurbished HP ProCurve Switches
Lifetime Warranties, Professional Testing & Shipping on all HP Equipment Purchases!
» Buy a link now

Advertisements
Sponsored links
Top 5 Reasons to Combine App Performance and Security
KODAK i1400 Series Scanners stand up to the challenge
Bring harmony to your mix of UNIX-Linux-Windows computing environments
Locate Hidden Software on business PCs with this free tool
 Home   Open source  Operating systems  Unix
www.itworld.com    open.itworld.com     security.itworld.com     smallbusiness.itworld.com
storage.itworld.com     utilitycomputing.itworld.com     wireless.itworld.com

 
Contact Us   About Us   Privacy Policy    Terms of Service   Reprints  

CIO   Computerworld   CSO   GamePro   Games.net   IDG Connect   IDG World Expo   Infoworld   ITworld   JavaWorld   LinuxWorld  MacUser   Macworld   Network World   PC World   Playlist  

Copyright © Computerworld, Inc. All rights reserved

Reproduction in whole or in part in any form or medium without express written permission of Computerworld Inc. is prohibited. Computerworld and Computerworld.com and the respective logos are trademarks of International Data Group Inc.