Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a machine that running customized linux, and I login into the system by PuTTY.

It turned out I'm using bash. And the PS1 is

sh-4.1# echo $PS1

when I type following:

sh-4.1# ls a very long path i will not be able to see the rest of the command line

I will see

< i will not be able to see the rest of the command line

I can use left arrow key to move forward:

sh-4.1# ls a very long path i will not be able to see the rest of the command >

This is very inconvenience as you have to move cursor to see rest of the command line.

How can I show the whole command line?

share|improve this question
Not sure this will help someone who knows or not, but does the sh-4.1# mean that you are using bash (my guess is the shell you use may matter)? – nerdwaller Aug 7 '13 at 3:27

No one uses sh anymore, it's always a symlink to the distro-specific default shell (ash, ksh, bash, dash, zsh, etc.). You can check withreadlink -e $(which sh)

Are you using a Virtual Terminal or a terminal emulator such as gnome-terminal, xterm, konsole, etc.?

In any case, here's a trick: Press CTRL+X+E to initialize an editor (set by the environmental variable EDITOR) then save & exit and your long command will be executed.

You may wish to change the default editor using export EDITOR="nano -w"

Source: Commandlinefu - Rapidly invoke an editor to write a long, complex, or tricky command

share|improve this answer
readlink -e $(which sh) shows that I'm using bash. Good point that I can use editor for command line edit, but when I use arrow key to view my history, I still can't see the whole line. – Deqing Aug 12 '13 at 5:58
I had a strong suspicion it was BASH based on the 4.1 version number. Please post the value of your PS1 environmental variable. That is the likely culprit for the line not wrapping to the next line. Additionally, update the question to specify which terminal program you are using; you might have to turn on word-wrap – justbrowsing Aug 12 '13 at 7:17
Question updated, thanks. – Deqing Aug 12 '13 at 8:33

There doesn't seem to be anything funky going on inside your PS1 variable, so turning focus away from which shell you are using.

PuTTY, huh? A quick search turned up a bug report regarding wrapping. I use MobaXterm on the occasion I'm forced to use Windows (the horror).

However, fired up a VM and lo-and-behold Auto wrap mode initially on is enabled by default and it actually works. Do you have this setting enabled?

putty wordwrap

share|improve this answer

If you absolutely have to enter the path in one go, I might suggest changing the prompt. If you don't mind going back to bash, you could add a newline near the end of the PS1 variable definition, which would move the boilerplate to a separate line, thus giving you more of the line to work with. This would be done by editing your .bashrc, like so:

# Original line from ~/.bashrc:
PS1='\s-\v# '
# ^^ prints "bash-4.2# _" as the prompt on my system
# (Ignore parens, underscore shows cursor position)
# or insert '\n':
PS1='\s-\v\n# '
#         ^^ newline, now prints
# "bash-4.2
#  # _"

The downside to this is that your prompt now takes up more screen real estate, and, depending on your original prompt, might only give you a few more characters to work with per line.

Having said that, is it really mandatory that the path be entered at once? It could be worth cding down a few levels (since you already know their location from the path) then running ls or whatever else.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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