Shell review notes ---- user management, shell ---- user management
$ Who can know the number of logins to the System
$ Who | wc-l: calculate the number of users
Note: | it is a pipeline symbol. pipeline can be established between two programs (pipeline): the output of who is the wc input. The result listed by wc is the number of logged-on users.
The pipeline is converted into an independent command by entering this command into a common file, and then using chmod to set the execution permission for the file.
#! /Bin/sh when a file contains the first two characters #! The kernel will scan the remaining parts of the line to see if there is a complete path available for executing the program's interpretation. the kernel will reference the interpreter with a straight-forward option, and then use the other part of the command line. generally, shell scripts start #! /Bin/sh.
$ Cat> nusers creates a file and uses cat to copy the input from the terminal.
Who | content of the cw-l program
^ D Ctrl-D indicates end-of-file
$ Chmod + x nusers grant the File Execution permission
$./Nusers run the test
6. Possible output test results