One quick and easy way to tell whether you are inside a screen's pseudo terminal or in a regular terminal is to check STY environment variable. When screen is invoked, it sets STY variable to a session name. So if STY environment variable is set to any non-empty string, that means you are inside a screen session.
However, note that the above method works only if you are still on a local computer where you run screen command. If you SSH to any other remote computer from the local computer's screen session, STY variable will not be set on the remote computer while you are technically still in a screen session.
In fact, a more reliable way to check if you are in a screen session is to press "Ctrl-a"+"Ctrl-t". If you are in screen, the terminal will show you time information at the bottom of the terminal.
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!