2

Running into a slightly strange situation. Basically for reasons outside of my control I'm on a server that somebody else has set up. I've got sudo access, I just can't figure out what happened or find any documentation.

When I open .bashrc (sudo nano ~/.bashrc) I get a static view that just overwrites the top row. I can exit only by hitting enter after hitting Ctrl+X. Screenshot below.

enter image description here

Same thing happens with vi, and obviously this makes it impossible to edit anything on the server. Anyone have an idea as to what might be happening here? I've done a lot of googling, but it's tough to lock this down.

Response of lsb_release -a pasted below.

Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic

Looking for any weird code lying around I found the following in the .bashrc:

case $- in
    *i*) ;;
      *) return;;
esac

I'm not certain what's going on here tbh, but it was the only thing that I didn't recognize so it might be related?

4 Answers 4

3

It sounds like someone has messed with the (virtual) tty settings that are best left alone in the 21st century, unless of course you're actually using an antique physical terminal from a computer museum...

You should be able to get the tty on the remote server into a usable state with the command (run on the remote server, immediately after logging in):

stty sane

After you've got the terminal working, look for commands like stty or tput in the shell startup scripts which might be doing strange things to the tty.

4
  • Hmm, unfortunately that didn't change anything. May 7, 2019 at 14:13
  • @SlaterVictoroff Probably time to start looking at your local terminal, then. May 7, 2019 at 17:10
  • Same local terminal works fine sshing into other remote envs. Anything else you'd suggest I check? Is stty sane supposed to give some kind of output? May 7, 2019 at 17:24
  • I found something weird in the .bashrc but not sure it's relevant. May 7, 2019 at 17:39
0

Add to the bottom of the file the next line:

export EDITOR=/path/vi

path= The location of the vi editor.

You can execute the command in your current terminal before editing .bashrc.

1
0

You imply, this happens to any file you try to edit.

I think the bashrc seems ok, I have seen similar code in https://gist.github.com/aakbar5/2969095d8dd11e95a282157c2ca29b39, and it’s explained why that case statement is there.

If you think replacing the bashrc help, you can edit a file without an editor. Make a back up first. This uses Here Doc.

cat > ~/.bashrc <‘HT’
# replacement goes here

HT

As for the text editors, what are the path of each? i.e., what is the output of which vi?

0

Try running editor of your preference in screen session. This helps me with such problems 99% of the time. I also believe that this is a problem with TTY setting / some Xterm variables, you could try exporting env output from another machine and sourcing such file on this one checking if that solves the problem the proper way, but I would use screen first

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .