Frequently Asked Question
How to create a new user with a home directory and sudo privileges in a single command
ปรับปรุงล่าสุด 11 วันมาแล้ว
To create a new user with a home directory and sudo privileges in a single command on Debian, run the following useradd command as root:bash
useradd -m -s /bin/bash -G sudo %username% && passwd %username%
Use code with caution.Command Breakdown
useradd: The low-level utility used to create structural user accounts.-m: Forces the creation of the user's home directory (usually/home/%username%).-s /bin/bash: Sets Bash as the default login shell for the user.-G sudo: Appends the user to the secondarysudogroup, granting them administrative privileges.&& passwd: Immediately triggers the prompt to set the password for the new account, allowing you to log in securely right away