Linuxips
  • Home
  • Linux
  • Debian
  • Ubuntu
  • Fedora
  • Arch Linux
No Result
View All Result
Linuxips
  • Home
  • Linux
  • Debian
  • Ubuntu
  • Fedora
  • Arch Linux
No Result
View All Result
Linuxips
No Result
View All Result
Home Commands

Whoami Command in Linux

admin by admin
September 1, 2022
Reading Time: 2 mins read
0
Whoami Command in Linux

In this tutorial, you will learn how to use the whoami command with examples. The whoami command allows Linux users to see the currently logged-in user. The output displays the username of the effective user in the current shell. Additionally, whoami is useful in bash scripting to show who is running the script.

Contents hide
1 Prerequisites
2 whoami Command Syntax
3 whoami Command Options
4 whoami Command Examples
4.1 Basic whoami Usage
4.2 Verify the Effective User
4.3 Check an Account for Sudo Permissions
4.4 Check whoami Version
5 Conclusion

Prerequisites

  • A system running Linux.
  • Access to the command line/terminal.

whoami Command Syntax

The syntax for the whoami command is:

$ whoami [option]

whoami Command Options

The whoami command comes with the two following options:

 

OptionDescription
–helpShows a help message and exits.
–versionShows the version information and exits.

whoami Command Examples

There are several different ways to use whoami. The examples below explain common use cases of the whoami command.

Basic whoami Usage

When running whoami without any options, the output shows the name of the currently logged-in user.

To test the command, open the terminal and enter:

$ whoami

The output prints the name of the effective user.

whoami Command

Verify the Effective User

When you have more than one account, use whoami to verify the username after switching to a different account.

For example, switch to another user with the su command:

$ su [account name]

Then, run the whoami command to verify the effective user:

whoami command in Linux

Since you executed the command as a different user, the terminal shows another username.

Check an Account for Sudo Permissions

Use the whoami command to check if a user has sudo privileges. To do this, execute the command with sudo and provide the password:

$ sudo whoami

sudo whoami command in linux

Check whoami Version

To check the version of the whoami command, execute:

$ whoami --version

whoami Version Check Command

Conclusion

After following this tutorial, you should know how to use the whoami command to find the name of the effective user on a Linux system. You can use it as you want. Enjoy!!!

Related Linux Tutorials:

  • How to Install Cisco Packet Tracer on Ubuntu.
  • How to install Tweak Tool on Ubuntu 21.04.
  • ZSH to BASH | How to Install ZSH on Ubuntu.
  • How to Install Ubuntu.
  • ls Command in Linux
  • pwd command in Linux
ShareTweetSendShareShare
Previous Post

How to Install Arch Linux [Step by Step Guide]

Next Post

How to Install VMware Tools on Arch Linux

admin

admin

Linuxips is a Linux blog that publishes articles and tutorials about server operations, installations, new techniques and Linux security.

Related Posts

Install ZSH on Arch Linux
Arch Linux

How to Install ZSH on Arch Linux

January 6, 2024
How To Use AppImage in Linux
Linux

How To Use AppImage in Linux [Complete Guide]

April 2, 2023
How To Install uGet Download Manager On Ubuntu
Linux

How To Install uGet Download Manager On Ubuntu

March 8, 2023
Linux Files and Directories
Linux

Linux Files and Directories

March 3, 2023
How to Create Files With Passwords in Linux
Linux

How to Create Files With Passwords in Linux

February 27, 2023
pwd Command in Linux
Commands

pwd command in Linux

November 6, 2022

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

You might also like

Install ZSH on Arch Linux

How to Install ZSH on Arch Linux

January 6, 2024
How to Install ZSH on Kali Linux 2024.1

How to Install ZSH on Kali Linux

January 5, 2024
How To Use AppImage in Linux

How To Use AppImage in Linux [Complete Guide]

April 2, 2023
How To Install uGet Download Manager On Ubuntu

How To Install uGet Download Manager On Ubuntu

March 8, 2023
How to Install ZSH on Ubuntu 22.10

How to Install ZSH on Ubuntu 22.10

March 7, 2023
Linux Files and Directories

Linux Files and Directories

March 3, 2023

© 2024 Linuxips.com - Linux Tips, Tricks and Tutorials.

  • Home
  • Web Stories
  • Privacy Policy
  • Contact Us
  • Disclaimer
No Result
View All Result
  • Home
  • Linux
  • Debian
  • Ubuntu
  • Fedora
  • Arch Linux

© 2024 Linuxips.com - Linux Tips, Tricks and Tutorials.