1,313 reputation
313
bio website
location California
age
visits member for 2 years, 2 months
seen Aug 29 at 3:47

Jun
20
comment Using Perl to count the number of scientific numbers in a file
This would give incorrect results if a line happened to contain both a number and some other string. The answer above that uses grep's -o option to output only matches is more correct.
Apr
23
comment Is there an alternative to the `which` command?
If your shell or keyboard doesn't support "[]" (I think ash does), you can replace [ -x $dir/$COMMAND ] with test -x $dir/$COMMAND (test is a bash/ash built-in, and may also be available as a standalone executable
Mar
29
comment What is the best way to add a user to the sudoer group?
And, visudo only protects you from syntactical errors - it's still possible to lock yourself out of the system with a bad sudoers configuration. So, you should still know how to get root without sudo. I usually edit /etc/sudoers with vi instead of visudo, write the file, and test my sudo access before exiting vi. That way I can revert my changes if it doesn't work. This doesn't work with visudo since it edits a temp file. Though these days it's not much of an issue since nearly all of my servers are managed by Puppet, including the sudoers file.
Mar
29
comment ssh-copy-id hangs with 8192-bit key
For completeness, I tested with a 16384 bit key (the max key size for my version of ssh) and it worked fine too. Took a long time (5 minutes or so) to create that 16384 bit key and has a noticeable 2 or 3 second delay when authenticating to the remote host.
Mar
29
comment ssh-copy-id hangs with 8192-bit key
Works for me with an 8192 bit key and Linux client and server: OpenSSH_6.0p1 Debian-3ubuntu1.1, OpenSSL 1.0.1c 10 May 2012.
Mar
28
comment Particular site is not working on Ubuntu 12.04
@Graeme - If an alternate DNS server solves his problem, he can edit the resolvconf config to hardcode the DNS server.
Mar
28
comment Particular site is not working on Ubuntu 12.04
@Graeme If he can resolve the name using an alternate DNS server, then the solution to his problem is clear. If he can't, then the search goes on.
Mar
28
comment Particular site is not working on Ubuntu 12.04
Maybe your ISP's nameserver is not resolving some domains for some reason. Some have noted that Comcast is silently blocking some domains from DNS resolution. Try running host developer.android.com to resolve with your default nameserver, then host developer.android.com 8.8.8.8 to resolve with a Google DNS server to see if it's a problem with your default DNS server.
Feb
18
comment awk + print awk output in one line
If he wants a newline after the last record, he could do: awk '/Shutdown/ {printf "%s ", $1} END {print ""}'
Oct
25
comment Cannot install rsync (unable to create…Input/output error)
Thanks, I added it as an answer. I didn't add it as an answer originally because I didn't think it would turn out to be something so obvious :)
Oct
25
comment Performance Issue: AWS Medium Linux Instance V/S Hetzner Dedicated Instance
Since you're only seeing 11.5 seconds of CPU time being used over 22 minutes of real time, looks like the difference is in I/O speed. Which is surprising if you're using EBS storage since EBS is not particularly fast, but I think that even the instance store storage is backed by spinning hard drives so I'd expect your SSD's to be much faster.
Oct
24
comment Cannot install rsync (unable to create…Input/output error)
My first guess would be a disk I/O error. Check dmesg: dmesg | tail -30
Oct
24
comment A shell script that never dies
Since he wants the script to run every 5 seconds, Cron won't run it often enough. But he could invoke the script every minute and have it check to see if it's already running and exit immediately if it is. That way the script would only be dead for at most a minute before cron starts it up again.
Oct
24
comment A shell script that never dies
If the "do whatever" task hangs, this runs the risk of running out of processes or memory on the machine. And if the script is killed while it's sleeping, it won't have a chance to invoke itself again so it will stop running.
Oct
24
comment Copy of full swap file is empty
Sure, the swap file is just a normal file, so you can copy it or open it and read it just as you described. Try running "strings" on it to quickly scan the entire file to printable strings: sudo strings /mnt/swap -- you just can't be certain where the blocks in the swap file came from.
Oct
24
comment Copy of full swap file is empty
Normally, only the least recently used memory blocks are paged out to the swap file -- unless your computer is very memory constrained, this probably won't include your browser history (which is accessed fairly often by the browser) -- your swap file probably contains blocks allocated by long running daemons that haven't been read in a long time.
Oct
24
comment Copy of full swap file is empty
Why do you need to access data in the swap file? Since you don't really know which blocks were paged out, maybe all zero-filled blocks were paged out (though I'm surprised you don't see any non-zero data at all, like block pointers or other data structures). Accessing the swap file read-only should not be a problem.
Oct
24
comment Running tcpdump, tee and scp
Is it possible that you have one of the commands running in the background or in another terminal window?
Oct
24
comment Running tcpdump, tee and scp
I'm not sure which of the command lines I provided you're using, but none of them should be appending to the file. "tee" will overwrite the output file with each run, and the ">" operator will also overwrite the file. Can you give more details? Are you running on Linux?
Oct
23
comment Why is wc so slow?
Ahh, but a simple counting of characters, words, and lines is less computationally complex than computing an MD5 checksum. At least, if not for handling multibyte character sets. That's why I was surprised that md5sum ran much faster.