Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

11 votes
2 answers
26110 views
who, whoami, and "who am i"
I can understand the commands `who` and `whoami`, but what exactly happens when I type: who am i and who am I am on Ubuntu, nothing happens after them! Why doesn't Linux / UNIX reply with an error message (something on the line of "unknown arguments" for `who`), or just reply with the output of `who...
I can understand the commands who and whoami, but what exactly happens when I type: who am i and who am I am on Ubuntu, nothing happens after them! Why doesn't Linux / UNIX reply with an error message (something on the line of "unknown arguments" for who), or just reply with the output of who?
A. N. Other (211 rep)
Jul 10, 2017, 03:31 PM • Last activity: Oct 21, 2022, 06:48 AM
1 votes
0 answers
1504 views
command whoami and echo $USER are giving different outputs how is that even possible?
If I don't fix this I can't properly run bash scripts that checks whether the $USER is root in an IF statement, because, as it is, the $USER is never root, even when the whoami is the root. No matter if I su to root, I keep being whatever user I was before, at least for the $USER variable. How do I...
If I don't fix this I can't properly run bash scripts that checks whether the $USER is root in an IF statement, because, as it is, the $USER is never root, even when the whoami is the root. No matter if I su to root, I keep being whatever user I was before, at least for the $USER variable. How do I fix this? I have tried setting the variable $USER to be equal to the output of the command whoami on the .zshrc file, but it didnt work at all.
vcedraz- (11 rep)
Aug 25, 2022, 03:52 PM
14 votes
4 answers
23077 views
`who am i` after `su` not showing new user id?
Why is it that when I switch user `su ` and then execute `who am i` is outputs the previous user which I was logged as and not the one I've switched to?
Why is it that when I switch user su and then execute who am i is outputs the previous user which I was logged as and not the one I've switched to?
user1091856 (661 rep)
Nov 16, 2012, 06:40 AM • Last activity: Nov 4, 2021, 05:43 AM
9 votes
2 answers
28413 views
A command that gives username@hostname:pwd
I know that `pwd` gives the current working directory, `hostname` gives the current host and `whoami` gives the current user. Is there a single unix command that will give me the output of whoami@hostname:pwd so that I can quickly paste the output into an `scp` command?
I know that pwd gives the current working directory, hostname gives the current host and whoami gives the current user. Is there a single unix command that will give me the output of whoami@hostname:pwd so that I can quickly paste the output into an scp command?
Hooked (1373 rep)
Nov 20, 2013, 03:36 PM • Last activity: Feb 5, 2021, 02:31 PM
10 votes
3 answers
59170 views
Difference between who and whoami commands
The man page description of `who` command is `who - show who is logged on ` But there exists a similar command `whoami`. The man page description of `whoami` is `whoami - print effective userid ` Can anyone explain what exactly these commands do ? How are they different from each other ?
The man page description of who command is who - show who is logged on But there exists a similar command whoami. The man page description of whoami is whoami - print effective userid Can anyone explain what exactly these commands do ? How are they different from each other ?
narendra-choudhary (858 rep)
Sep 19, 2014, 05:07 PM • Last activity: Dec 14, 2020, 07:33 PM
0 votes
1 answers
3414 views
Why whoami always returning "root"?
After a hack, a dedicated server always return "root" following `whoami` command. Even after a `sudo su myUser` > `whoami` return "root". `myUser` exists on the server, because regarding [this issue][1] `passwd myUser` return `Changing password for myUser.` Furthermore, when installing package on th...
After a hack, a dedicated server always return "root" following whoami command. Even after a sudo su myUser > whoami return "root". myUser exists on the server, because regarding this issue passwd myUser return Changing password for myUser. Furthermore, when installing package on the server, rights are always set as root:myUser. What are the paths, that could lead to a whoami always returning 'root' ?
GuillaumeRZ (103 rep)
May 4, 2020, 05:20 PM • Last activity: May 5, 2020, 08:55 PM
0 votes
0 answers
621 views
In script : ssh and then sudo rootsh root
Can't find the solution. I need in the script - ssh to a server then change to root via `sudo /usr/bin/rootsh -i -u root`. Then make some action then go back and carry on with script... Something like ``` ... ssh -t myserver EOF ... ``` If I do it this way - doesn't work. If done in the way ``` ssh...
Can't find the solution. I need in the script - ssh to a server then change to root via sudo /usr/bin/rootsh -i -u root. Then make some action then go back and carry on with script... Something like
...
ssh -t myserver 
EOF
...
If I do it this way - doesn't work. If done in the way
ssh -t myserver 'sudo /usr/bin/rootsh -i -u root ;whoami'
I can do ssh and then switch to root, but then script wait until session/shell closed.
Ivo Babinec - Leo (41 rep)
Jan 30, 2020, 01:07 PM • Last activity: Jan 30, 2020, 03:39 PM
10 votes
1 answers
3379 views
Different outputs for `w`, `who`, `whoami` and `id`
In command line platforms online, like for instance the one on Codecademy, when I run for cmd in w who whoami id do echo $cmd $cmd echo ========================= echo " " done I get w                   &#1...
In command line platforms online, like for instance the one on Codecademy, when I run for cmd in w who whoami id do echo $cmd $cmd echo ========================= echo " " done I get w                               00:52:54 up 8 days, 14:10,  0 users,  load average: 3.78, 2.98, 2.69       USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT        =========================                             who =========================                                                  whoami                           ccuser                           =========================                                  id uid=1000(ccuser) gid=1000(ccuser) groups=1000(ccuser)      =========================                    Note that only whoami and id output something. When I run the same thing on my computer, I see similar results for all commands. Why doesn't Codecademy display the user for w and who? What's different about these commands?
whoami (103 rep)
Mar 17, 2019, 01:04 AM • Last activity: Mar 17, 2019, 10:50 AM
7 votes
2 answers
10860 views
Using whoami to search for files that mention user
I'm currently working through some exercises to try and improve my shell scripting. The requirements of the script are as follows: >1. It must get the user's name using the `whoami` command and store it in a variable called `username`. >2. It must take a single parameter which is the name of the fil...
I'm currently working through some exercises to try and improve my shell scripting. The requirements of the script are as follows: >1. It must get the user's name using the whoami command and store it in a variable called username. >2. It must take a single parameter which is the name of the file to be searched. >3. It must grep to search the specified file for occurrences of the user's name and print them. This part is relatively simple, and I've used the following to get it working: username=$(whoami) echo 'Enter the name of the file you would like to search: ' read fileName cat "fileName" | grep "$username" However there is a catch, the exercise states the following: > **Note:** for this task there's no need to worry about missing parameters of error checking. The script, apart from shebang and any comments you choose to add, should consist of two lines. How can I reduce this to only two lines?
NigerianWizard (93 rep)
Oct 8, 2018, 10:53 AM • Last activity: Oct 8, 2018, 01:54 PM
34 votes
2 answers
10356 views
Is `who mom likes` a real linux command?
I stumbled across a blog that mentioned the following command. who mom likes It appears to be equivalent to who am i The author warns to never enter the following into the command line (I suspect he is being facetious) who mom hates There is nothing documented about the `mom` command. What does it d...
I stumbled across a blog that mentioned the following command. who mom likes It appears to be equivalent to who am i The author warns to never enter the following into the command line (I suspect he is being facetious) who mom hates There is nothing documented about the mom command. What does it do?
spuder (18573 rep)
Jan 7, 2014, 12:57 AM • Last activity: Jul 20, 2016, 06:55 AM
1 votes
1 answers
1956 views
Using export USER=myName doesn't change the output of whoami
I saw [this example][1] $ whoami MatsP $ g++ -Wall -std=c++0x getenv.cpp $ ./a.out MatsP $ export USER=DonaldDuck $ ./a.out DonaldDuck but for me it doesn't work. I am in a Debian machine. I used `export -p` and indeed the variable changed. I refreshed the `bachrc`, still nothing. How to achiece the...
I saw this example $ whoami MatsP $ g++ -Wall -std=c++0x getenv.cpp $ ./a.out MatsP $ export USER=DonaldDuck $ ./a.out DonaldDuck but for me it doesn't work. I am in a Debian machine. I used export -p and indeed the variable changed. I refreshed the bachrc, still nothing. How to achiece the above? whoami displays the default value.
traveller (111 rep)
Apr 5, 2016, 01:19 PM • Last activity: Apr 5, 2016, 02:15 PM
9 votes
1 answers
11878 views
Difference between logname and $LOGNAME
While reading about environment variables, the one I came across was `LOGNAME`, I'd like to know the difference between this variable and whatever the command `logname` returns - as both of them did differ in what they returned. -bash-3.2$ logname user11 -bash-3.2$ echo $LOGNAME user1 Although, `who...
While reading about environment variables, the one I came across was LOGNAME, I'd like to know the difference between this variable and whatever the command logname returns - as both of them did differ in what they returned. -bash-3.2$ logname user11 -bash-3.2$ echo $LOGNAME user1 Although, whoami returns the same user as LOGNAME -bash-3.2$ whoami user1
Keyshov Borate (1359 rep)
Mar 8, 2016, 12:38 PM • Last activity: Mar 8, 2016, 01:11 PM
0 votes
1 answers
6038 views
$USER != whoami
I'm trying to re-install homebrew on my mac. I get this error: michaels-1856:~ michael.snowden$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ==> This script will install: /usr/local/bin/brew /usr/local/Library/... /usr/local/share/man/man1/brew.1 ==> The...
I'm trying to re-install homebrew on my mac. I get this error: michaels-1856:~ michael.snowden$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install) " ==> This script will install: /usr/local/bin/brew /usr/local/Library/... /usr/local/share/man/man1/brew.1 ==> The following directories will be made group writable: /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 ==> The following directories will have their owner set to tomcat: /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 ==> The following directories will have their group set to admin: /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 Press RETURN to continue or any other key to abort ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 Password: ==> /usr/bin/sudo /usr/sbin/chown tomcat /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 chown: tomcat: illegal user name Failed during: /usr/bin/sudo /usr/sbin/chown tomcat /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 michaels-1856:~ michael.snowden$ It's this line that troubles me: chown: tomcat: illegal user name I googled homebrew "the following directories will have their owner set to", and only found one search result, which was the [homebrew install script](https://raw.githubusercontent.com/Homebrew/install/master/install) My username isn't tomcat, as far as I know. Specifically, this is the line of the script that's giving me trouble: "The following directories will have their owner set to #{Tty.underline 39}#{ENV['USER']}#{Tty.reset}:" The problem, from what I can gather, is that $USER=tomcat, but whoami=michael.snowden michaels-1856:~ michael.snowden$ whoami michael.snowden michaels-1856:~ michael.snowden$ echo $USER tomcat **EDIT** The only thing i found in my ~/.bash* files referencing "tomcat" was something I did to see if tomcat was a valid user after creating this post. michaels-1856:~ michael.snowden$ cat ~/.bash* | grep tomcat chown tomcat test.txt **EDIT** This got resolved, but the solution was really specific to my computer's setup and took a lot of digging.
michaelsnowden (103 rep)
Oct 4, 2015, 12:18 AM • Last activity: Oct 4, 2015, 03:02 AM
5 votes
1 answers
2521 views
What does su - `whoami` command do?
I am running a script in my project and I see this command su - `whoami` I am having a few basic questions: 1. What does this command do ? 2. What is the significance of `` quotes outside the whoami command ? 3. What is - used for ? I know `su` stands for switch user.
I am running a script in my project and I see this command su - whoami I am having a few basic questions: 1. What does this command do ? 2. What is the significance of `` quotes outside the whoami command ? 3. What is - used for ? I know su stands for switch user.
Sachin Jain (153 rep)
Jul 25, 2014, 09:23 AM • Last activity: Jul 25, 2014, 08:39 PM
Showing page 1 of 14 total questions