1
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.
Why call the command
whoami
when you can use theUSER
environmental variable? – justbrowsing – 2013-08-15T05:59:16.2601`` is deprecated. you may consider to use $(whoami) instead. Also there is no need for ; at the end. Just write everything in one line. A function might be more flexible. – l1zard – 2013-08-15T07:05:08.010