Posted in programming unix

Users, Groups and Permissions on Linux

  1. Adding a user
    sudo adduser <username>
    e.g.: sudo adduser thabung
  2. Delete a User
    sudo deluser <username>
    sudo userdel thabung
  3. Changing the user password
    sudo passwd <username>
    sudo passwd thabung
  4. Adding a group
    sudo groupadd <groupName>
    sudo groupadd programmers
  5. Removing a group
    sudo groupdel <groupname>
    sudo groupdel programmers
  6. Group information
    sudo vi /etc/group
  7. List the groups which the user is in
    groups <username>
    groups thabung
  8. File permission
    Write : 4, Read : 2, Execute: 1
    So, 4+2 = 6, means file/folder has read& write permissions
    4+2+1 = 7, means read, write & execute permissions(full control)
    change the file permission of a folder
    sudo chmod -R (owner)(group)(public) <folderName>
    e.g. sudo chmod -R 775 music
    It means:
    The owner can Read + Write + Execute (4 + 2+ 1 = 7)
    Group members can Read + Write + Execute (4 + 2+ 1 = 7)
    Public can only Read + Execute (4 + 1 = 5), but cannot write/modifychange the permission of a file
    sudo chmod  (owner)(group)(public) <fileName>
    e.g. sudo chmod -R 775 music/animals.mp3
  9. Change the file/folder ownership
    sudo chown -R <username>:<groupname> <pathToFolder>
    e.g.sudo chown -R thabung:www-data /var/www/mysite


I am a passionate software developer currently located in Bengaluru. I love creating beautiful stuffs, reading and soccer. When I am not in front of the PC, you'll find me EITHER day dreaming ;-) OR playing soccer OR reading . FCB and NEUFC are my favorite clubs

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s