One of the benefits of the Virtual I/O server is the predictability of its commands. Commands to list something start with ls and device names are prefixed with the pretty guessable -dev
In fact, I once wrote an article in praise of the VIOS command line interface (CLI).
But [language warning] boy, oh boy, do I find it confusing remembering whether I'm using the restricted shell (logged in as the user padmin) or switching to the full-blooded, no decaf, root access. You do that using the command oem_setup_env (as anyone would have guessed).
Jumping the Gate of the Restricted Shell
Now maybe, like me, you avoid damaging your VIOS environment by avoiding that oem_setup_env command. But just between you and me (and just about every other AIXer I've ever met), sometimes it's nice to have, isn't it? Like when you're playing with disk device drivers that you simply can't install or configure in the restricted shell.
It can be very frustrating remembering if you're padmin (restricted) or effectively root (oem_setup_env), so when you're logged in as padmin and run a typical root command, and then get an error, you're likely to set up an alias like this in /home/padmin/.profile
alias aix="ioscli oem_setup_env"
or, in recent versions of the VIOS (as of August 2015), simply this:
Not sure which one to use?
Type the following "type" command to identify which version of oem_setup_env is valid:
Thanks to lillracksingen for the comment.
And then log in as padmin and run aix every time. Full shell, here we come!
Except you're not supposed to do that!
If you really, really, really have to go to the full shell, just for one command, there's another way. It's insanely obvious, which is probably why it took me 9 years even to think about it and then I didn't think about it at all. It was sent to me by John Tucker, an AIX enthusiast in the US and a reader of this blog. So a tip of the Akubra hat to you, mate.
when you want to run a command as root, but you're logged in the restricted shell as padmin, run the command as padmin but pipe it to oem_setup_env
So, if you want to run a command such as uptime to see how long since the last reboot, there's probably a few ways of doing this in the restricted shell, but good luck working out what they are.
You run uptime and you get a friendly message to tell you that you made a mess of it.
Sure, you could do the oem_setup_env thing and then run uptime, then exit (of course) to take you back to the restricted shell, but why not just try using the pipe?
Here's how it looks (wrong, then right):
In case you can't see the screen shot, here is the text:
$ uptime rksh: uptime: not found. $ echo "uptime" | oem_setup_env 06:01AM up 8:06, 1 user, load average: 0.52, 0.79, 0.81
Isn't that nice? It still doesn't exactly protect you from jumping the wall of the restricted shell and then going wild wiping out your VIOS, but at least it's keeping you more or less on the right side of the law.
Thanks again to John Tucker. I couldn't afford to send you an Akubra, John, but here's a link to the Wikipedia article on this iconic Australian headwear.