How to quit `tail -f` mode without using `Ctrl+c`?

As said in the comments, Ctrl-C does not kill the tail process, which is done by sending either a SIGTERM or SIGKILL signal (the infamous -9...); it merely sends a SIGINT which tells tail to end the forward mode and exit.

FYI, these's a better tool:

less +F filename

In less, you can press Ctrl-C to end forward mode and scroll through the file, then press F to go back to forward mode again.

Note that less +F is advocated by many as a better alternative to tail -f. For difference and caveats between the two tools, read this answer: Is `tail -f` more efficient than `less +F`?


What I want is a normal way to quit, like q in top.

That's ControlC :)

I am just curious about the question, because I feel that killing the process is not a good way to quit something.

^C (ControlC) sends a SIGINT to the process, which is defined as:

The SIGINT signal is sent to a process by its controlling terminal when a user wishes to interrupt the process

That's exactly what you want to do here, is interrupt tail. There's no other way to accomplish what you're trying to do ("nicely" quit tail) and while other answers provide a means to stop tail in other ways, they're no better.

Pressing ^C will attempt to interrupt a task in Linux -- this is perfectly normal, and it's only "not good" if that process is in the middle of something and you're not letting it finish, and then the only "not good" side effect is leftover things from that process. As an example, ^C in the middle of a make command leaves partially-compiled software, but that's fine: a further run of make will clean that up / resume where it left off.


tail -f filename, how to quit the mode without use Ctrl c to kill the process

You can't do that. Perhaps you wanted to run tail -f somefile | less

The Ctrl c is interpreted by the tty subsystem (and by your shell) and sends a SIGINT signal (see signal(7) and pty(7)...). See tty demystified.

Tags:

Tail