I'm currently changing the permissions and ownership on a 4TB HDD filled with files. Is it even possible to monitor the progress of commands such as chmod and chown?


You can attach to the running process and see what it's doing now. This will give you an idea of where it's at.

strace -p1234

where 1234 is the process ID of the chmod process. Note that many systems restrict non-root users to monitoring child processes only, so you'd have to do this as root; see after upgrade gdb won't attach to process.

Knowing what file is currently being processed doesn't provide an easy way of knowing what has already been processed. chmod traverses the file tree in depth-first order, and traverses each directory in directory order (the order of ls -U, which is not the same as the order of ls in general).

It would be nice to know how many files the process has already processed, and that can be determined at least approximately by knowing how many system calls the process has made, but as far as I know Linux doesn't keep track of how many system calls a process has made.

  • The problem is that I'm using a recursive chmod, so it changes the pid continuously. – Adan Dec 14 '16 at 0:44
  • @vasc0x No, a recursive chmod (chmod -R) does not fork, so there is only one PID. If you ran find … -exec chmod … {} \; then that does invoke one chmod per file; you can find where the recursion is at by tracing the find process. – Gilles 'SO- stop being evil' Dec 14 '16 at 0:59

In general, no, not without some flag to show what a program is doing, with the flag being specified when the process launched. (If you do make it verbose, also be sure to put it in a screen or tmux session so you can reconnect to that as necessary...)

Some utilities (e.g. dd) accept a user signal to toggle verbosity (e.g. via the USR1 signal, pkill -USR1 dd) but that varies by application (USR1 by default just kills a process; use with caution).

Indirect indications are another method, e.g. run top, assuming the processes generates sufficient CPU or I/O load to make it stand out (something that waits on network results may not appear to be doing much).

Process tracing is also possible, though may horribly slow the system down (e.g. strace); less expensive tools for such a check would be dtrace or similar which can take samples and report a summary on how many relevant system calls chmod is making over some duration.


You might look at the pv command. I don't have it on this system at the moment, but it helps you monitor pipe flows.

I am assuming you are doing something like:

find stuff -exec chmod 664 {} \;

You could break up the command using pipes, and then insert pv or tee in to monitor where things were at.

I realize that I didn't cookbook an answer, but perhaps these ideas will help.

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.