SolutionsPrivate Clouds: Cloudforms PaaS: OpenShift Public Clouds Cloud Portfolio Building Clouds Cloud Partner Program ResourcesMedium & Large Enterprise Enterprise Solutions Business Intelligence Collaboration & Content Management Enterprise Applications Security Web Applications
Tips from RHCEs
Featured Article: less Surprisesby Randy Russell, Red Hat Certification Manager
less, the GNU utility that resembles the classic UNIX more command, has capabilities you might not be aware of. Sure, it will page through files, but have you ever tried the following?
These commands are equivalent to the following, respectively:
tar ztvf somefile.tar.gz | less
tar jtvf somefile.tar.bz2 | less
unzip -l somefile.zip | less
(rpm -qpi somepackage.rpm; rpm -qpl somepackage.rpm) | less
In all these cases, less provides the same function with less (sorry!) typing.
The following command is very familiar to Linux and UNIX system administrators:
tail -f /var/log/messages
For the uninitiated, this command displays the system log (/var/log/messages), and updates the display as new entries are written to the log. For example, you might run a tail -f like the one above on a DHCP server to see DHCP requests and acknowledgments as they happen.
Sometimes, however, you not only want to have the display updated, but you also want to scroll back through the output periodically. less provides this capability. First, less the file that you wish to monitor (this could also be output that has been passed through a pipe to less):
Now type Shift-f. The display will immediately go to the bottom of the file and you will see a line like the following below the output:
Waiting for data... (interrupt to abort)
As new data enter the log, the display will update. less will remain in this mode until you type ^c.
Spend more time with less. Like the other great GNU tools included with our OS products, it is full of surprises.
Randy Russell is the Certification Manager for Global Learning Services, responsible for maintaining the RHCE program as well as overseeing security and embedded courseware. He has been instructing Red Hat training classes for three years. In that time he's seen the program grow from a single RHCE course at the corporate headquarters to courses offered in 65 locations around the world, covering a broad range of open source technologies.