I tried:

who & pwd and it output the result of pwd output: /root.

May I know if I am right?

  • There's no motivation for this question (and no question in the Question body); why do you need the output of two commands with one command? You fake it by writing a script that executes those two commands, then call the "one" script, but this sounds like it's a homework assignment to teach you about command-lines. Perhaps you could lay out what you've learned and why you think that we're the right people to tell you if your homework is correct. – Jeff Schaller Nov 15 '18 at 15:03

The & operator has nothing to do with executing two commands, see this question.

In order to execute two distinct commands on the same line, use the appropriate separator ;:

who; pwd

Not the answer you're looking for? Browse other questions tagged or ask your own question.