Users Groups

disable root and disable password
$ sudo vim /etc/ssh/sshd_config
PasswordAuthentication no
PermitRootLogin no
$ sudo service ssh restart

$ cat /etc/passwd |grep /bin/bash |grep [5-9][0-9][0-9] |cut -d: -f1          #   user list:    

Add a new user
$ adduser morteza
Set password:
$ passwd morteza
$ passwd # for current user
Login as:
$ su - morteza

User is not in the sudoers file

Modify sudoers at /etc/sudoers
Uncomment the line under "Allow people in group wheel to run all commands"
Add current user to wheel group

OR $ usermod -a -G sudo morteza

make a new group

$ groupadd <groupname>

$ gpasswd -a morteza mygroup     # add existing user morteza to the group mygroup

gpasswd -d user group     # remove existing user morteza from the group mygroup

$ groups morteza               # groups a user belongs to

$ chown -Rv username someFileOrDir     # the user own the directory. v verbose will tell you what happened and what didn't, The verbose mode is especially useful if you change the ownership of several files at once.

$ chgrp -Rv usergroup somedir    # change the group of a directory

To make sure that group ownership is inherited on future files - to avoid future unwanted permission denied calls:

chmod -R g+s /tmp/mytemp*

Create a shared directory for all users

$ sudo groupadd users-share     # Make sure all the users who need write access to /var/www are in this group.
$ sudo usermod -a -G users-share morteza  # for each user
$ sudo usermod -a -G users-share scidb
$ sudo mkdir /home/users-share  
$ sudo chgrp -R users-share /home/users-share/  # Then set the correct permissions on /var/www.
$ sudo chmod -R g+wx /home/users-share/  
$ sudo find /home/users-share/ -type d -exec chmod 2775 {} \;  # Additionally, you should make the directory and all directories below it "set GID", so that all new files and directories created under /var/www are owned by the www-data group.
$ sudo find /home/users-share/ -type f -exec chmod ug+rw {} \;       # Find all files in /var/www and add read and write permission for owner and group:
#login again to be able to use this change in permissions

Subpages (1): New Instance