Linux User Identifying

LinuxLinuxBeginner
Practice Now

Introduction

Welcome to the not-so-distant future in the thriving sci-fi space city of "Neoterica", where humanity has seamlessly integrated advanced technology into every aspect of life. In this bustling metropolis of glittering skyscrapers and floating vehicles, lives famed science fiction writer, “Nova Eclipse”, known for her captivating novels that explore the depths of human identity within the boundless expanse of the cosmos.

In this lab, Nova has reached out for your help to authenticate the users accessing the mainframe of her new AI-driven typewriter. This machine, affectionately dubbed as "The Scribe", houses her unfinished manuscripts, research materials, and personal notes for the next bestseller. Your mission is to ensure that only authorized users, including Nova, can unlock the secrets within “The Scribe”. The skill you will master is the fundamental Linux command whoami, which will be the key to identifying each user trying to access the system.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux/UserandGroupManagementGroup -.-> linux/whoami("`User Identifying`") subgraph Lab Skills linux/whoami -.-> lab-271445{{"`Linux User Identifying`"}} end

Authenticating the User

In this step, you will learn how to use the whoami command to identify the current user logged into the terminal. This is critical for Nova to ensure only she can access “The Scribe” on her secure terminal. To begin, open your zsh terminal in /home/labex/project and execute the whoami command.

First, ensure you are in the correct directory:

cd ~/project

Next, run the whoami command:

whoami

The execution of this command should output the username of the currently logged-in user. For example, if the user is Nova, it should display nova.

Recording the User Authentication

Now that you've identified the user, Nova wants you to log this identification into a file named user_identification.log.

First, if the file does not exist, create it using the touch command:

touch ~/project/user_identification.log

Then, append the output of the whoami command to user_identification.log:

whoami >> user_identification.log

To verify that the correct information is logged, use the cat command to display the contents of user_identification.log:

cat ~/project/user_identification.log

You should see the username as the output in the log file.

Summary

In this lab, we simulated a real-world scenario where we helped a famous science fiction writer secure her AI-driven typewriter by identifying the system user. Starting with the basics of the whoami command, you successfully authenticated the user and then recorded the authentication in a log file.

While this lab is novice-friendly, its focus on step-by-step instructions and understanding the reasoning behind commands provides a solid foundation for further exploration into the vast universe of Linux and its intricacies.

Other Linux Tutorials you may like