Wednesday, 14 August 2013

Use the result of 'whoami' as part of an alias

Use the result of 'whoami' as part of an alias

I am setting up my default .bashrc on my Ubuntu machine that I will soon
be adding more and more users to.
One command that users will have access to is mysql, logging them into the
SQL system on the server. Is there a was yo dynamically update the .bashrc
depending on the username without human intervention?
What I am looking for is to set up an alias for the following:
User Matt will have an alias:
alias sql='mysql -u matt -p'
User Jim will have an alias:
alias sql='mysql -u jim -p'
The mysql username will always be the same as the system username, making
me wonder if there was a simple way to get the output of whoami and use
that as part of the command.

No comments:

Post a Comment