How to exclude a package from apt-get autoremove?

I'm in a situation where the list of orphaned packages to be removed by apt-get autoremove includes a package that I want to keep. Apparently I have accidentally removed a package which was depending on it. How can I now mark the package as explicitly desired, so that apt-get autoremove will not remove it?


Use apt-mark

$ man apt-mark
...
manual
       manual is used to mark a package as being manually installed, which will 
prevent the package from being automatically removed if no other packages 
depend on it.

So

sudo apt-mark manual <package-name>

Now autoremove won't remove it.

To undo

sudo apt-mark auto <package-name>

Now autoremove will remove the package if it is not a dependency of any other package.


A few more Google attempts brought up a solution:

It is either possible to just install explicitly:

sudo apt-get install <package>

or marking as manually installed via

sudo apt-mark manual <package>

apt won't re-install, the output will just look like:

$ sudo apt-get install tmux
Reading package lists... Done
Building dependency tree       
Reading state information... Done
tmux is already the newest version.
tmux set to manually installed.