Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    Your answer:
    ls -lha

    Correct answer:
    ls -lah
Oh dear.


there is also ls -lh -a, ls -l -a -h and so on. I am going to solve this by adding an option in the future to activate the regex if the user doesn't want to memorize a single pattern. Thanks a lot for mentioning it. Regards


Why not do it by default? Why do you believe you can choose one "right" pattern?

Also:

Questions repeated multiple time within single session.

  Question: Write the command that clears the terminal
  command line screen and shows it as new
  Your answer:
  reset
 
  Correct answer:
  clear
"Clear" will not fix terminal in some cases. Maybe do not ask for "and shows it as new" and note you only want to remove current text?

  Question: Write the command that you use
  to move into your home directory '~'
  Your answer:
  cd
  
  Correct answer:
  cd ~


Question: Write the name of the standard subdirectory of the root directory which contains references and files for the devices.

Your answer: dev

Correct answer: /dev

Edit: Also

Question: Write the command that shows a text 'hello world' in the console without moving to a new line after executing the command

Your answer: printf '%s' 'hello world'

Correct answer: echo -n 'hello world'


I also got a similar result with this: Question: Write the command that reads the file that has the name (text.txt) and shows only one page each time you hit space and it allows you to explore the file back and forward.

Your answer: less test.txt

Correct answer: less text.txt


echo -n hello world considered wrong as well.

Also

Question: Write the command that you use if you finish working with the terminal and you want to log out from the current session.

Your answer:logout

Correct answer:exit


I got bit by that as well. I think testing common arguments is useful, but I wonder if it would make more sense to limit to a single argument. That would eliminate the need to handle permutations, and it would also keep the questions simpler.


I think to do this properly you need to implement the argument parsing the command is doing; e.g., use getopt(3C). After all, "ls -la -h --" is valid too.


Not all unix utilities use getopt.

Clearly the correct way to implement this is to run each command in a short-lived container and check the output matches what's expected. For things like the pager questions, it'll need to implement a full vte and vte comparison, so that should be fun.

For bonus points, one of the options to emulate linux in the browser could be used to do that more securely and without the need for a service... though the load time might increase by several minutes or hours.


> Clearly the correct way to implement this is to run each command in a short-lived container and check the output matches what's expected.

I'm not sure it is clearly correct. Some commands don't produce output, `mkdir` and `cd` for example (the first two in the animation). Furthermore they'd have to blacklist `echo` and other ways to produce the output against the spirit of the exercise... until an answer is, say, `echo $?` - at which point you'd require a preceding command exiting in a suitable way in order to keep the "just execute it" approach workable.


> though the load time might increase by several minutes or hours.

Just a few seconds on my humble E480 using Firefox: https://bellard.org/jslinux/vm.html?url=https://bellard.org/...


You can just put the flags in a set and test for set equality.


I got hit by auto correct on my phone and answered like this:

Question: Write the command that clears the terminal-command line screen and shows it as new Your answer:Clear Correct answer:clear


This is what is supposed to happen. UNIX-based terminals are case sensitive.


Site dev should still be able to turn off the autocomplete functionality?


It's practice for your interview skills. If you're on a job interview, and you say 'ls -lha' when the interviewer is expecting 'ls -lah', chances are good you will be marked wrong, and may be passed over in favor of a candidate with "stronger command line skills".


But neither of those options is more or less correct than the other; there is no way to know which a strict (but apparently unqualified!) interviewer is going to prefer.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: