356
Networking: A Beginner's Guide
For example, to get the operating system's name and release type, enter the following:
[root@ford /root]# uname -s -r
It might appear odd that uname prints such things as the operating system name
when the user obviously will know that the name is Linux. However, such information
is actually quite useful because you can find uname across almost all UNIX-like
operating systems. Thus, if you are at an SGI workstation and enter uname -s, the tool
will return IRIX; if you enter the command at a Sun workstation, it would return SunOS;
and so on. People who work in heterogeneous environments often find it useful to write
their scripts such that they behave differently depending on the operating system type,
and uname provides a wonderfully consistent way to determine that information.
who: Find Out Who Is Logged In
When administering systems that allow people to log in to other people's machines or
set up servers, you will want to know who is logged in. To generate a report listing the
users currently logged in, use the who command, as follows:
[root@ford]# who
This command will generate a report similar to the following:
Sshah tty1 Jun 14 18:22
root pts/9 Jun 14 18:29 (:0)
root pts/11 Jun 14 21:12 (:0)
root pts/12 Jun 14 23:38 (:0)
su: Switch Users
Once you have logged in to the system as one user, you do not need to log back out
and then log in again to assume another identity (for example, if you logged in as
yourself and want to become the root user). Simply use the su command to switch to
another user. This command has only two command-line parameters, both of which are
optional.
By default, running su without any parameters results in an attempt to become the
root user. For example, if you are logged in as yourself and want to switch to the root
user, type the following:
[sshah@ford ~]$ su
Linux will prompt you for the root password; if you enter the password correctly,
Linux then drops down to a root shell.
If you are the root user and want to take the identity of another user, you do not
need to enter that user's password. For example, if you are logged in as root and want
to switch over to user sshah, type the following:
[root@ford /root]# su sshah