echo %logonserver%

which domain controller the user currently logged onto

The command line can be accessed by using the cmd command which will open a command window with a DOS interface. The command line is a throw back to the early days of computing before there was a Windows interface.
Sample Output

By: 0disse0
2011-06-13 09:52:51

These Might Interest You

  • In my work environment, we log onto the servers as our user ('user', in the sample ouput), and 'sudo su - root' to other accounts. This trick allows us to return the account name we logged in as -- and not the account name we currently are ('root', in this example). Using this trick, you can build other commands: Set your CVSROOT env variable to your account name: CVSROOT=$(who am i | awk '{print $1}') SCP a file to another server: scp file.txt $(who am i | awk '{print $1}') This works out great in my environment, as we can include this in our documentation and make the comands more easy to copy/paste for different users, and not have to set all sorts of variables, or modify the docs for each user. whoami gives you the name of the user you currently are, not the user you logged on originally as. who gives you a listing of every single person logged onto the server. who am i gives you the name of the user you logged on as, and not who you changed to with su. Look at the following scenario: whoami user su - # whoami root # who am i user pts/51 2009-02-13 10:24 (:0.0) whoami != who am i Show Sample Output

    who am i
    ozymandias · 2009-02-20 16:26:11 9
  • ### for ADUSER in $(wbinfo -u --domain="$(wbinfo --own-domain)" | sort); do WBSEP=$(wbinfo --separator); ADUNAME=$(wbinfo -i "$ADUSER" | cut -d ":" -f5); UINFO=$(wbinfo -i "$ADUSER" | cut -d ":" -f3); GINFO=$(wbinfo -i "$ADUSER" | cut -d ":" -f4); SIDU=$(wbinfo -U "$UINFO"); SIDG=$(wbinfo -G "$GINFO"); USERID=$(wbinfo -s "$SIDU" | sed 's/.\{1\}$//' | cut -d "$WBSEP" -f2); GROUPID=$(wbinfo -s "$SIDG" | sed 's/.\{1\}$//' | cut -d "$WBSEP" -f2); echo -e "$ADUSER:$USERID:$ADUNAME:$GROUPID"; done | column -tx -s: ### Show Sample Output

    for DOMAIN in $(wbinfo -m); do WBSEP=$(wbinfo --separator); ADSERVER=$(wbinfo ... (Read description for full command)))
    jaimerosario · 2014-06-13 21:03:23 0
  • Only from a remote machine: Only access to the server will be logged, but not the command. The same way, you can run any command without loggin it to history. ssh user@localhost will be registered in the history as well, and it's not usable.

    ssh user@hostname.domain "> ~/.bash_history"
    maxadamo · 2012-07-09 14:29:22 0
  • These are the parameters to ldapsearch (from ldap-utils in Ubuntu), for searching for the record for Joe Blogg's user. sAMAccountName is the LDAP field that ActiveDirectory uses to store the user name. 'DOMAIN\Joe.Bloggs' where "DOMAIN" is the the active directory domain. Othewise you could use "CN=Joe.Bloggs,DC=example,DC=com" instead of "DOMAIN\Joe.Bloggs" Show Sample Output

    ldapsearch -LLL -H ldap:// -b 'dc=example,dc=com' -D 'DOMAIN\Joe.Bloggs' -w 'p@ssw0rd' '(sAMAccountName=joe.bloggs)'
    greppo · 2009-06-11 13:07:11 2

  • 0
    net user user_name new_password /domain
    shawn_abdushakur · 2014-03-17 14:22:52 0
  • Short and sweet command. This command is also useful for other information such as what IP address a particular user logged in from, how long had they been logged in, what shell do they use.

    haivu · 2009-03-24 16:03:28 1

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: