NEXT UP previous
Next: My Home Page

Answers

  1. Several solutions to this problem are possible, all of which count the number of lines in the file /etc/passwd as each login name available on the system has its own line in this file:

  2. The command to list the processes on your system is ps. This command lists the processes on the system, one line per process. Counting the number of lines should give a count of the number of processes. One minor problem is that, by default, the ps command also displays a header line at the top of its output. This can be suppressed but you need to look at the manual page to find out that the command line switch to do this is -h. This gives a solution of:
    	$ ps -axh | wc -l
    


  3. The df -a command lists all the filesystems that are mounted together to generate your overall directory hierarchy. The mounted filesystems are listed one per line so a line count will tell you the number of mounted filesystems. One problem is that the df command also generates a header line which, unlike the ps command, cannot be suppressed. This means that the number you obtain as output from this pipeline will be one too big. If it is important, it is possible to sort this out, and we'll cover arithmetic expressions in another tutorial.

  4. This exercise uses a command we have not covered yet, but a quick glance in the manual shows that the who command just lists all the users who are logged in, one per line. Counting the number of lines will therefore display the number of user logins currently active.

NEXT UP previous
Next: My Home Page