Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Sending a USR1 signal to a running `dd' process makes it print I/O sta-
tistics to standard error and then resume copying.
$ dd if=/dev/zero of=/dev/null& pid=$!
$ kill -USR1 $pid; sleep 1; kill $pid
18335302+0 records in 18335302+0 records out 9387674624 bytes
(9.4 GB) copied, 34.6279 seconds, 271 MB/s
How does 'pid=$!' fit into the dd syntax? Is the first line a single command? The meaning of 'pid=$!' is clear to me. As a second question, why to sleep 1, then kill $pid? 'kill -USR1 $pid' would do exactly what is intended that is, print and resume copying.
I use this approach myself sometime. Anyway, here's my clarification of that example (which is exactly that, an example of little practicality.)
# Write from /dev/zero into /dev/null, and do it in the background (note the &.)
dd if=/dev/zero of=/dev/null &
# Get the pid of whatever the last backgrounded process was (see bash man page.)
# Note that this is a new, separate statement, not an argument to dd,
# as could be mistaken from the original text.
# Now, print out the progress using USR1 interrupt.
kill -USR1 $pid;
# The sleeping makes the behavior more clear in the example, but probably isn't necessary.
# Okay, examples over. Actually kill (terminate) the process.
Oh thanks, jhwilliams. I knew the meaning of pid=$! as I had looked for ! in the bash man. pid is an arbitrary name, and $! extracts the value of !. But in the first line of the example, there is not a semicolon (';') to separate the two commands. But bash interpreted the right way! It seems as if, after an ampersand, the semicolon is superfluous.
By the way, what is the meaning of USR1 or a reference to it. I have a demo board, able to run linux (embedded) with two LEDs (light indicator) , USR0 and USR1.