UpFront
UpFront
Tech Tip
Here's the problem. We need to remove duplicate lines from unsorted text from within the shell. This normally would be the job of sort -u or sort | uniq, except that in either case, we lose the input order. For example, if this is the input file:
$ cat >/tmp/numbers <<EOF one two three one three four EOF
Running it through sort -u would get this:
$ sort -u /tmp/numbers four one three two
The solution:
$ nl /tmp/numbers | sort -k2 -u | sort -n | cut -f2- one two three four
For platforms where the nl command is not available, awk could be used to simulate this behavior:
$ awk -v 'OFS=\t' '{print NR, $0}' /tmp/numbers | sort -k2 -u
↪| sort -n | cut -f2-
one
two
three
four
What it does is pretty simple—it adds a record number field, sorts the input ignoring that field, restores the original order using the record numbers and then strips that field out.
Tech Tip
There is nothing worse than when you boot up your Linux machine to show Windows users a neat feature, such as your slick 3-D Compiz desktop, and while booting, you get the message that one of your partitions needs to be force-checked because it hasn't been checked in 23 boots. So while e2fsck trudges through that giant partition scanning for errors, the people you were attempting to convert are rolling their eyes and trying to contain their laughter about your so-called superior OS.
You can tweak the conditions under which the filesystem check will run at boot time using the command tune2fs. Using a -c option allows you to tweak the number of boots that will trigger a forced check, and using -i allows you to change the time interval between checks in the format: [days|weeks|months].
If you want to initiate disk checks manually only (a risky idea if you forget—proceed at your own risk!), use this variant of the command:
tune2fs -c 0 - i 0
Tech Tip
Do you need to give passwordless SSH access to users but also need to restrict what can be run? Here I give interactive and non-interactive examples.
First, you need to generate authentication keys (no passphrase) using ssh-keygen. In this tip, I generated rsa keys. The keys, by default, are saved as ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub.
You need to append the public key as follows:
suman@shri:~/.ssh$ cat id_rsa.pub >> authorized_keys
Prepend the command (that you want to be executed automatically) to the signature. For example, if uptime is the command to be executed automatically whenever an SSH request comes from the user for which you generated the key, the key entry in authorized_keys file should look like this:
command="/usr/bin/uptime" ssh-rsa <LONG ENCRYPTED STRING>
Now, you can use the private key to execute the uptime command automatically. The private key in this example, by default, was saved as ~/.ssh/id_rsa. I copied it to the remote host and saved it as uptime.key. Make sure this file has 600 permissions. Then, you can do the following (from the remote machine):
suman@strangeloop:~ % ssh -T -i uptime.key suman@shri 15:11:46 up 4 days, 3 min, 3 users, load average: 0.00, 0.00, 0.00
This technique also can be used for interactive programs. Below is a simple interactive shell script:
#!/bin/sh echo -n "Hi! Enter your fav distro: " read DISTRO echo "Your fav distro is $DISTRO"
Here I have created another set of keys as I did above. I saved the private key as distro.key. Prepend command="<full_path_to_script>" to the public key in the authorized_keys file, and you will be able to do:
suman@strangeloop:~ % ssh -T -i distro.key suman@shri Hi! Enter your fav distro: Debian Your fav distro is Debian
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
| Designing Electronics with Linux | May 22, 2013 |
| 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 |
- Dynamic DNS—an Object Lesson in Problem Solving
- Designing Electronics with Linux
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Web & UI Developer (JavaScript & j Query)
- Senior Perl Developer
- Technical Support Rep
- Symbolic Math with Python
- UX Designer
- Network Monitoring with Ethereal
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!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
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?




3 min 46 sec ago
21 min 9 sec ago
2 hours 14 min ago
4 hours 7 min ago
11 hours 1 min ago
11 hours 17 min ago
13 hours 9 min ago
19 hours 56 sec ago
23 hours 32 min ago
23 hours 33 min ago