Skip to content

setupusers

gollum edited this page Feb 27, 2015 · 4 revisions

User management & Permissions

In Linux systems, file and folder access is defined for certain users and groups of users. Naturally, each group can have multiple users and each user can be member of many groups.

https://wiki.archlinux.org/index.php/Users_and_Groups http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/

basic command line tools

  • showing the current users groups

      schneider@kefi118:~$  groups
      schneider adm sudo lpadmin sambashare sftpusers
    
  • showing [user]s groups

      $ groups [user]
    
  • showing the existing groups on the computer

      $ cat /etc/group
    
  • showing the permissions of the files in a folder

      $ ls -l
    

admin tools

  • creating a user

      $ sudo useradd -m -g [initial_group] -G [additional_groups] -s [login_shell] [username]
    

While -m creates an own user home directory, -g specifies the primary group, -G specifies secondary groups, -s defines the default shell for this user, by default this is bash. To add a new user, say a master student called mats, to the workstation, providing him with an empty home directory and adding him only to his own group, also called mats, you have to type:

	$ sudo useradd -m mats -s /bin/bash
  • change or set a password for the new user

      $ sudo passwd mats
    
  • add a user to a group

      $ sudo usermod -a -G [group] [user]
    
  • remove a user

      $ sudo deluser --remove-home [user]
    

    removes the user and his home directory. you will be reminded that the group of the user remains without members. So also delete the group:

      $ sudo delgroup [user]
    

monitoring

  • check which users are existing

      cut -d: -f1 /etc/passwd
    
  • see login attempts

              sudo less /var/log/auth.log
    

It is possible that a botnet tries to break into the workstation, which you recognise by secondly failed logins. The probability that the hack cracks the barrier is marginal, since only login via SSH with private-public key authentication is enabled.

Clone this wiki locally