Search code examples
linuxputtyls

How to stop displaying long long file list of `ls`?


There is a big directory which contains 100k files on the remote server, and I typed command: ls in my putty.

It starts to display a very long file list, and seems never end.

How to stop it, without closing the putty program?


Solution

  • If you are over SSH, you can use escape sequences. For example to send break, press:

    enter, ~ and B

    "enter" is of course not typed, just press the enter key (I suppose to "reset" the current command buffer)

    Other interesting ones

    Terminate time-outing session

    enter, ~ and .

    Send escape character

    enter, ~ and ~

    You can list these commands with

    enter, ~ and ?

    On my system the above prints:

    # ~?
    Supported escape sequences:
      ~.  - terminate connection (and any multiplexed sessions)
      ~B  - send a BREAK to the remote system
      ~C  - open a command line
      ~R  - Request rekey (SSH protocol 2 only)
      ~^Z - suspend ssh
      ~#  - list forwarded connections
      ~&  - background ssh (when waiting for connections to terminate)
      ~?  - this message
      ~~  - send the escape character by typing it twice
    (Note that escapes are only recognized immediately after newline.)