Why Doesn't Control-C Work in the Linux 'less' Command?

  • Thread starter Thread starter ehrenfest
  • Start date Start date
Click For Summary
SUMMARY

The 'less' command in Linux does not respond to Control-C due to its design, which intentionally ignores this interrupt signal. Instead, users can exit the 'less' environment by pressing the 'q' key. While some implementations of 'less' may allow Control-C to function as an exit command, this behavior is not standard across all versions. Understanding this design choice clarifies why users experience difficulty when attempting to exit 'less' using Control-C.

PREREQUISITES
  • Basic understanding of Linux command line operations
  • Familiarity with the 'less' command and its functionalities
  • Knowledge of keyboard shortcuts in terminal applications
  • Awareness of process management in Linux
NEXT STEPS
  • Research the 'less' command options and configurations in Linux
  • Explore alternative text viewers like 'more' and their exit commands
  • Learn about signal handling in Linux, specifically how commands respond to Control-C
  • Investigate process management commands such as 'fg' and 'bg' for handling suspended processes
USEFUL FOR

Linux users, system administrators, and developers who frequently work with command line tools and seek to enhance their efficiency in navigating text files.

ehrenfest
Messages
2,001
Reaction score
1
[SOLVED] getting out of less

How do you get out of the "less" environment in linux? The normal control-C does not work and I am not sure why. I usually just resort to control-Z but then I have to go back and kill the process which is annoying.

EDIT: apparently .q works; but can someone please explain why the normal control-C does not work?
 
Last edited:
Computer science news on Phys.org
The designer of 'less' chose to make it ignore ctrl-c, I don't know why.
Some implementations quit on ctrl-C but this isn't the standard behaviour.
 

Similar threads

  • · Replies 18 ·
Replies
18
Views
2K
Replies
3
Views
11K
Replies
10
Views
5K
Replies
3
Views
2K
  • · Replies 123 ·
5
Replies
123
Views
19K
Replies
0
Views
2K
Replies
1
Views
2K
  • · Replies 35 ·
2
Replies
35
Views
7K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 52 ·
2
Replies
52
Views
6K