How to Fix Garbled Characters ^[[A^[[D in Linux Terminal (Debian 11)
Recently, when using a VPS terminal under the same SSH client, I encountered garbled symbols like ^[[A^[[D when pressing the Up Arrow (↑) and Down Arrow (↓). I tried searching via ChatGPT and the internet but couldn't find a solution until I resolved it based on experience.

Temporary Solution
The operating system used is Debian 11, and the user is not root (this issue likely applies to other Linux distributions as well). If you notice a $ symbol at the beginning of the terminal, it usually indicates that the default shell is sh. To verify the shell type, run the following command:
$ echo $SHELL
/bin/sh
As expected, the shell is indeed sh. By entering the bash command, the shell was switched to bash mode, and the prompt changed to user@GreenCloud:/data$.

After switching, pressing the Up Arrow (↑) and Down Arrow (↓) to view command history no longer displays garbled symbols, and the issue is temporarily resolved.
Permanent Solution
The method above only addresses the symptom; the problem will reappear upon the next login. To fix this permanently, you can use the chsh command to change the default shell type for a specific user:
# /bin/bash is the shell type; replace 'user' with your actual username
chsh -s /bin/bash user
When the user logs in next time, they will use bash as their default shell terminal type, permanently resolving the issue.
Conclusion
On Linux, if the user's shell type is set to sh, it may cause garbled symbols like ^[[A^[[D when using the Up and Down arrows. You can temporarily resolve this by using the bash command or permanently fix it by changing the user's shell type with the chsh command. Users experiencing similar issues may find this solution helpful.