מאגר מידע

How to Manage Users and Permissions in Linux

Managing users and file permissions correctly is essential for a secure multi-user server.

Managing users

sudo adduser alice          # create a user
sudo usermod -aG sudo alice  # grant sudo
sudo passwd alice            # set/change password
sudo deluser alice           # remove a user

Understanding permissions

Each file has read (r), write (w) and execute (x) permissions for owner, group and others. ls -l shows them, e.g. -rwxr-xr--.

Changing permissions and ownership

chmod 755 script.sh         # rwxr-xr-x
chmod +x script.sh          # make executable
chown alice:developers file.txt   # change owner:group
chmod -R 775 /var/www/app   # recursive

Permission numbers

  • 7 = read + write + execute
  • 6 = read + write
  • 5 = read + execute
  • 4 = read only

Grant the minimum permissions needed — avoid chmod 777.

?האם התשובה שקיבלתם הייתה מועילה

0 משתמשים שמצאו מאמר זה מועיל

Powered by WHMCompleteSolution