Lewati ke konten utama

Linux Security

Separate User Accounts on Linux: Why and How | KaliLinux.net

Learn why separate user accounts matter on Kali Linux and how to create, restrict, and verify them in a legal lab. Practical steps from KaliLinux.net.

Separate User Accounts on Linux: Why and How | KaliLinux.net

Multi-user Linux setup is the first hardening step most Kali users skip. A default Kali install runs everything as root, and that habit follows people into shared machines. KaliLinux.net readers often ask how to separate accounts without breaking their lab workflow. This article covers why separate accounts matter and how to set them up on Kali or any Debian-based system, framed for isolated lab and authorized use only.

Why separate accounts matter

Running as root means any tool, script, or misclicked command has full control of the system. In a personal lab that is convenient. On a shared box, a CTF team machine, or a workstation with multiple users, it is a liability. The Linux kernel and most daemons enforce file ownership and permissions per user ID (UID). If everyone shares root or a single kali account, that enforcement does nothing.

A concrete fact: since Linux 2.6 (2003), the kernel exposes UID separation through /proc/<pid> ownership, meaning any process running as a non-root user cannot read another user’s process memory without privilege. That boundary is real and testable. It is also the boundary most beginners ignore.

Isolation reduces blast radius. A compromised browser running as an unprivileged user cannot rewrite /etc/shadow or install a system-wide backdoor without an escalation step. On a lab box, that is exactly the failure mode you want to observe rather than prevent silently.

How to create and separate user accounts

The workflow below is standard for Debian and Kali. Run it on a system you own or a lab VM.

  1. Create a non-root account: sudo adduser analyst. Set a strong password when prompted.
  2. Give administrative access only when needed: sudo usermod -aG sudo analyst. Avoid adding users to sudo by default.
  3. For shared lab machines, use one account per person. Naming like lab-alice, lab-bob keeps audit trails readable.
  4. Restrict home directory permissions: chmod 700 /home/analyst. Default Debian behaviour already does this, but verify.
  5. Lock the root login over SSH. Edit /etc/ssh/sshd_config, set PermitRootLogin no, then sudo systemctl restart ssh.
  6. For tools that need raw sockets (nmap SYN scans, Wireshark packet capture), grant capabilities instead of running whole sessions as root: sudo setcap cap_net_raw,cap_net_admin+eip /usr/bin/nmap.

That last step is where most Kali users get stuck. Wireshark ships a dumpcap helper with capabilities; nmap needs the same treatment for -sS scans as a normal user. If a tool fails with “Operation not permitted,” check capabilities before falling back to sudo.

Sudo policy is worth tuning too. visudo opens /etc/sudoers. A minimal safe rule for a lab user looks like:

analyst ALL=(ALL) /usr/bin/apt, /usr/bin/systemctl

That limits administrative actions to package management and service control. Blanket ALL=(ALL) ALL is the default many tutorials assume, and it defeats much of the isolation you just built. The sudo project has documented this grammar since version 1.8 in 2011; the man page man sudoers is the authoritative reference at https://www.sudo.ws/docs/man/sudoers.man/ .

One more habit: keep the attacker tooling and the analysis tooling on separate accounts when practising. If nmap or Metasploit runs as analyst and Wireshark sniffs as capture, logs stay clean and you can tell which account did what. This is not paranoia; it mirrors how a SOC analyst separates their workstation from the detection stack.

Verifying the separation

Do not trust the setup until you test it. Log in as the new user and run id. You should see the expected UID and groups. Then try cat /etc/shadow. It should fail with “Permission denied.” If it does not, you are still in a privileged context.

Check process visibility with ps aux | head. As a normal user, you see all processes but you cannot read other users’ /proc/<pid>/mem or signal them without sudo. That is the kernel boundary working.

Check SSH from another host: ssh analyst@lab-ip. Confirm root login is refused. This single test catches more misconfigurations than any checklist.

For CTF teams, run each member under their own account on the shared box and keep flags and writeups in per-user home directories. Kalau ada yang butuh root untuk tool tertentu, ajarin lewat jalur capability, jangan langsung kasih sudo su.

Close

Separate accounts are not a Kali-specific feature. They are how Linux has worked since the beginning, and skipping them is the most common shortcut in beginner labs. For readers building a practice machine, the goal is not maximum lockdown. It is understanding what each boundary does before you rely on it. KaliLinux.net keeps this advice framed for legal lab and certification study, where you own every host in the chain. Kalau kamu belum bikin akun non-root di VM Kali, lakuin itu sebelum nmap scan berikutnya dan perhatiin bedanya.

Pertanyaan yang sering diajukan

Is running as root on Kali Linux dangerous in a lab?
It is convenient but removes the kernel’s UID-based isolation. A compromised tool or script gets full system access. For lab work, a non-root account with targeted sudo rules is safer and easier to audit.
How do I run nmap SYN scans without sudo?
Grant the binary capabilities: sudo setcap cap_net_raw,cap_net_admin+eip /usr/bin/nmap. Then run nmap -sS normally as your user. KaliLinux.net recommends this over wrapping every scan in sudo.
Should every user on a shared Kali box have sudo?
No. Grant sudo only to accounts that need it, and scope it to specific commands. Use visudo to edit /etc/sudoers and test with sudo -l as the target user.
How do I verify that accounts are actually separated?
Log in as the new user, run id, then try cat /etc/shadow. It should fail. Also confirm sshd refuses root login and that PermitRootLogin no is set. Testing beats assuming.