I am trying to copy some files and folders on a Centos machine.

I do it like so: sudo cp source destination & to run it in the background.

I see there are three cp processes now when I run ps aux | grep cp: One of them is the grep command itself, but the other two are copies of the above cp command: one with the entire command listed above and the other without the sudo in front. The PIDs of the two processes also differs by one.

My questions:
1. Why the two processes? The owner of both is listed as root.


The two processes are sudo on the one hand, and cp on the other. When you run

sudo cp source destination &

the shell starts sudo with the full command line; then sudo (which runs as root because it is setuid root) checks that you're allowed to run cp like that, and forks and starts cp. So while cp is running you see both sudo and cp processes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.