<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Folarin Martins</title>
    <description>The latest articles on DEV Community by Folarin Martins (@mfolarin).</description>
    <link>https://dev.to/mfolarin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F660371%2F1eff4422-84a7-4796-a483-adb42792270d.jpeg</url>
      <title>DEV Community: Folarin Martins</title>
      <link>https://dev.to/mfolarin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mfolarin"/>
    <language>en</language>
    <item>
      <title>The Ultimate Guide to User &amp; Permissions Management in GNU/Linux</title>
      <dc:creator>Folarin Martins</dc:creator>
      <pubDate>Sat, 08 Jan 2022 11:37:54 +0000</pubDate>
      <link>https://dev.to/mfolarin/the-ultimate-guide-to-user-permissions-management-in-gnulinux-3h63</link>
      <guid>https://dev.to/mfolarin/the-ultimate-guide-to-user-permissions-management-in-gnulinux-3h63</guid>
      <description>&lt;p&gt;Create new user&lt;br&gt;
&lt;code&gt;sudo adduser newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;NOTE: Creating a new user also creates a group by the same name known as the primary group&lt;/p&gt;

&lt;p&gt;Change user password&lt;br&gt;
&lt;code&gt;sudo passwd newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Grant user admin privileges&lt;br&gt;
&lt;code&gt;visudo&lt;/code&gt;&lt;br&gt;
with unlimited root access&lt;br&gt;
&lt;code&gt;newuser ALL=(ALL) all&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;with restricted access&lt;br&gt;
&lt;code&gt;Cmnd_Alias ADMIN1PRIVILEDGES = /usr/bin/adduser, /usr/bin/usermod, /usr/bin/addgroup&lt;/code&gt;&lt;br&gt;
&lt;code&gt;newuser ALL=(root) ADMIN1PRIVILEGES&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Change user home directory&lt;br&gt;
&lt;code&gt;usermod --home /home/newuser newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Change user shell&lt;br&gt;
&lt;code&gt;usermod --shell /bin/sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add descriptive comment to user&lt;br&gt;
&lt;code&gt;usermod --comment "Here is a new demo user" newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add an account expiry date&lt;br&gt;
&lt;code&gt;usermod --expiredate 2022-12-31 newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Lock account&lt;br&gt;
&lt;code&gt;usermod --lock newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Unlock account&lt;br&gt;
&lt;code&gt;usermod --unlock newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add a password change policy of 60 days&lt;br&gt;
&lt;code&gt;change --maxdays 60 newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Delete user account&lt;br&gt;
&lt;code&gt;deluser newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Delete user with all files&lt;br&gt;
&lt;code&gt;deluser -r newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a group&lt;br&gt;
&lt;code&gt;addgrop newgroup&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Delete a group&lt;br&gt;
&lt;code&gt;delgroup newgroup&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add a user to a group&lt;br&gt;
&lt;code&gt;usermod -aG newgroup newuser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Remove a user from a group&lt;br&gt;
&lt;code&gt;deluser newuser newgroup&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Change file owner to a user&lt;br&gt;
&lt;code&gt;chown newuser file1.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Change file group to a group&lt;br&gt;
&lt;code&gt;chgrp newgroup file1.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Change file permissions&lt;br&gt;
&lt;code&gt;chmod a+rwx file1.txt //give read+write+execute to all&lt;/code&gt;&lt;br&gt;
&lt;code&gt;chmod u+rwx file1.txt //give read+write+execute to owner&lt;/code&gt;&lt;br&gt;
&lt;code&gt;chmod o-w   file1.txt //remove write access from others different from file owner and group&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or, in the octal form:&lt;br&gt;
&lt;code&gt;chmod 755 file1.txt   //equivalent to u+rwx, g+rx, o+rx&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;permission bits | binary | octal&lt;br&gt;
--x                    001     1&lt;br&gt;
-wx                    011     3&lt;br&gt;
rwx                    111     7&lt;br&gt;
r-x                    101     5&lt;br&gt;
rw-                    110     6&lt;br&gt;
r--                    100     4&lt;br&gt;
-w-                    010     2&lt;/p&gt;

&lt;p&gt;To prevent a user from deleting files owned by other users, set the sticky bit on the directory&lt;br&gt;
&lt;code&gt;chmod o+t directory1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To enable others to access the file with the same permission as the owner&lt;br&gt;
&lt;code&gt;chmod u+s file1.txt   //apply the setuid bit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To enable others to access the file with the same permission as the group&lt;br&gt;
&lt;code&gt;chmod g+s file1.txt   //apply the setgid bit&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
