How to Print the User Name on Unix Using Exec
- 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...