Changing Your Prompt
The environment variable PS1 sets your prompt string for bash. In that string, you
can use \w to print out the current directory. So if you set
your prompt will come back as
Stick this in your bash startup file to make the change permanent (as we saw back
in Chapter 2, Add an Editor and Java , on page 15 ).
You can log out by pressing Ctrl - d or by typing exit . And now you're back to
your local shell.
Admin with Root
On any modern system, an ordinary user doesn't usually have full permissions
to do everything on the system. You usually have to type a password to get the
authority of an administrator on the system. On Windows machines this account
is called Administrator, and on Linux and Mac systems it's called root .
While you can log in directly as root with the appropriate password, that's
usually frowned upon. It's too easy to make a typo and suddenly blow away
half your system. Root is ultimately powerful, and with great power comes
But you still need to be able to execute certain commands as root without
logging on as root. You can do that using the sudo command, which lets you
do as the super user root would do. You preface the command you want to
run with sudo , and it will prompt you for your normal user account password.
Get it right, and then the rest of the command will be executed as root. For
example, here I'm using sudo to run an adduser command to add the user “fred.”
Remote $ sudo adduser fred
User 'fred' added.
This way it allows you to have the full power of root, but only in limited,
controlled, well-known circumstances, and not just logged in as root.
In fact, if your SSH is set up so that it does allow root to log in directly, you
should look up how to disable that feature. That way you have to log in using
your user account and SSH key, and then provide your password via sudo .