How to Print the User Name on Unix Using Exec

104 222
    • 1). Log in to the UNIX computer in text (shell) mode, using your regular account.

    • 2). Type the following command into the shell:

      exec id > ~/myUserName.txt

      Press "Enter." The shell will transfer control to id; id, in turn, will print the user name and exit.

    • 3). Log in in to the computer again as your regular user. Check that exec indeed printed out the user name by typing the following command into the shell:

      cat ~/myUserName.txt

      The user name will be listed as part of the output of the cat command, immediately after the "uid=" heading.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.