zesttec / Linux-knowledgebase

0 stars 0 forks source link

Linux User Management #1

Open zesttec opened 4 years ago

zesttec commented 4 years ago

Linux Users and groups

Create a new user and set its password:

You need to apply the commands with root permission( with sudo or using sudo su - to switch to root account ) most of the time.

To verify new user is successfully created:

Once a new user created, it entry is added to /etc/passwd file like: newusername:x:1001:1001::/home/newusername: Username:Password:UserID(UID):GroupID(GID):UserInfo:HomeDirectory:Shell

What are these fields:

Add home directory for new user: useradd -d /home/HomeDirectoryName newusername

Change the ownership of dirs or files:

chown newusername -R a/b/c/ means giving newusername the ownship of directory a/b/c/ and all files inside it. chown newusername a/b/c/ means giving newusername the ownship of directory a/b/c/.

Created a new group

groupadd newgroupname. Groups information is stored in /etc/group

Change the group ownership of a file or directories.

chgrp [-R] groupname fileORdirectory -R option means to change the group ownership recursively of files and directories.

You can also pass multiple files to chgrp command as arguments: chgrp groupname file1 file2 file3

Reference: https://www.tecmint.com/add-users-in-linux/

zesttec commented 4 years ago

File Permissions

Ps: You need root privilege to perform commands.

Reference: https://www.howtogeek.com/437958/how-to-use-the-chmod-command-on-linux/ https://www.thegeekstuff.com/2013/02/sticky-bit/ https://en.wikipedia.org/wiki/Setuid http://catcode.com/teachmod/setuid.html