Find the answer to your Linux question:
Results 1 to 3 of 3
Is there a code you can put that automatically inputs the username of the current user? for example something like $user would automatically indicate "administrator" if that was the name ...
  1. #1
    Just Joined!
    Join Date
    Jul 2008
    Posts
    17

    Is there a way to specify the current username in a script?

    Is there a code you can put that automatically inputs the username of the current user? for example something like $user would automatically indicate "administrator" if that was the name of the currently logged in user?

  2. #2
    Linux User
    Join Date
    Jun 2007
    Posts
    318
    There are a couple of ways.

    Code:
    usr="$USER"
    or

    Code:
    usr="`whoami`"

  3. #3
    Just Joined!
    Join Date
    Dec 2007
    Location
    bangalore
    Posts
    38
    can also use echo $LOGNAME

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...