sudo improves safety/security by providing accountability, and privilege separation.
Imagine a system that has more than one person performing administrative tasks. If a
root login account is enabled, the system will have no record/log of which person performed a particular action. This is because the logs will only show
root was responsible, and now we may not know exactly who
root was at that time.
OTOH, if all persons must login as a regular user, and then
sudo for privilege elevation, the system will have a record of which user account performed an action. In addition, privileges for that particular user account may be managed and allocated in the
To answer your question now, a hacker that compromises one user account will get only those privileges assigned to that account. Further, the system logs will (hopefully) have a record showing which user account was compromised. OTOH, if it's a simple, single-user system where the privileges in the
sudoers file are set to
%sudo ALL=(ALL:ALL) ALL), then the advantages of accountability, and privilege separation are effectively neutered.
Finally, in regard to the advantages of
sudo, the likelihood is that a knowledgeable hacker may also be able to cover his tracks by erasing log files, etc;
sudo is most certainly not a panacea. At the end of the day, I feel that like many other safeguards we put in place,
sudo helps keep honest people honest - it's less effective at keeping dishonest people at bay.