Root access
Use root safely — create a sudo user, understand sudo, and avoid working as root day to day.
1 min read Some details need confirmation
On this page
Root can do anything — including break the system with one typo. Use a normal user with sudo for daily work.
Create a sudo user (Ubuntu/Debian)#
bash
adduser deploy
usermod -aG sudo deployCopy your SSH key to the new user:
bash
rsync --archive --chown=deploy:deploy ~/.ssh /home/deployTest in a new terminal before logging out of root:
bash
ssh deploy@YOUR_SERVER_IP
sudo whoami # should print: rootUsing sudo#
Prefix admin commands with sudo:
bash
sudo apt update
sudo systemctl restart nginxLost access?#
If you lock yourself out (a lost key, or a firewall that blocks SSH), you'll need out-of-band console access or a reinstall.
Once you've confirmed the new user works, disable root SSH login.
Was this page helpful?
