[2025-jun-17] The SlackDocs mailing lists at https://lists.alienbase.nl/mailman/listinfo have been retired. No one has been using these lists for years and it's time to say goodbye. The list archives remain available at https://scalzi.slackware.nl/mailman/listinfo/slackdocs
[2025-jun-17] The SlackDocs Wiki has moved to a new server, in order to make it more performant.
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| howtos:misc:enabling_sudo_on_slackware [2020/01/02 18:19 (UTC)] – slackjeff | howtos:misc:enabling_sudo_on_slackware [2026/04/26 20:24 (UTC)] (current) – [Sources] r1w1s1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Enabling Sudo on Slackware ====== | ====== Enabling Sudo on Slackware ====== | ||
| - | Sudo, substitute user of (Super User) or Super user of (acting as super user) has a big role on UNIX Likes systems, sudo allows ordinary users to temporarily get privileges from another user, widely used for the privileges of the superuser root. | + | < |
| + | **tl;dr** — Slackware ships with sudo installed but disabled. Enable it by uncommenting the **wheel** line in ''/ | ||
| + | </ | ||
| - | There are many advantages and disadvantages of using sudo over su, for example sometimes we just need to perform a task quickly, such as updating the system with a single command, such as ' | + | ===== Overview ===== |
| - | But every superhero pays his price, as sudo allows | + | Slackware does not enable |
| - | This is why it is extremely important that you have a secure password for root as well as your regular user, so you can use sudo with peace of mind. | + | This document describes how to enable |
| - | Unlike other distributions | + | This approach follows common Unix practices while preserving |
| - | The first step is to create a group called " | ||
| - | Let's use manual mode for better learning and notion. | + | ===== Design goals ===== |
| - | The first step is to log in as root, for that use the su command, and right after we will open a groups configuration file located in / etc / group, open it with your favorite editor: | + | * keep privilege escalation explicit |
| + | * avoid modifying default Slackware behavior unnecessarily | ||
| + | * use group-based access control | ||
| + | * ensure configuration remains auditable | ||
| + | * prevent accidental lockouts | ||
| - | < | ||
| - | $ su | ||
| - | # nano / | ||
| - | </ | ||
| - | Let's navigate to the last line of the ' | + | ===== Assumptions ===== |
| - | < | + | * Slackware is running on the system |
| - | privoxy: | + | * sudo is installed (it is, by default) |
| - | </code> | + | * the **wheel** group already exists in '' |
| + | * the user has root access via '' | ||
| + | * the system administrator understands the risks of sudo access | ||
| + | |||
| + | |||
| + | ===== Configuring sudoers ===== | ||
| - | In this same format we will create the sudo group, the format should be as follows: | + | Always edit ''/ |
| < | < | ||
| - | groupname: | + | # visudo |
| </ | </ | ||
| - | To check your user ID run the 'id -u' | + | If you prefer a different editor, set the '' |
| < | < | ||
| - | $ id -u | + | # EDITOR=vi visudo |
| - | 1000 | + | |
| </ | </ | ||
| - | We then add in the last line of the group file: | + | Slackware' |
| < | < | ||
| - | sudo: | + | ## Uncomment to allow members of group wheel to execute any command |
| + | # %wheel ALL=(ALL) ALL | ||
| </ | </ | ||
| - | Example: | + | Remove the ''#'' |
| < | < | ||
| - | nobody: | + | ## Uncomment to allow members of group wheel to execute any command |
| - | nogroup: | + | %wheel ALL=(ALL) ALL |
| - | users: | + | |
| - | console: | + | |
| - | tor: | + | |
| - | privoxy: | + | |
| - | sudo: | + | |
| </ | </ | ||
| - | After this process, save and close. | + | Save and exit. '' |
| - | Now we will need to edit the ' | + | |
| + | ===== Adding a user to wheel ===== | ||
| + | |||
| + | As root, add your regular user to the wheel group: | ||
| < | < | ||
| - | # nano / | + | # usermod -aG wheel username |
| </ | </ | ||
| + | Replace '' | ||
| - | Open the file, find the line ''# | ||
| - | Commented sudo line: | + | ===== Applying the change ===== |
| + | |||
| + | Group changes take effect on the next login. Log out and log back in, then verify: | ||
| < | < | ||
| - | ## Uncomment to allow members of group sudo to execute any command | + | $ sudo whoami |
| - | # %sudo ALL=(ALL) ALL | + | root |
| + | $ sudo slackpkg update | ||
| </ | </ | ||
| - | Uncommented | + | If the output of '' |
| + | |||
| + | < | ||
| + | A reboot is **not** required. Logging out and back in is enough to refresh group membership. | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Passwordless sudo (optional) ===== | ||
| + | |||
| + | For a system where you want sudo without a password prompt, use this line in ''/ | ||
| < | < | ||
| - | ## Uncomment to allow members of group sudo to execute any command | + | %wheel ALL=(ALL) |
| - | %sudo ALL=(ALL) ALL | + | |
| </ | </ | ||
| - | Uncommented the line of sudo, save and close, | + | This reduces friction but increases risk: anyone with access |
| - | There are directories like the example '/ sbin' which is accessible only with users of UID 0, an example is root itself. What happens if we try to execute a command like slackpkg for example that is inside directory? It will fail. | ||
| - | So we need to add two new lines to our PATH. | + | ===== Notes and considerations ===== |
| - | For this still as root user let's open the file 'profile' | + | * Slackware does not require sudo. The '' |
| + | * Always test sudo from a separate terminal before closing your root session, | ||
| + | * Limit wheel membership to trusted users only. | ||
| + | * Syntax errors in sudoers can lock out administrative access — always use '' | ||
| - | < | ||
| - | # Set the default system $PATH: | ||
| - | PATH="/ | ||
| - | </ | ||
| - | Note that there is an established pattern, directories have their field separated by ':' | + | ===== Conclusion ===== |
| - | < | + | Enabling sudo on Slackware is a deliberate administrative choice, not a default |
| - | # Set the default | + | |
| - | PATH="/ | + | |
| - | </ | + | |
| - | < | + | Using the wheel group and explicit sudoers configuration balances convenience and security while preserving Slackware's emphasis on transparency and control. |
| - | Please note that your regular user (UID 1000) can now execute | + | |
| - | </ | + | |
| - | Simply put, it is the same as giving a read permission to a file, for a given user it can read but cannot write or execute, for example. | ||
| - | Reboot your system with the shutdown command with parameters -r now, or simply exit your user and return so that you can execute the exit command or simultaneously press the **CTRL + D** keys. | + | ===== References ===== |
| - | Run tests by adding sudo in front of the desired command | + | * '' |
| - | Also test by updating your list and checksuns with slackpkg. | + | * '' |
| + | * '' | ||
| - | <code> | + | |
| - | $ sudo ls /root/ | + | {{tag>slackware |
| - | $ sudo slackpkg update | + | |
| - | </ | + | |
| ====== Sources ====== | ====== Sources ====== | ||
| - | * Originally written by [[wiki: | + | * Originally written by [[wiki: |
| <!-- Please do not modify anything below, except adding new tags.--> | <!-- Please do not modify anything below, except adding new tags.--> | ||
| <!-- You must remove the tag-word " | <!-- You must remove the tag-word " | ||
| - | {{tag> | + | {{tag> |