So you logged in as root/user with sudo permissions... ok? You want to be at least 20% secure though, and the next coolest game server shouldn't be ran as root. You're just not as dank as Bryan Lunduke.
Perhaps it's Minecraft you want to setup, and you're going to use GNU Screen for running it in the background like a bajillion of online tutorials suggest.
You add a user for minecraft, but hey! Let's be a little bit secure and you use SSH Keys and don't want to be bothered to setup a key for your new minecraft user. OR when you run
adduser minecraft you also add the flag
--disabled-password or you used the good ol'
useradd and didn't set a password because life goals or something.
Whatever the reason is, you don't want to be bothered with firing up another putty window just to run screen, you just want to su to the new user and do your magic.
Now you can always just run
screen -dmS sessionname your command here and it will run the command specified after the session name. Assuming you didn't screw up, it'll work fine.
But what if you don't want
--dmS? What if you want to attach to the screen session? Whether you're using
screen -r or just starting a new session the classic way with
screen -S, it doesn't work, all because you su'd in. Screen can't control your pseudo-terminal because you're really using the one from the user you su'd from yet you're running screen from the su'd user. It cries out in agony!
Cannot open your terminal '/dev/pts/0' - please check. But alas.... just run this command first:
Then run your screen session.
Just remember to type
exit when you're all done to end "writing" the script.
It'll work. You're welcome.