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
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Linux Systems Administrator
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Validate an E-Mail Address with PHP, the Right Way
- Technical Support Rep
- Senior Perl Developer
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Introduction to MapReduce with Hadoop on Linux
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?




1 hour 26 min ago
4 hours 20 min ago
4 hours 46 min ago
7 hours 14 min ago
7 hours 47 min ago
7 hours 48 min ago
7 hours 49 min ago
7 hours 51 min ago
7 hours 52 min ago
7 hours 54 min ago