Basic command
separation
Summary
Use this to write multiple lines command (if your
terminal screen isn't long enough).
Example
#mount /dev/hdc \
/mnt/cdrom
#
Summary
Normally, when you enter a command, the task runs in the
foreground and you don't get the prompt back until
the program is finished. Sometimes you don't want this behavior.
Especially if your task takes a lot of time
and doesn't have any interaction with the user (example:
updatedb). The answer is to run the program in the
background. By placing a "&" last in your
command you achieve this effect.
Example
#sleep 10
<Wait ten seconds>
#
#sleep 10 &
[1] 13533 <-- this is the PID (ProcessID) of the process
you just put in the background.
# Your prompt returns immediately
#sleep 10 & sleep 15 &
[1] 13534 <- starts both commands simultaneously in the
background in order.
[2] 13535 <- this is the sleep 15 commands PID
#
Summary
A really useful separator. It directs the output of one
command to the next. This is very useful when you want one
program to work on the output of another one.
Example
# ps aux | grep ps
larson 1344 0.0 0.4 1188 584 p2 R 15:04 0:00 ps aux
larson 1345 0.0 0.3 1180 464 p2 S 15:04 0:00 grep ps
#
The example first lists all processes on the system and
directs this output to the grep utility which sorts
out and displays all lines with ps in them. PS: you may
not get the same output that I did, because the "grep
ps" command may or may not have been started at the
time you ask for the process list.
Summary
If you want to execute more than one command in a row you
can separate them with a semicolon (;)
Example
#cp /tmp/hello ; cat hello
Copies the file "hello" to the current directory
and then displays it.
Table of contents
|