DæmonNews: News and views for the BSD community

April 2000 Get BSD New to BSD? Search BSD Submit News FAQ Contact Us Join Us
Search


Get BSD Stuff

Answer Man

by Gary Kline and David Leonard

This time we bring you several more of the questions that pop up very often on the mailing lists and BSD newsgroups--oh, and the answers with commentary in some depth.

More coming soon to this website direct to you. And next column, maybe a pleasant surprise!




Q: Is there an easier way to uuencode and mail gzip'd tarballs than:

 
$ uuencode saveconfig.gz saveconfig.gz > saveconfig.uu 
$ mail -s saveconfig.uu smith@save.com < saveconfig.uu ? 

A: Sure, and one that fits your example case might be to use the power of pipes with redirection. Here is a one-liner:

 
% uuencode saveconfig.uu < ./saveconfig.gz | mail -s saving smith@save.com 

There are examples of using uu{en,de}code in the uuencode(1) man page. Say that you want to send a friend your sample project code at a distant site and haven't got an ftp path to reach him, or just want a one-liner. After you have cd'd to your project directory, this will automate the task.

 
% tar -zcf - . | uuencode proj.gz | mail -s proj.gz friend@some.edu 


Q: My power has gone out unexpectly in recent days. How can I automate my BSD system to auto-sync my disks, say, every few seconds... just in case?

A: In FreeBSD, this is one for /sbin/sysctl, the utility that lets you retrieve or set many things in the BSD kernel. To update the sync time, as root

 
# sysctl -w kern.update=3 

will sync the disks every three seconds. sysctl lets the root user fine-tune the system. sysctl retrieves and lets root alter a wide range of things such as the number of processes to a given user or the number of open file per user (ID) or the open files per process.

Typing

 
# man 8 sysctl 

will give you more details.

OpenBSD doesn't have such a knob. The sched_sync ('update') kernel thread syncs a filesystem once every second, unless you are running with soft updates in which case it syncs continuously. This behaviour is negated by mounting a filesystem with the 'async' option.

The interesting question is why your reliability experience with Linux/ext2fs has been better than with *BSD/ffs. Perhaps this extract exlpains it:

BSD-like synchronous updates can be used in Ext2fs. A mount option allows the administrator to request that metadata (inodes, bitmap blocks, indirect blocks and directory blocks) be written synchronously on the disk when they are modified. This can be useful to maintain a strict metadata consistency but this leads to poor performances. Actually, this feature is not normally used, since in addition to the performance loss associated with using synchronous updates of the metadata, it can cause corruption in the user data which will not be flagged by the filesystem checker. (Full paper)

In BSD, the ffs performance loss associated with synchronous mounts (the default) can be reduced by either mounting with the 'async' option (which can lead to more corruption) or enabling soft updates on your file system. See the tunefs(8) manual page for details on turning it on.

See also http://www.mckusick.com/articles.html


Q: What do the directory abbreviations

 
/usr/share/doc/smm 
/usr/share/doc/psd 
/usr/share/doc/usd 

stand for?

A:

 
smm is for the System Manager's Manual 
psd is for the Programmer's Supplementary Documents 
usd is for the User's Supplementary Documents 

In days of yore, physical paper books, collectively called the Manual, accompanied Unix releases. It consisted of the smm, psd, usd and all the manual pages accessible with man(1).

The smm/psd/usd directories are intended to contain the source code to those parts of the Manual. These days, most manual searches are performed online, and the format of the smm/psd/usd documents are not as amenable as the manual pages are. Because of their reduced profile, they are poorly maintained in the *BSD world and so tend to be treated as historical documents rather than working documentation.


Q: How do I enforce automatic logout after specified amount of time?

A: FreeBSD sets this in /etc/login.conf, with the :idletime directive. To set an idletime maximum of 30 minutes, assuming the users you want to logout after 30 minutes are dialed in, set the

":idletime=30m:" 

line under the PPP/SLIP connections section.

Of course idletime and sessiontime are different things, so if you want to limit all users to, say 8 hours and 30 minutes, under the same section you would set

":sessiontime=8h30m:" 

Do a

 
% man login.conf  

for details. It's worth noting that /etc/login.conf is one of those almost-endlessly configurable sysadmin features.

OpenBSD does not have such burdensome rules. Instead, the reader is referred to the /etc/ppp/options or the idled port; /usr/ports/sysutils/idled.


Q: How do I print out man pages so I can go in a corner and read them?

A: First of all, you will need to find the file that contains the manual page `source'. You can find it by giving the -w option to man(1). Note that on some systems, manual pages are installed preformatted ASCII and/or compressed, and these will appear as `cat' pages:

    
% man -w ls /usr/share/man/cat1/ls.0.gz 

A slight diversion on cat pages is in order:

Cat pages are plain text files with backspace sequences that achieve overstrike, (bold) and underline on a dot-matrix or line printer. For example to print a bold 'B', you would send to the printer 'B', backspace and then the 'B' again.

The online paging programs, more(1) and less(1), understand the backspace sequences and simulate overstrike and underlining when you view the manual page.

However, we need the manual page source to the cat pages. For the ls cat page named above, the corresponding 'man' page should be located at:

 
/usr/share/man/man1/ls.1 

If you don't have this form of the file, then you will find it hard to print out the documentation on anything except a line printer.

Assuming you found the man page source, you can now convert it into one of many types of outputs. For example, to generate postscript output, use the -T (type) and -mandoc flags to groff in the following incarnation:

 
% groff -Tps -mandoc /usr/share/man/man1/ls.1 > ls.ps 

You can then send this file to your postscript printer with lpr.


Q: How can I set up my console screen to do 80x50? I'm tired of seeing the standard 80x24 lines.

A: In FreeBSD, one way of setting the kind of console display you want is thru vidcontrol.

 
# vidcontrol VGA_80x50 

Doing a

 
% man vidcontrol 

will tell you about all the vidcontrol options. Another way is to set up all your console screen with the 80x50 option by putting

 
allscreens_flags="VGA_80x50" 

in /etc/rc.conf to set it for all console screens when you boot. But be aware that the "allscreens_flags" option only works for some vidcontrol options; for instance, you can't set foreground and background colors this way. On OpenBSD, the proper way is to set the TERM environment variable to `pcvt25' and then use the scon(1) utility:

 
% scon -s 25 

You may also need to turn off the interfering 'full' VT220 compatibility mode with:

 
% scon -f off 


About the Authors

Gary Kline has been porting code since the late 1970's when he helped port several V6 utilities to V7 at Cal Berkeley. He is the principal architect for Project Muuz, an open-source shareware mind-zapping app. When he isn't hacking code, he's hacking Zen poetry or prose, or listening to jazz radio and drinking espresso.

[home| mail]

David Leonard is a PhD student in the Department of Computer Science and Electrical Engineering at the University of Queensland, Brisbane, Australia.

His area of research is QoS-adaptive component software architectures, and in his spare time is a developer for the OpenBSD project. That said, David enjoys living the quiet life with his wife, Kylie and cat, Mu. He especially enjoys frequenting Moreton Bay's many fabulous places to eat. Mmmmm!

[home| mail]




Author maintains all copyrights on this article.
Images and layout Copyright © 1998-2004 Dæmon News. All Rights Reserved.