how to do screen recording in ubuntu code example

Example 1: screen recorder ubuntu

sudo apt install kazam

Example 2: screen recorder for ubuntu

sudo add-apt-repository ppa:maarten-baert/simplescreenrecorder
sudo apt update
sudo apt install simplescreenrecorder

Example 3: ubuntu black screen recording

log out and beside "Sign in" button you will see a small cogwheel. click on it and choose "Ubuntu on Xorg" or "Gnome on Xorg" and you're good to go, OBS should work on that, but this reverts you to using X as display manager.