Guide to Unix/Commands/Multiuser Commands
who
[edit | edit source]who gives information about the users logged into the machine. The information includes the user's terminal, login date ,login time and the location they are connecting from.
Examples:
$ who alice pts/0 Mar 23 08:05 (213.23.423.24) bob pts/2 Apr 10 22:06 (domain.aol.com) carol pts/3 Apr 10 18:34 (space.com)
The option "-w" shows wheter or not a user's tty is accessible with commands like write or talk. + indicates that the tty is accessible, and - that it's not:
$ who -w root - tty3 Jan 19 02:26 koppe - tty4 Jan 19 17:10 bok + pts/1 Jan 19 23:03
Using "who" with two non-option words gives your username. On some systems, this gives your actual username, and using "su" or "sudo" to switch user does not change this name.
$ who am i puffy
On other systems, this gives more information:
$ who am i puffy ttyp2 Oct 27 10:08
Links:
- who, opengroup.org
- who man page, man.cat-v.org
- 20.6 who in GNU Coreutils manual, gnu.org
finger
[edit | edit source]finger finds out information about a user. If the user has created a .plan (several lines) and/or a .project (one line) file in their home directory this will also be displayed.
Examples:
$ finger alice Login: alice Name: Alice Makemerry Directory: /home/alice Shell: /bin/bash On since Sat Apr 10 18:34 (BST) on pts/3 from ip.fakedomain.com 1 hour 25 minutes idle Mail last read Sat Apr 10 23:57 2004 (BST) No Plan.
Links:
- finger, freebsd.org
- GNU Finger, a manual, gnu.org
su
[edit | edit source]su switch user
Examples:
Become another user:
user> su bob Password: bob>
Become root... then become another user:
user> su Password: root# root# su bob bob> (Note: root is not asked for password to become bob!)
Switching user and using the new user's environment (shell, shell-variables, home-directory) as if after a normal log-in:
user> su - bob Password: bob$
Run a program as another user (as root unless otherwise specified):
user> su -c 'apt-get update' Password:
Note: The permission and owner/group of su - as well as other config-files (typically /etc/su and /etc/login.defs) - may prevent users not belonging to certain groups from switching user even with the correct password, or even being able to execute su at all (E.g. in BSD it's traditionally been restricted to members of the wheel-group only).
Links:
- C.4 Utilities, opengroup.org
- su man page, man.cat-v.org
- su, freebsd.org
- 22.5 su, a manual for old coreutils, ftp.gnu.org