Use sudo for tasks require root privileges
# use sudo
sudo apt install nginx
# Only users in the /etc/sudoers file can use sudo
visudo
# Add user
# Set the root user to a no login shell
usermod -s /bin/nologin root
Sudoers File Syntax
# Example sudoers file
# Root user, full access
root ALL=(ALL:ALL) ALL
# Admin group, full access
%admin ALL=(ALL:ALL) ALL
# allow sarah to shut down the server
sarah localhost=/usr/bin/shutdown -r now
Fields for above
- User or %group
- Hosts: localhost, ALL(default), almost always ALL
- (User:Group): Almost always (ALL:ALL), optional
- Command: ALL(default) or list of commands ‘/bin/ls’