Introduction to Unix

../_images/ksus1.jpg ../_images/UNIX_blocks.jpeg

3.9. Miscellaneous Other Commands

3.9.1. whoami

Linux for Programmers and Users, Section 4.10

whoami

The purpose of this curious command is just to report the user’s login name. It is useful for shell script programming. Other commands that do a similar task are id and echo $USER.

The id is used more for informational purposes and is not as useful as whoami in a shell script.

The output of the whoami command is slightly different from $USER because whoami outputs the username that the user is working under, whereas $USER outputs the username that was used to login. For example, if the user logged in as john and su into root, whoami displays root and echo $USER displays john. This is because the su command does not invoke a login shell by default.

See also

who

3.9.2. su

Linux for Programmers and Users, Section 4.11

su

run a shell with substitute user and group IDs

SYNOPSIS

su [-] [USER]

-, -l, --login

make the shell a login shell

If the USER name is left off, attempt to become root. Unix system administrators seldom login as root. Rather, they usually login to the system as themselves and then use su - or sudo to gain superuser (root) privileges.

The root user may su to other user accounts without typing a password. Other users must always enter the correct password when using su.

3.9.3. ul

Linux for Programmers and Users, Section 4.12.4

ul

Remove or transform underline characters so that they display correctly.

SYNOPSIS

ul [-t terminal] [FILE …]

See col below for an explanation of when you might use ul.

3.9.4. col

col

filter reverse line feeds from input

SYNOPSIS

col [-bx]

-b

Do not output any backspaces, printing only the last character written to each column position.

-x

Output multiple spaces instead of tabs.

Note

col only reads from standard input (usually from a pipe).

Manual pages produced with the Using man command use a very old text formatting system called nroff. To produce attractive display with bold text, colored and underlined text on simple terminals, nroff uses special characters such as reverse line feeds, half returns and subscripts. col and ul may be used to strip out such characters so that manual page documentation might be included in other documents. In most cases, col alone will do the trick, but occasionally ul is also needed.

man ls | col -xb > ls_doc.txt

If a command line similar to above does not solve the problem, try:

man ls | col -xb | ul -tdumb > ls_doc.txt

3.9.5. od

Linux for Programmers and Users, Section 4.13

od

A debugging utility that will display non-text data in a readable form. The default format of the data is octal, but it may changed. See the textbook for details and examples.

3.9.6. mount

Linux for Programmers and Users, Section 4.14

mount and umount

The superuser may use these commands to add or remove a drive to / from the file-system. It may be possible (depending on the system configuration) for regular users to mount or umount removable drives.

Users may use mount to display the drives that are currently mounted. (See also df)

3.9.7. time

Linux for Programmers and Users, Section 4.15

time

This is a debugging utility that reports timing information related to the running of a program. This can give hints about what might be wrong with a command that takes a longer time to complete than it should.