Two Cent Tips
As a new Linux user, I discovered that I had a hard time finding my way around the file system. I knew the find command was out there, but remembering all the options required to make it search the right places, find the right files, and print the right answers was something I couldn't do, at first. So I made up my own command, using a shell script, and called it fnd.
fnd takes one argument, the name of the file you want to locate, complete with any wildcards you may wish to include, and pipes its output to less, which then allows you to view a large list of results. What you get, on each line of output, is the complete path to any file that you're looking for. I find it amazingly useful (as is a rough familiarity with the less command). Here's my script:
!/bin/bash find / -iname $1 -mount -print |less
That's it. The -iname option tells find to be case insensitive, the $1 is a variable that substitutes in your command line argument, -mount tells find not to search directories on other file systems like your CD-ROM (because mine is wonky and locks up the machine if it is accessed). The -print option is required or you don't get any output. (Get used to it, it's *nix.) The | (pipe) symbol tells find to direct its output to the less command, so you can see your results in style. Don't forget the / right after the find command, or it won't know where to look. Enjoy. You won't regret the time you spend keying in this little shortcut, and don't forget to put it in a bin or sbin directory after using chmod to make it executable. —Jim Murphymurphyc@cadvision.com
In the mail from issue 9, Jim Murphy says that the -print option to find is necessary to get output from the find command, and follows that up with “get used to it, it's *nix.” Well, he's part right. Linux does require this. However, any users who work on other Unix boxes will find slight differences in some of the common CLI (Command Line Interface) commands. For example, find on Solaris does not require the -print option to get output. Just food for thought.
Second, I have an xterm title bar function that people might find useful. I'll give the code first, then explain what it does.
In your .bashrc (or .kshrc—note this only works on ksh style shells) add the following:
HOSTNAME=`uname -n`
if [ "$TERM" = x"term" ] && [ "$0" =
"-bash"]
then<\n>
ilabel () { echo -n "^[]1;$*^G"; }
label () { echo -n ^"[]2;$*^G"; }
alias stripe='label $HOSTNAME - ${PWD#$HOME/}'
alias stripe2='label $HOSTNAME - vi $*'
cds () { "cd" $*; eval stripe; }
vis () { eval stripe2; "vi" $*; eval stripe;}
alias cd=cds
alias vi=vis
eval stripe
eval ilabel "$HOSTNAME"
fi
This does three things (as long as you're in an xterm and running bash):
When the xterm is first opened, the name of the current host is displayed in the title bar.
When you change directories (using cd), the current path is displayed in the xterm title bar with the user's $HOME directory stripped off the front end of the path (to save some space when you're somewhere in your own directory tree). The path is preceded by the current host's network name.
When you use vi to edit a file, the name of the file is displayed in the title bar along with the current host's name. When you exit your vi session, the title bar reverts to the hostname/path format described in #2 above.
I find this very useful for all my ksh-based systems, because it removed the path from my shell prompt, thus saving me space for prompt commands. Since bash is a ksh compatible shell, this works quite well on standard Linux systems. —Michael J. Hammelmjhammel@csn.net
Saw Jim Murphy's find tip in issue #9, and thought you might like a quicker method. I don't know about other distributions, but Slackware and Red Hat come with the GNU versions of locate(1) and updatedb(1), which use an index to find the files you want. The updatedb(1) program should be run once a night from the crontab facility. To ignore certain sub-directories (like your /cdrom), use the following syntax for the crontab file:
41 5 * * * updatedb --prunepaths="/tmp /var \
/proc /cdrom" > /dev/null 2>&1
This command would run every morning at 5:41 AM, and update the database with file names from everywhere except the subdirectories (and those below) listed.
To locate a file, just type locate file name. The file name doesn't have to be complete; locate can also do partial matching. For me, the search typically takes only a few seconds, and I have tens of thousands of files.
The locate(1) command also has regular expression matching, but I often just pipe it through agrep(1) (a faster grep) to narrow the search. Thus:
locate locate | agrep -v man
would exclude the man page, and only show me the binary and the sources, if I had them on-line. (The -v flag excludes the pattern used as an argument.) To get the binary files alone, along with a complete directory listing, use the following command:
ls -l `locate locate | agrep bin`
The find(1) command is a great “swiss-army knife” (and actually not that bad once you get used to it), but for the 90% of the cases where you just want to search by file name, the locate(1) command is far faster, and much easier to use. —Bill Duncan, VE3IEDbduncan@ve3ied.uucp
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- RSS Feeds
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- Readers' Choice Awards
- The Secret Password Is...
- Reply to comment | Linux Journal
5 min 36 sec ago - All the articles you talked
2 hours 29 min ago - All the articles you talked
2 hours 32 min ago - All the articles you talked
2 hours 33 min ago - myip
6 hours 58 min ago - Keeping track of IP address
8 hours 49 min ago - Roll your own dynamic dns
14 hours 2 min ago - Please correct the URL for Salt Stack's web site
17 hours 14 min ago - Android is Linux -- why no better inter-operation
19 hours 29 min ago - Connecting Android device to desktop Linux via USB
19 hours 58 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
bash/ksh using less command
!/bin/bash
find / -iname $1 -mount -print |less
doesn't works on both my suse sles 9 and 10:
it displays the following message:
<<>>
(the same if I replace "less" with "more")