Restore previous state of apps after powering on Ubuntu system

It is called "session management"

Could I have it on ubuntu?

Not in a default desktop

But you can use the Linux window session manager or Gnome Window Session Manager extension for gnome for this. You will get an indicator on the Gnome Shell top bar where you can save and restore a session. Installation from the 2nd link (1st one has a similar setup):

setup

  • Make sure you have nodejs installed (e.g. execute node -v and if there is no output install it).

  • Install lwsm via npm: npm install -g linux-window-session-manager (on some systems you might want to use sudo)

  • Download or clone repository and move all files to /home/your-user-name/.local/share/gnome-shell/extensions/[email protected]

  • In some cases - especially when you're using nvm, you might need to configure the path to your lwsm installation (which you can find out via which lwsm after a successful installation) extension via gnome-shell-extension-prefs.


Installation after setup is done:

cd tmp
git clone [email protected]:johannesjo/gnome-shell-extension-window-session-manager.git
mv gnome-shell-extension-window-session-manager ~/.local/share/gnome-shell/extensions/[email protected]

It's not shutdown, anycase take a look at the following command:

pm-action - Suspend or Hibernate your computer

pm-hibernate [--help]
pm-suspend [--quirk-*] [--help]
pm-suspend-hybrid [--quirk-*] [--help]

From man page:

These commands can be used to put the machine in a sleep state. The precise way how this
   is done can be influenced by installing executables and configuration snippets. For some
   options external programs are needed.

   These commands will usually be called by UPower or hald when triggered to do so by a
   program in a desktop session such as gnome-power-manager. Calling them from the command
   line is also possible, but it is not guaranteed that all programs in your desktop session
   keep working as expected.

   pm-suspend
       During suspend most devices are shutdown, and system state is saved in RAM. The system
       still requires power in this state. Most modern systems require 3 to 5 seconds to
       enter and leave suspend, and most laptops can stay in suspend mode for 1 to 3 days
       before exhausting their battery.

   pm-hibernate
       During hibernate the system is fully powered off, and system state is saved to disk.
       The system does not require power, and can stay in hibernate mode indefinitely. Most
       modern systems require 15 to 45 seconds to enter and leave hibernate, and entering and
       leaving hibernate takes longer when you have more memory.

   pm-suspend-hybrid
       Hybrid-suspend is the process where the system does everything it needs to hibernate,
       but suspends instead of shutting down. This means that your computer can wake up
       quicker than for normal hibernation if you do not run out of power, and you can resume
       even if you run out of power. s2both(8) is an hybrid-suspend implementation.