Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

User management commands in linux

linux commands for begginers

How to add / change permissions to user in linux?

In this article beginners will learn, how to add / change the permissions in linux. This article explains the commands in linux to set permissions. Use the following commands to add / change the permissions in linux.

chown command
chown command is used to change the permission of owner and group of a file or directory.
chown user:group [file/directory]

chmod command
chmod command is used to give permissions to folder in linux, chmod command that change the permission of the user owner, group and other users for a specific file/directory.
we can give the permission as digits.(4 = read permission , 2 = write permission , 1 = execute permision)
chmod 760 [file/directory]

This command means that
  1. The owner of the file/directory have all read,write and execute permission .
  2. users in the group will get read, write and execute permissions.
  3. other users will not have any permission to that file/directory.
ACL linux permission (Access control list)
ACL linux permissions are used to set permissions to a specific user for a specific file/directory.
Using chmod command it is difficult to set different permissions to different users when there is a situation where lot of users in that case we use acl commands.

Linux setfacl example :
setfacl –m u:Testuser:rwx [file/directory]

This command gives read ,write,and execute permissions to our user.
To allow all file/directory to inherit ACL permission from the directory it is within,we can use –d option.
setfacl –dm u:Testuser:rwx [file/directory]

getfacl command can be used to view the permissions of file/directory.
getfacl file/directory

Author : 
Ajith Michael
System Engineer
Bayasys Infotech (P) Ltd., Kochi.

Image source : www.google.com

User management commands in linux

linux commands for begginers

How to add user in linux?

In Linux, a ‘useradd‘ command is a low-level utility that is used for adding/creating user accounts in Linux and other Unix-like operating systems. 
Let the new user to be add is Testuser ,then the command will be :
useradd Testuser

Creating password for a user :
passwd Testuser

Enter the new password for the user.

We can see this user details in /etc/passwd file.
cat /etc/passwd

When we run ‘useradd‘ command in Linux terminal, it performs following major things:
  1. It edits /etc/passwd, /etc/shadow, /etc/group and /etc/gshadow files for the newly created User account.
  2. Creates and populate a home directory for the new user.
  3. Sets permissions and ownership to home directory.
    The default home directory for a user will be  ‘ /home/Testuser/ ‘ . but we can create a user with different home directory.
    useradd –d [directory] Testuser
    

    Author : 
    Ajith Michael
    System Engineer
    Bayasys Infotech (P) Ltd., Kochi.

    Image source : www.google.com