DEV Community

Mahbub Ferdous Bijoy
Mahbub Ferdous Bijoy

Posted on

Day-3: Linux user management and permissions

  1. use sudo command to see some confidential or root user access file:
$ cat /var/etc/shadow         [you cant see access denied]
$ sudo cat /var/etc/shadow        [noew you can see]
$ sudo cat /var/etc/passwd
$ sudo cat /var/etc/group

Enter fullscreen mode Exit fullscreen mode
  1. add some user by using useradd command:
$ sudo useradd userName

Enter fullscreen mode Exit fullscreen mode
  1. delete some user by using userdel command:
$ sudo userdel userName

Enter fullscreen mode Exit fullscreen mode
  1. cahnging some user password :
$ sudo passwd userName

Enter fullscreen mode Exit fullscreen mode
  1. if we want to know our ssh key :
$ cat ~/.ssh/id_rsa.pub

Enter fullscreen mode Exit fullscreen mode
  1. connect your machine with remote machine via ssh :
$ ssh -i "key-pair_fileName_PATH ubuntu@ip_address    [ubuntu or any os]

Enter fullscreen mode Exit fullscreen mode
  1. something copy from remote server:
$ scp -i <keypair_PATH> < keypair_PATH> <user@ip_address>: filePath 

Enter fullscreen mode Exit fullscreen mode

here all linux permission command:

  1. check file permission:
$ ls -l

Enter fullscreen mode Exit fullscreen mode
  1. to change any file permission by using chmod(rwx):
$ chmod +x fileName            [make executable file]
$ chmod +rwx fileName          [ make permission read,write, executable]
$ chmod -rwx fileName          [ remove all permission]
$ chmod -x fileName            [remove executable permission]

Enter fullscreen mode Exit fullscreen mode
  1. we can give permission by using numaric command like 777:
Description: for read - 4, write - 2, execute -1. all together 7. for 777 means 1st 7 for user, 2nd for group and 3rd for all user

$ chmod 777 fileName    [all permission for user,group and all]
$ chmod 742 fileName    [all permission for user, read for group, write for all]
$ chmod 124 fileName    [execute permission for user, write for group, read for all]
$ chmod 711 fileName    [ all permission for user, execute for groups and all]

Enter fullscreen mode Exit fullscreen mode
  1. modifying ownership permission :
$ sudo chown userName fileName    [it will change files user ownership]
$ sudo chgrp groupName fileName    [it will change files group ownership]
$ sudo chmod userName:groupName fileName     [it will change both user & group ownership]

Enter fullscreen mode Exit fullscreen mode
  1. if you want to change your user password:
$ passwd

Enter fullscreen mode Exit fullscreen mode
  1. to see our system name :
$ uname

Enter fullscreen mode Exit fullscreen mode
  1. to see our system name and details:
$ uname -a
$ uname -r     [to check only version numaric ]

Enter fullscreen mode Exit fullscreen mode
  1. add a user to a group :
$ sudo usermod -a -g groupName userName

Enter fullscreen mode Exit fullscreen mode
  1. remove a user from a group:
$ sudo deluser userName groupName

Enter fullscreen mode Exit fullscreen mode
  1. Shows information of all the users logged in:
$ finger

Enter fullscreen mode Exit fullscreen mode
  1. show information of a particular user:
$ finger userName

Enter fullscreen mode Exit fullscreen mode

Top comments (0)