Posted on 2013-09-26
Medium Priority
Last Modified: 2014-10-15

we use in windows

what is it's equivalent in linux..

Please help.
Question by:jcob_l
LVL 31

Expert Comment

ID: 39525977
LVL 20

Expert Comment

ID: 39526056
well to be exact 'whoami' is a command.
If you want exactly the same thing you have above (a system veriable which holds the current  username) then it would be

echo $USER

(note the capital letters)

Author Comment

ID: 39526072
[root@server2 dbs]# echo $USER
[root@server2 dbs]#
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

LVL 20

Expert Comment

ID: 39526092
yes.  See the word 'root' at the start of lines 1 and 2.... thats your username.
See the '#' at the end of those lines.... that also means you are 'root'
root is your username.

Is that not what you want ?
LVL 20

Accepted Solution

edster9999 earned 2000 total points
ID: 39526099
if you started as a different user and then did 'su' or 'sudo' to become root
and you want to know what is the username beneath root
then you could use the command
or to get it as a variable you can echo, you could do something like :

echo "Your name is `logname` "
LVL 44

Expert Comment

ID: 39527652
Not related (i.e. please no assist for this), but if you're new to Linux something you should be aware of... the more stuff you do at root level, the more ownerships and permissions will get tied to it until eventually your setup won't run withOUT using 'su -' for root (most distros by default no longer allow "logging in" as root for just that reason).

So it's much better to do 'su' + root password, or put the user in the /etc/sudoers file and use 'sudo' + user password (as edster9999 mentioned in http:#a39526099).
LVL 13

Expert Comment

ID: 39552219
Check $PS1

answer is there itself.

Author Closing Comment

ID: 40381763
yes that is correct with sudo.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Welcome back to our beginners guide of the popular Unix tool, cron. If you missed part one where we introduced this tool, the link is below. We left off learning how to build a simple script to schedule automatic back ups. Now, we’ll learn how to se…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question