Posted over 5 years ago. Visible to the public.

Get the initial username which you used to login to your Linux system

If you need the initial user which you used to login to your Linux system or the time when you login you can do:

Copy
who -m

If you're in a good mood you can also do:

Copy
who am i

or (this is my favorite):

Copy
who mom likes

One purpose of this could be the .bashrc to show different Bash Promts for root to different users:

Copy
if [ `who mom likes | awk '{print $1}'` = "foobar" ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[41;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Author of this card:

Avatar
Kim Jahn
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Kim Jahn to makandropedia