command line text editors in Linux (nano,vim) are not working #15295

Closed
opened 2026-01-31 04:34:06 +00:00 by claunia · 10 comments
Owner

Originally created by @oholimoli on GitHub (Sep 21, 2021).

Windows Terminal version (or Windows build number)

1.11.2421.0, Microsoft Windows [Version 10.0.18363.1679]

Other Software

No response

Steps to reproduce

When I connect to a linux server with SSH and I try to edit a file with a command line editor like nano or vim it is not possible to edit the text file. Is it possible to fix this?

Expected Behavior

When I use the git bash in Windows everything is ok:

[root@server~]# echo "test" > test.txt
[root@server~]# cat test.txt
hello
[root@server~]# nano test.txt

image

Actual Behavior

[root@server~]# echo "test" > test.txt
[root@server~]# cat test.txt
hello
[root@server~]# nano test.txt

image

Originally created by @oholimoli on GitHub (Sep 21, 2021). ### Windows Terminal version (or Windows build number) 1.11.2421.0, Microsoft Windows [Version 10.0.18363.1679] ### Other Software _No response_ ### Steps to reproduce When I connect to a linux server with SSH and I try to edit a file with a command line editor like nano or vim it is not possible to edit the text file. Is it possible to fix this? ### Expected Behavior When I use the git bash in Windows everything is ok: ``` [root@server~]# echo "test" > test.txt [root@server~]# cat test.txt hello [root@server~]# nano test.txt ``` ![image](https://user-images.githubusercontent.com/47213738/134128306-38a975f0-ebde-49b3-8ff4-745a73875fcf.png) ### Actual Behavior ``` [root@server~]# echo "test" > test.txt [root@server~]# cat test.txt hello [root@server~]# nano test.txt ``` ![image](https://user-images.githubusercontent.com/47213738/134128695-b7332276-9a83-40c7-908d-b6379f81c3be.png)
Author
Owner

@zadjii-msft commented on GitHub (Sep 21, 2021):

Which version of ssh are you using? What's TERM set to once you log into the remote machine? Does this repro in a vintage console window (i.e. conhost.exe?)

@zadjii-msft commented on GitHub (Sep 21, 2021): Which version of `ssh` are you using? What's `TERM` set to once you log into the remote machine? Does this repro in a vintage console window (i.e. `conhost.exe`?)
Author
Owner

@oholimoli commented on GitHub (Sep 21, 2021):

I get the same problem with cmd.exe and conhost.exe

My ssh version is: OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

This seems to be the problem.. when I run ssh -V in the GitBash I get:

$ ssh -V
OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020

I will try to update SSH for Windows

@oholimoli commented on GitHub (Sep 21, 2021): I get the same problem with cmd.exe and conhost.exe My ssh version is: `OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5` This seems to be the problem.. when I run `ssh -V` in the GitBash I get: ``` $ ssh -V OpenSSH_8.3p1, OpenSSL 1.1.1g 21 Apr 2020 ``` I will try to update SSH for Windows
Author
Owner

@oholimoli commented on GitHub (Sep 21, 2021):

I just updated ssh to OpenSSH_for_Windows_8.6p1, LibreSSL 3.3.3

Still the same problem :(. Somehow I can use nano only in the GitBash.

@oholimoli commented on GitHub (Sep 21, 2021): I just updated ssh to `OpenSSH_for_Windows_8.6p1, LibreSSL 3.3.3` Still the same problem :(. Somehow I can use nano only in the GitBash.
Author
Owner

@zadjii-msft commented on GitHub (Sep 21, 2021):

What's TERM set to once you log into the remote machine? Does this repro in a vintage console window (i.e. conhost.exe?)

@zadjii-msft commented on GitHub (Sep 21, 2021): > What's `TERM` set to once you log into the remote machine? Does this repro in a vintage console window (i.e. `conhost.exe`?)
Author
Owner

@oholimoli commented on GitHub (Sep 21, 2021):

I found the solution here:
https://superuser.com/questions/1172222/issues-editing-files-with-nano-in-bash-windows-10

After connecting to the server I must run the command export TERM=linux

image

I still don't get it why this problem occurs.. why do I need to set an environment variable on my server in order to use nano when I'm connected via ssh? And why was it working in my Git Bash?

@oholimoli commented on GitHub (Sep 21, 2021): I found the solution here: https://superuser.com/questions/1172222/issues-editing-files-with-nano-in-bash-windows-10 After connecting to the server I must run the command `export TERM=linux` ![image](https://user-images.githubusercontent.com/47213738/134183845-81718839-c40e-4fa9-873c-30ee870d4b50.png) I still don't get it why this problem occurs.. why do I need to set an environment variable on my server in order to use nano when I'm connected via ssh? And why was it working in my Git Bash?
Author
Owner

@zadjii-msft commented on GitHub (Sep 21, 2021):

The Windows Terminal doesn't set TERM itself, but the git bash terminal (mintty) likely does. I'd be curious to know what TERM was set to on that machine when you first remoted into it. The Windows Terminal should be roughly equivalent to TERM=xterm-256color, but yea I'd guess that linux would work too.

@zadjii-msft commented on GitHub (Sep 21, 2021): The Windows Terminal doesn't set `TERM` itself, but the git bash terminal (mintty) likely does. I'd be curious to know what `TERM` was set to on that machine when you first remoted into it. The Windows Terminal should be roughly equivalent to `TERM=xterm-256color`, but yea I'd guess that `linux` would work too.
Author
Owner

@oholimoli commented on GitHub (Sep 21, 2021):

The server runs CentOS. The value of TERM was dumb??. I changed it to linux:
echo "export TERM=linux" >> ~/.bashrc

Now everything seems to work fine.

@oholimoli commented on GitHub (Sep 21, 2021): The server runs CentOS. The value of `TERM `was `dumb`??. I changed it to linux: `echo "export TERM=linux" >> ~/.bashrc` Now everything seems to work fine.
Author
Owner

@zadjii-msft commented on GitHub (Sep 21, 2021):

Well, that sure is dumb 😝 glad you figured this out!

@zadjii-msft commented on GitHub (Sep 21, 2021): Well, that sure is `dumb` 😝 glad you figured this out!
Author
Owner

@oholimoli commented on GitHub (Sep 21, 2021):

true :), very lucky to find this solution ... I'm pretty sure I used nano in the past the same way and everything was ok :/.

@oholimoli commented on GitHub (Sep 21, 2021): true :), very lucky to find this solution ... I'm pretty sure I used nano in the past the same way and everything was ok :/.
Author
Owner

@samvanbrussel commented on GitHub (Nov 18, 2021):

vim and nano used to work in the past on my Ubuntu Server 20.04.3 LTS and Raspberry Pi OS 10 (buster). Since I had to do an install of Raspberry Pi OS 11 (bullseye), I noticed that it didn't work any more.

After a lot of research, I noticed it stopped working everywhere, not just on bullseye, so it should be related to my client (Windows Server 2019, ssh via native PowerShell, PowerShell 7 and Command Prompt). So something has changed in Linux (via updates) or Windows (via updates).

Executing export TERM=linux before using nano or vim works. Otherwise, they also work but you get a blank screen and can't see what you're typing (unless you close you editor and go back to the prompt, then everything you did appears).

@samvanbrussel commented on GitHub (Nov 18, 2021): `vim `and `nano `used to work in the past on my Ubuntu Server 20.04.3 LTS and Raspberry Pi OS 10 (buster). Since I had to do an install of Raspberry Pi OS 11 (bullseye), I noticed that it didn't work any more. After a lot of research, I noticed it stopped working everywhere, not just on bullseye, so it should be related to my client (Windows Server 2019, ssh via native PowerShell, PowerShell 7 and Command Prompt). So something has changed in Linux (via updates) or Windows (via updates). Executing `export TERM=linux` before using `nano `or `vim `works. Otherwise, they also work but you get a blank screen and can't see what you're typing (unless you close you editor and go back to the prompt, then everything you did appears).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15295