- Modify current username
- Add user and then modify its username
- Determine the user account
You need to have Linux running on the virtual machine configured on your system. When you install Ubuntu, it requires information like username and password. After providing this information, you will be able to access all the applications and have the privilege to use them.
Modify Current Username
Step 1- User Description: To change the current username in Linux, we use the command to know about the current user and directory. “Whoami” is used to display the username, and “pwd” is used to display commands used to outright the execution. The third command, “gnome-session-quit” is used for logging out from the current account in the system.
After the above command, the system will prompt a message to log out or it will automatically quit from the system.
Step 2-Enter in the command shell: When the login page is displayed, type keys Ctrl+alt+f1 then a command prompt will appear. The system will demand a username and password for the login.
Step 3-Set password for root: Modify the password for the root user. After providing login details, we will implement the appended command to set a password for the root user.
After this command, we will type the current password of the user. Then, you can input the new password you want. After retyping, you will see that password is updated successfully.
Step 4:Login as root: Now, the user will log in to the system as root. After applying the password, you will see that name is changed from aqsayasin to root. The root is a temporary name.
Step 5-Change username from Aqsa Yasin to aqsay: We will change the root name with our desired one. Once the name is initialized, the home directory name will be altered. Following the change, the user name on the login screen is changed.
# usermod –d /home/aqsay –m aqsay
#chfn –f aqsay aqsay
After login to “aqsay”, go to the terminal and write the three commands we used to execute earlier in this guide to check the description of a user after alteration. By using these commands, you can see that the username is changed successfully.
Add a New User and then Modify the Username
In accordance with modifying the username, one must have a user in Linux. If there is no existence of any user, we will see how the user is created and modified in the command line of Ubuntu. This creation and modification require the following steps:
Step 1-Add user: You will add a user by the following command. “hania123” is the name we want to give to a new user.
After providing the username, you will be asked to enter a new password. After retyping the password, a message prompting a successful update will appear. Password confirmation will allow you for further verifications and knowledge of the description of the user, .i.e. Full name etc. The user doesn’t need to enter all details, and you can skip it by pressing the “enter” key. The system will confirm the given information by pressing “y” to continue.
Step 2-Identification: After completing the description process, we will log out from the system to ensure the user’s presence on the homepage of Ubuntu.
Step 3-Modification: Moving forward, we will modify the root name of the directory with the help of the below-cited command.
After modifying the user, you will now want to see all users created in Ubuntu. For this purpose, we will use the “ls” command
Now, you will see the names of the users. Then you will log out from the system. After logging in, you will notice that the root name that has been changed from “Aqsa Yasin” to“zahra123”
Determine the User Account Currently in Linux
To know the currently logged-in user, we will come to know it by using a couple of commands.
The “Who” command will let you know about the identity of the user i.e., name of the current user is “aqsay”.
The same answer is obtained by applying “whoami” as a comparative to “who”. Moreover, the same answer is obtained by echoing the “$user”.
$ Echo $user
One letter word “w” is more effective in giving output in a detailed form. It provides the information of the last 5,10 and 15 minutes, mostly including boot time, etc.
TTY shows the terminal type you are using,:0 means the mouse and keyboard connected with. FROM represent the name of the host. IDLE shows the idle time of the user in the system. [email protected] depicts the time, the user was logged in. JCPU and PCPU represent the joint and process CPU timings. Whereas WHAT shows the current process of the user.
To obtain more details about the user, as we have to know who the user is. The below command is the better way to start.
This command gives us user id (uid), groups of them (gid), and shows the group in which the user has become the member.
If you want to obtain the output of only groups, specific less cluttered view of groups can be obtained.
In the article mentioned above, we have described changing usernames using some set of commands in the terminal and on a simple command-line shell.