PWD, Whoami and Hostname commands in Linux  What are they? ▷ 2021

The operation of this operating system is based mainly on Linux commands, that is to say, that from this point on, any type of task that you want to carry out on the system will be executed. This is how they can currently be found Thousands of commands available to Linux users.

If you are starting to take your first steps and are just getting familiar with the operation of this OS, then it is very important that you begin to know what they are Whoami, pwd and hostname commands, these being one of the most used and necessary within this system. In this way, with their help, you can start carrying out various types of tasks on your computer.

Bearing in mind the importance of these three commands and knowing that they are essential for the management of the equipment, here we are going to explain a little more what they are pwd, hostname and Whoami, what they are for and how you can use each of them on your Linux computer, for this, follow in detail everything that we will teach you next in the post.

What are the PWD, Whoami, and Hostname commands and what are they for in Linux?

According to the aforementioned, it is essential that you know each of these commands, since this will allow you to know when you should use each of them according to your needs.

Therefore, here we explain in detail what each of them consists of:

Whoami command

Whoami it’s a Unix-like command, In Spanish this means who I am. It is a fairly simple command that will allow you to print the name of the user who is executing a command, in this case it may be the user to login, username, user identifier, user ID, user identifier, they all mean the same thing. Keep in mind that when you refer to a user you want to indicate to an individual that you are making use of a computer, service or operating system.

But it should also be mentioned that in each system there are different users. In this case, the users belonging to the operating system itself are known as root users, others are aimed at system applications that are those that are responsible for run app services and others belonging to physical users. Therefore, it can be said that a user can be both a person, like a program or as a machine, this will basically depend on the action that is being executed.

Hostname command

In computing it is known by the name hostname or host to anyone who receives or is assigned to a device that is part of a networkThis way you can be able to distinguish yourself from the rest. In the same way it allows me to locate others, allowing what they are data transfers within a network, you can freely select the hostname.

On Unix operating systems and all its derivatives like GNU / Linux there is a command called hostname, it is a command line software “CLI” and which aims to allow the user to reset, change and obtain information from the host name of a computer. By default and according to Standard of FHS hierarchies, the host names of a team are stored in the file /etc/hostname, it can be modified by a text editor and the necessary permits.

Pwd command

Print Working Directory or as it is also known pwd, is a command of Linux and currently one of the most used by administrators of this operating system. The same works on Linux and others operating systems such as UNIX, this is a built-in shell command that is available in ksh, Bash, Shell, Korn, among others.

East pwd command aims to print the name of the current working directory with the full path started by root (/). Current working directories are those that are operating commands like cat, ls or cd using bash, zsh or Korn Shell.

Learn step by step how to use these commands in Linux

Bearing in mind the concept of each of these commands and the function that each of them performs in the Linux operating system, it is very important that you can also know how to apply them in your day to day.

To do this, follow in detail each of the methods that we will teach you below:


Being able to execute this command in Linux is an easy task, although many times it may seem like something very tedious, to do this, follow the steps that we are going to teach you below:

  • The first thing you should do is enter the terminal the command pwd(opciones).
  • In the case of the command pwd It has different options that will allow you to use it in different ways, although it is also possible to use it without applying any arguments. According to this, here we are going to show you the most basic options of this command, to find the list of pwd options you must write the following line in the terminal: pwd-help.


  • -L: Aims to print the value of $ PWD if you name the current working directory, it can also be said to print or display the current working directory. Even without the –L and just by typing the pwd in the terminal you can get the same results.
  • -P: In this case it prints the physical directory without symbolic links, the symbolic links they are a guy in special file which allows you to create a shortcut to a file or points to another file. In order to print the physical directory without symbolic links, you must enter the following command line: pwd –p
  • It can be assumed that you have used the command cd repeatedly and you want to know what your current working directory is.

In order to find out this, you need to do it through the following line:

After applying both commands you will have the opportunity to know which one is the address of your current working directory.


As already mentioned earlier in the post, the whoami command it allows you know the name of the user who is running a task.

Therefore, if you want to know the name of the user who is currently in session, you must perform each of the following steps:

  • The first thing will be to enter the terminal Whoami’s command.
  • This command only has two options, keep in mind that both options are only informative for which they don’t add any kind of function to whoami. In this case it is the option of “Help” and “version”.
  • In the case of “Help” allows you to get help that is directly related to the use of whoami, When executing the parameter together with the command, the following output will be shown:


  • There you will have the opportunity to observe how to use it, as well as a brief description of whoami, all the options you have and who maintains the software.
  • While with whoami’s version like any command, it takes care of run using command console, as all software has versions that are being updated by the developers, they are also responsible for adding improvements to the functions. In order to know the whoami version that you are using you must use the following command line: whoami –versión.


  • In this image it can be seen that whoami’s version with which it is working is 8.30.


To be able to use this command in Linux it is very easy, for this you simply have to follow each of the steps that we are going to indicate below:

  • The first thing you should do is run the man command in the terminal followed by the command hostname, it will be as follows: man hostname.


Later you must analyze and test each of the options that this command has at your disposal and which we show you below.

Host name

Keep in mind that hostname It is the name assigned by default or freely to a device by the network. In this case the directory where it is hosted is /etc/hostname for what you owe apply the following command line: cat /etc/hostname.

To be able to modify it you just have to use your favorite text editor indicating the path mentioned above, editing this file can only be run with administration privileges, for this it will be necessary that you apply the following route: sudo nano /etc/hostnameHere you must delete the existing name and enter the new name. Then you go to save changes, in this way you will modify the hostname of your device.


When run directly the hostname command the host name of the computer in session will be printed on the screen. In this way you will be able to obtain the same result as when we previously executed the order cat/etc/hostname.

Configured IP addresses

In the case of devices connected to a network, they can have one or more network interfaces configured and in the same way they can have several IP addresses per interface. Fortunately, the hostname command allows you to view the IP addresses that are configured there on the host through the parameter -i and there you must execute the command line: hostname –i.

After this you will see in the image how much IP addresses you have in each of your interfaces configured in the network, mostly if your equipment is for domestic use you will only have an interface and an IP address.

Change hostname with hostname

As has been mentioned throughout the post, the hostname of a computer can be modified editing the file /etc/hostname. But when using the hostname command you will also be allowed to make the modification, for this you must execute the following line: hostname nuevo_nombre.

To be able to modify it you can run hostname and pass the new host name as a parameter, but to be able to execute a change in the content of the directory /etc/hostname even indirectly, it must be run with administrator privileges, for this insert the following line: sudo hostname IPAP. In order for the changes to be made correctly, it will be necessary to reboot the system. There you can run hostname and see what the host name has been replaced by the new name.

Hostname version

Like any command, hostname also has a version, to be able to know it you simply have to execute hostname –v and there you will be able to know which version you are working with.

If you have any questions, leave them in the comments, we will answer you as soon as possible, and it will also be of great help to more members of the community. Thanks! 😉

Nely zambrano

Author: Nely Zambrano

I have extensive experience in the technological field, my specialties are graphic design, social networks and Digital Marketing. Windows and Android are my specialty.

You may be interested:

Leave a Comment