At the system shell prompt, the user can enter various commands to perform the work accordingly. Each command usually obtains input from the terminal keyboard, prints the output to the terminal screen, uses standard input stdio and standard output stdout to represent the input and output of each command, and uses a standard error output stderr to output error messages. These three standard input and output systems are linked by default to terminal devices, but they can also be redirected using the concept of piping, obtaining input from one file or another command, outputting to another file or as input to another command.$ ls > ls.out
$ cat < ls.out
$ ls -l | grep mbox
FreeBSD can run multiple processes at the same time, enter command 10 directly under the shell, and the shell puts the process into the foreground execution. If you want to put a process into the background, you need to add a "&" symbol at the end of the command line. The following commands are executed from the background, from the Ftp.isc. org downloads files.
$ wget ftp://ftp.isc.org/pub/inn/inn-1.7.2.tar.gz &
When the program is already executing in the foreground, you can use ^z to suspend the program and suspend execution. You can then use the BG command to place the pending program in the background, or use FG to place a background or pending process into the foreground.
When running a program in the background, you can use the Jobs command to view the status of the background job. When you have more than one daemon, you use the FG command with parameters to switch the background jobs with different ordinal numbers to the foreground.
$ jobs
[1]+ Running wget ftp://ftp.isc.org/pub/inn/inn-1.7.2.tar.gz &
$ fg %1
wget ftp://ftp.isc.org/pub/inn/inn-1.7.2.tar.gz
After you start more than one program, you can use the PS command to view these processes and their status.
$ ps
PID TT STAT TIME COMMAND
501 p2 Ss 0:00.24 -bash (bash)
988 p2 R+ 0:00.00 ps
765 p3 Is+ 0:00.28 -bash (bash)
230 v0 Is+ 0:00.14 -bash (bash)
The results shown include the process identification number PID, the control Terminal TT (P0 means the control terminal is TTYP0), the process state stat, the processor time used by the process and the specific commands.
You can add parameters to the PS command to get more output, and the following command will output all the processes in the system:
$ ps waux
USER PID%cpu%mem VSZ RSS TT STAT started time COMMAND
WB 989 0.0 0.4-236 P2 r+ 5:48pm 0:00.00 ps-aux
Root 1 0.0 0.1 496 72?? is 10:12pm 0:00.02/sbin/init--
Root 2 0.0 0.0 0 0?? DL 10:12pm 0:07.05 (pagedaemon)
Root 3 0.0 0.0 0 0?? DL 10:12pm 0:00.20 (vmdaemon)
Root 4 0.0 0.0 0 0?? DL 10:12pm 0:04.27 (syncer)
Root 27 0.0 0.0 204 0?? iws-0:00.00 (Adjkerntz)
Root 91 0.0 0.5 820 328?? is 2:12pm 0:00.82 syslogd
Daemon 100 0.0 0.0 792 0?? iws-0:00.00 (portmap)
Root 131 0.0 0.3 864 164?? is 2:12pm 0:00.06 inetd
Root 134 0.0 0.3 980 192?? is 2:12pm 0:00.11 cron
Root 138 0.0 0.6 1252 380?? is 2:12pm 0:00.11 SENDMAIL:ACCEPTI
WB 230 0.0 1.1 1540 668 V0 is+ 2:12pm 0:00.14-bash (bash)
Root 231 0 .0 0.0 824 0 v1 iws+-0:00.00 (Getty)
Root 232 0.0 0.0 824 0 V2 iws+-0:00.00 (Getty)
Root 500 0 .0 0.9 876 524?? SS 4:19pm 0:01.78 telnetd
WB 501 0.0 1.4 1540 888 P2 Ss 4:19pm 0:00.24-bash (bash)
Root 698 0.0 1.5 1644 900?? is 4:49pm 0:00.02/usr/local/sbin/s
Root 700 0.0 1.2 1308 748?? Ss 4:49pm 0:00.22/usr/local/sbin/n
Root 702 0.0 3.4 2900 2112?? S 4:49pm 0:00.32/usr/local/sbin/s
Root 764 0.0 0.9 880 540?? is 5:10pm 0:00.22 telnetd
WB 765 0.0 1.7 1536 1052 P3 is+ 5:10pm 0:00.28-bash (bash)
Root 0 0.0 0.0 0 0?? DLs 10:12pm 0:00.02 (swapper)