The who command is completely different from the whoami command. As its name suggests, the whoami command prints the user name of the effective user id. Linux whoami command print effective userid, linux unix. The su command is used to run a function as a different user. Dec 12, 20 this command can confirm you that you are logged in using a correct user. You use the whoami command to obtain information on the currently loggedon user, the name of the computer, group and domain membership, and privileges associated with the user. This linux tutorial explains how to use the linux whoami command with syntax and arguments. But, this also restricts the user from running specific commands. Nov 20, 2019 here, were going run the whoami command as the user mary. Users who are new to the linux system can know the username with the help of this command. This linux whoami command tutorial shows you how to display the current users name, with examples and syntax.
Displays your login name without root authority syntax. This command can confirm you that you are logged in using a correct user. The result is exactly the same as the whoami command, so in this example, it would display jacob. This command does not work on the windows xp operating system. The whoami command prints effective userid of the current user. Its purpose is to allow scriptsprograms to identify the current user so that the script can select actions based on who the user is. Here, were going run the whoami command as the user mary.
Who am i is not a valid form of that command, as am i are not valid arguments for who. Oct 09, 2016 this linux whoami command tutorial shows you how to display the current users name, with examples and syntax. How to use the whoami command on linux hostry help center. Jan 07, 2020 the su command is used to run a function as a different user.
Here they run whoami, which prints your username the after su makes su run a login shell. It displays the username of the current user when this command is invoked. Linux whoami command help and examples computer hope. By default it would just run the users shell as an ordinary shell, which wont do all that. The who command differs from whoami in that it provides a list of all users currently logged into the system as well as additional information about each of those users including login times and terminal numbers.
Mar 27, 2020 the result is exactly the same as the whoami command, so in this example, it would display jacob. In this article, we will cover the whoami command as its name suggests, the whoami command prints the user name of the effective user id. Note on the difference between who and whoami the who command will always display the account that you used to login the real user info the whoami command will show your effective user for example, if you login as blammy, the who and whoami commands will display something like this. And of course, because youre using sudo youll be prompted for your password. Let us consider an example to print effective userid. Grep is powerful utility seaches files with given patterns. Linux who command help and information with who examples, syntax, related commands, and how to use the who command from the command line. If used without parameters, whoami displays the current domain and user name. Jan 25, 2014 the author is the creator of nixcraft and a seasoned sysadmin, devops engineer, and a trainer for the linux operating systemunix shell scripting. Its primary function is to read commands that are typed into a console. Who command display all logged in user while whoami not. Apr 08, 2014 the whoami command is available in linux and unix like operating systems. It basically provides information about all users who are currently logged in. Videos can also be accessed from the youtube playlist.
The which command in linux lets users know about the absolute path of command line tools. The command id p is suggested for normal interactive use. Running whoami is the same as running the id command with the. Linux whoami command summary with examples tutorial. Recall from our last video, we created the alias lsd, and that led us to kick off this, our. The response from whoami tells us that the user account running the command is mary. It will show the user name of currently working username in current session. Linux which and whoami command tutorial for beginners. The other answers provide what the command does, but not explain what its purpose is.
The who command prints information about all users who are currently logged in. The author is the creator of nixcraft and a seasoned sysadmin, devops engineer, and a trainer for the linux operating systemunix shell scripting. Linux whoami command help and information with whoami examples, syntax, related commands, and how to use the whoami command from. Released as a tool part of windows xp resource kit, it has made its way becoming the official builtin tool since vista. For example, if you login as blammy, the who and whoami commands will display something like this. However, what if you are only interested in the user who is currently logged in. It is basically the concatenation of the strings who,am,i as whoami. If you try to pipe the output of one command to a second command and the second is a command which works with no arguments, you wont get what you expect. Whoami is a very powerful command utility in windows 7 that easily reveals so much about you as the current user on your computer, including your login name, groups you belong to, privileges, etc.
Linux which and whoami command tutorial for beginners with. Just type the command on shell prompt and it will tell you current user id. Get the latest tutorials on sysadmin, linuxunix and open source topics via rssxml feed or weekly email newsletter. The linux who command lets you display the users that are currently logged into your unix computer system. Otherwise, it reads from a default file location usually. The basic who command with no commandline arguments shows the names of users that are currently logged in, and depending on which unixlinux system you are using, may also show the terminal theyre logged in on, and the time they logged in. The command is followed by options optional of course and a list of arguments.
This document covers the gnu linux version of whoami. Name whoami print effective userid synopsis whoami option. Our thirteenth word, or command to memorize is whoami from the category users whoami allows you to display the current users name. To be an expert in linux first step for a beginner would be to start learning the basic commands. Nov 14, 2019 in this article, we will cover the whoami command.
Whoami command is primarily the concatenation of words who am i. You can find details like remote ip address, terminal details, datetime of login etc. On unixlike operating systems, the who command displays users logged in to the system. To put it another way, who am i asks as question that linux cannot interpret, so, in your case at least, no. The who command will always display the account that you used to login the real user info. It is the easiest way to switch or change to the administrative account in the current logged in session. Factorpad linux essentials playlist covers your first 100 commands with examples. Get the latest tutorials on sysadmin, linux unix and open source topics via rssxml feed or weekly email newsletter.
I am logging in as root in my shell and typing who and this is the output. Print the user name associated with the current effective user id. How to use the whoami command by the linux information. If you use the sudo command without the u option, youll run the command as root. The who command displays the following information for each user currently logged in to the system if no option is provided. Linux whoami command linux whoami command is used to get current logged in username.
The xargs command builds and executes command lines from standard input. It can also show the user id, group id, and groups to which the user belongs. Use it to quickly verify the user as which you are currently logged in. Jun 04, 2016 the linux who command lets you display the users that are currently logged into your unix computer system. In other words, it displays the name of the currently loggedin user.
This command is most helpful with shell scripting to find if the current user is root or not. The command can be used in scripts to verify the name of the user who ran the script. Some versions of linux, like ubuntu, disable the root user account by default making the system more secure. It is probably the simplest command in linux to use. On most linux systems, simply typing whoami on the command line provides the user id. This command is able to display the name of the logged in user. Linux which and whoami command tutorial for beginners with examples xargs. The whoami command is available in linux and unix like operating systems.
Displays user, group and privileges information for the user who is currently logged on to the local system. In laymans terms, it reads items from stdin and executes. On unixlike operating systems, the whoami command prints the effective user id. Use who command is used to find current logged in users in your system along with other useful details. If your version misses this grep utility and then use the below command. Here you are telling unix to search the output of the finger command for the text osu0000 or whatever your username is. To use whoami command, simply run the command whoami. Programmation shell break call cmd command cscript doskey echo endlocal for goto if pause powershell prompt rem setlocal. Standard output is, by default, the display screen, unless redirected to a file, printer, etc. This grep command utility comes with the latest debian and nondebian version by default.
Linux whoami command summary with examples youtube. However, on solaris, you may have to determine the user id, by determining the uid of the user loggedin through the command below. The whoami utility displays your effective user id as a name. What is the function of the whoami command in linux. This linux command is helpful for dbasadmins working on multiple instances to know current username they are logged in. If file is specified, who gathers its information from this file. May 16, 2011 in this tutorial, i will show the very basic linux commands with examples that are frequently used to get you more familiar with the linux command line. When you are switching user, whoami will reports the current user which the owner of the session, while who command will report you the original user before you are switching user. The id command can show more than the current user. Domain1\administrator to display all of the information in the current access token, type. In computing, whoami is a command found on most unixlike operating systems, intel irmx 86, every microsoft windows operating system since windows server 2003, and on reactos.