While configuring, changing or testing stuff on a dedicated server, things might break or you lock yourself out. Things like that often happen while securing your server. Anyway, there is help!
Most ISPs offer a rescue console or booting into a rescue system to undo unwanted changes or rescue data from a defunct system. The rescue system is also the last resort when your system got compromised by an attacker. Here are the basic steps to find your way around:
- Tell the system to reboot and, this time, load the rescue system. Most ISPs have a command for that on the GUI/ the web interface of your server.
- Login via ssh as root: ssh <your-server's-IP> -l root
- Find out where the file system of your "real" operating system is now mounted: use the command fdisk -l, look for drive ids in the /dev folder
- Mount the filesystem ("sda2" here) to a newly-created directory (for example "foo") to work on the partitition: mkdir /foo && mount /dev/sda2 /foo
- Do what has to be done to recover your normal OS
- type reboot and <ENTER>