News for hackers. Stuff that matters.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by YesThatTom2 on Thursday January 02, 2014 @09:48AM (#6999765)
I have been unable to think of one for Linux system administrators. :-(
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by octo_t on Thursday January 02, 2014 @09:59AM (#6999812)
I've found 'list 10 two-letter linux commands and their use'

They don't actually have to think of 10, but their answer can show what they've actually had to do on a *nix system. Its also lets you prod them with questions like 'how might I get disk usage' or if they mention dd, ask them how they use it, what its good for etc.

Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by icebraining on Thursday January 02, 2014 @10:40AM (#7000053)
I was surprised I could actually think of 10. Using both dc and bc seems like cheating, though ;)
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by octo_t on Thursday January 02, 2014 @12:05PM (#7000610)
To be honest, a reason I like it is that if they free-think and say 'what about sed, oh of course thats three characters', shows what they know. Also whether shell-built ins count too.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by icebraining on Thursday January 02, 2014 @12:48PM (#7000884)
I'd grant bonus points for remembering the standard text editor. Or dismiss everyone who didn't!
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by aaronem on Thursday January 02, 2014 @10:09AM (#6999873)
I've seen a good one -- actually got asked it in a phone screen I did last year:

"How would you recursively delete all files with extension 'mp3' in a given directory tree?"

The (simplest) correct answer (I know) is

    find /path/to/wherever -name "*.mp3" -exec rm -fv {} \;
Maybe that's more of a pons asinorum, I suppose, but then isn't a pons asinorum precisely what a fizzbuzz question is meant to be?
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by chaosphere2112 on Thursday January 02, 2014 @11:08AM (#7000230)
Alternatively, you can just use

    find /path/to/wherever -name "*.mp3" -delete
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by icebraining on Thursday January 02, 2014 @10:36AM (#7000033)
The simplest would be

    find /path/to/wherever -name "*.mp3" -delete
This works at least in GNU find and FreeBSD.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by aaronem on Thursday January 02, 2014 @10:40AM (#7000055)
At which point I'd argue that using -exec with an appropriate command is simpler, in the general case, than using one of find(1)'s many, many, many twiddly little command-line arguments. Granted, -exec spawns a process per file, but processor cycles are cheaper than brain cycles, &c., &c.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by dasmoth on Thursday January 02, 2014 @11:02AM (#7000203)
That seems like a recipe for holy-war between those who kind-of like xargs and those who think find | xargs is an abomination.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by presidentender on Thursday January 02, 2014 @10:43AM (#7000073)
Can't we

    cd /path/to/wherever
    rm -rf *.mp3

?
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by aaronem on Thursday January 02, 2014 @10:44AM (#7000083)
You have stumbled squarely into the tripwire implicit in that question; "rm -rf *.mp3" ignores directories whose names don't end in ".mp3", and deletes those whose do.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by code_duck on Thursday January 02, 2014 @11:31AM (#7000393)
It's supposed to be recursive. That would only delete the files in the current directory, not subdirectories as well.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by presidentender on Thursday January 02, 2014 @03:19PM (#7001985)
-r is the 'recursive' flag.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by aaronem on Thursday January 02, 2014 @04:16PM (#7002343)
Yes, but it doesn't do what you think it does. Feel free to try it for yourself if you don't believe me.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by falsedan on Thursday January 02, 2014 @11:01AM (#7000195)

  find path -iname "*.mp3" -print0 | xargs -0 rm -fv
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by aaronem on Thursday January 02, 2014 @11:06AM (#7000222)
I'd give half marks for this, because it optimizes (meaninglessly) for processes, at the risk of ending up with "rm: Too many arguments" in a directory tree containing a sufficiently large number of MP3 files.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by tene on Thursday January 02, 2014 @01:53PM (#7001360)
xargs knows the maximum command line length, and will invoke the program more than once if necessary. One of the points of xargs is to break up invocations of a program into chunks of arguments that fit in one maximum length command line.

  xargs reads items
  from  the  standard  input, delimited by blanks (which can be protected
  with double or single quotes or a backslash) or newlines, and  executes
  the  command (default is /bin/echo) one or more times with any initial-
  arguments followed by items read from standard input.

  --max-chars=max-chars
  -s max-chars
         Use at most max-chars characters per command line, including the
         command  and  initial-arguments and the terminating nulls at the
         ends of the argument strings.  The largest allowed value is sys‐
         tem-dependent,  and  is  calculated as the argument length limit
         for exec, less the size of your environment, less 2048 bytes  of
         headroom.   If this value is more than 128KiB, 128Kib is used as
         the default value; otherwise, the default value is the  maximum.
         1KiB is 1024 bytes.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by aaronem on Thursday January 02, 2014 @04:54PM (#7002586)
Well, how about that! It could be that I formed my opinion regarding xargs before it got that smart, or it could be the old Red Hat boxes on which I mostly learned my craft didn't bother compiling in that capability. Either way, I'm glad to know about it now, and thank you very kindly for pointing it out to me!
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by falsedan on Thursday January 02, 2014 @07:31PM (#7003475)
breaking up the input into multiple executions is feature #1 for xargs and has been present since PWB UNIX in 1977
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by aaronem on Thursday January 02, 2014 @10:50PM (#7004042)
Then perhaps I'm thinking of "rm -f `find ...`". In any case, thanks for pointing it out; I learned something new today.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by falsedan on Thursday January 02, 2014 @04:19PM (#7002374)
Well put
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by falsedan on Thursday January 02, 2014 @12:04PM (#7000604)
zero marks for not understanding how xargs works
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by aaronem on Thursday January 02, 2014 @04:55PM (#7002592)
And a resounding "no hire" for privileging snark over substance.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by falsedan on Thursday January 02, 2014 @07:19PM (#7003415)
wouldn't take an offer from a place where sysadmins wouldn't read a man page to verify a candidate's answer
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by EvanAnderson on Thursday January 02, 2014 @10:07AM (#6999856)
I've been a contract sysadmin for a long time. In a former "life" part of my work was doing phone screens and job interviews for contract sysadmin candidates.

If a candidate's answer to a nonspecific troubleshooting scenario didn't begin with (or contain very close to the beginning of the answer) "look at the logs" I'd bump them. Anybody whose problem-solving methodology doesn't including gathering pertinent data early in the process isn't somebody I want "solving" problems for me.

Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by Ologn on Thursday January 02, 2014 @10:14AM (#6999898)
The best question I have is "Describe the power on of a RHEL x86 system in as much detail as possible from beginning to end, each step of what happens". It is open ended but can tell you a lot. You can get very fine grained, down to the hardware signals which take place before FFFF0000 is executed.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by snorkel on Thursday January 02, 2014 @10:11AM (#6999890)
"You need shell access to a remote system using ssh. What file would email to the admin to grant you access using ssh?"

You'd be surprised of how many supposed Linux admins have no idea how to setup ssh logins, which says a lot about the depth of their experience.

Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by hnriot on Thursday January 02, 2014 @10:33AM (#7000012)
I'd make this a requirement of developers too, some basic unix skills goes a long way as a developer.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by raverbashing on Thursday January 02, 2014 @10:27AM (#6999975)
1 - How to connect to a server using SSH without a password

2 - How would you check if $DATABASE is running and how would you start it if it wasn't. Bonus points: how do you make it start automatically at next reboot

3 - Show me the processes using the most CPU

Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by sov on Thursday January 02, 2014 @02:34PM (#7001679)
Is 1. really that trivial? If I recall there's some really weird convention about usernames across both platforms (assuming *nix) having to be identical, in addition to fiddling around with the RSA keys.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by hacknat on Thursday January 02, 2014 @10:03AM (#6999838)
Here's a couple:

Grep a current running process.

Grep x file and copy it.

You'd be surprised how many "Sys Admins" I've interviewed who can't do basic things.

Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by ambiate on Thursday January 02, 2014 @09:56AM (#6999801)
Ask about disaster recovery, backups, penetration testing, what to do if a database/webserver breach occurs, or any form of generic networking/routing.
Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by bob_george33 on Thursday January 02, 2014 @10:02AM (#6999834)
Not sysadmin specifically, but when I was working as a computer technician, questions we would ask to scope out the skills of people were along the lines of:

Q: "Something you have no experience with has broken and won't do a basic function, how will you go about fixing it?" A: Research, ask someone else etc.

Q: "X is missing their password for a system we have no admin rights on. How are you going to fix this?" A: Recovery Tools. Format device and set it up again. Use JS/Developer tools to get it in plain text from the browser.

Re:Ask HN: What's your speciality, and what's your "FizzBuzz... by darkrho on Thursday January 02, 2014 @10:08AM (#6999867)
Years ago I've been asked: There is a file named "-foo", how do you delete it?