[FAQ] How to rotate screen in Ubuntu Server

At first, you must login to terminal.
Then write command

echo 3 | sudo tee /sys/class/graphics/fbcon/rotate_all

Which will rotate your screen to landscape mode (tested for TS050 display) by using thing called framebuffer.
Here is all cases:

0 - Normal rotation
1 - Rotate clockwise
2 - Rotate upside down
3 - Rotate counter-clockwise

But, you should do that every time when you log in. Yeah, that’s not the way it should be, so let’s create shell script and call it on every boot.

Create file rotate_screen.sh at your home directory (/home/khadas).

nano /home/khadas/rotate_screen.sh

and write this to file

#!/bin/sh
echo 3 | sudo tee /sys/class/graphics/fbcon/rotate_all

also make it executable

chmod +x /home/khadas/rotate_screen.sh

So, now we have our script. Let’s add it to cron (which is installed by default). Because we need root, we’ll call it using sudo

sudo crontab -e

If earlier you haven’t used cron, then terminal will ask you about creating a file. Accept and go next.

You will see new file in terminal. Scroll to last line (which should be clear) and paste this code:

@reboot /home/khadas/rotate_screen.sh

If this doesn’t work - double check for typos.

3 Likes