{"id":151,"date":"2011-07-25T10:04:47","date_gmt":"2011-07-25T10:04:47","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=151"},"modified":"2013-05-18T08:59:14","modified_gmt":"2013-05-18T06:59:14","slug":"adding-new-users-under-debian","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=151","title":{"rendered":"Adding \/ deleting new users under Debian"},"content":{"rendered":"<p>Adding new users is something that you will need to do if you want to allow other users to use your machine.<\/p>\n<p>To add a new user is simple enough. First of all you need to become root, you can do this by logging in with your normal user account then running the <\/p>\n<pre>su<\/pre>\n<p> command.<\/p>\n<p>Once you are root you can add a new user with the <strong><tt>adduser<\/tt> command<\/strong>, this needs a single parameter &#8211; the name of the account to add.<\/p>\n<p>If you want to give the user &#8216;John Smith&#8217; a login account you could run<\/p>\n<pre>useradd jsmith <\/pre>\n<p>Once this is done there are two more things you need to do &#8211; set the password for this account (they can change it themselves later) &#8211; you can do this by running<\/p>\n<pre>passwd jsmith<\/pre>\n<p>When you run passwd it will ask you for the password to set twice, to make sure you&#8217;ve typed what you think you&#8217;ve typed.<\/p>\n<p>The next thing you need to do is make a home directory for them. This will normally just involve running:<\/p>\n<pre>mkdir \/home\/jsmith\r\nchown jsmith:users \/home\/jsmith<\/pre>\n<p>This creates a directory with the same name as the login account beneath the <\/p>\n<pre>\/home<\/pre>\n<p> directory &#8211; then changes it to be owned by the user.<\/p>\n<p>If you omit the &#8216;<strong><\/p>\n<pre>chown<\/pre>\n<p><\/strong>&#8216; command the user will not have permission to save files inside their own home directory !<\/p>\n<p><strong>Now let us test :<\/strong><\/p>\n<p><strong>Syntax<\/strong><\/p>\n<p>A simplified expression of the syntax of the su command is:<\/p>\n<pre>su [options] [commands] [-] [username]<\/pre>\n<p>The square brackets indicate that the enclosed item is optional. Thus, the simplest way to use the su command is to just type:<\/p>\n<pre>su<\/pre>\n<p>The operating system assumes that, in the absence of a username, the user wants to change to a root session, and thus the user is prompted for the root password as soon as the ENTER key is pressed. This produces the same result as typing:<\/p>\n<pre>su root<\/pre>\n<p>If the correct password is provided, ownership of the session is changed to root.<\/p>\n<p>Likewise, to transfer the ownership of a session to any other user, the name of that user is typed after su and a space. For example, to change the owner of the current login session to a user named <em>alice<\/em>, type the following:<\/p>\n<pre>su jsmith<\/pre>\n<p>The user will then be prompted for the password of the account with the username John Smith.<\/p>\n<p>======================================================================<\/p>\n<p><strong>Debian \/ Ubuntu<\/strong><\/p>\n<p>On Debian or Ubuntu systems, useradd is a command itself, and you can create users and define options to them using this command, and adduser is a perl script, that uses <a href=\"http:\/\/www.go2linux.org\/create-new-user-linux-useradd\">useradd<\/a> to create the account, asking you the password, Full-name, phone and others like this:<\/p>\n<pre>ggarron@debian:~\/tmp$ sudo adduser test\r\nAdding user `test' ...\r\nAdding new group `test' (1004) ...\r\nAdding new user `test' (1003) with group `test' ...\r\nCreating home directory `\/home\/test' ...\r\nCopying files from `\/etc\/skel' ...\r\nEnter new UNIX password:\r\nRetype new UNIX password:\r\npasswd: password updated successfully\r\nChanging the user information for test\r\nEnter the new value, or press ENTER for the default\r\n\tFull Name []: gasf\r\n\tRoom Number []: asdg\r\n\tWork Phone []: asdf\r\n\tHome Phone []: asdf\r\n\tOther []: asdf\r\nIs the information correct? [Y\/n] y<\/pre>\n<p>As you can see the script will do the job for you, I prefer using the command itself, as I like to have the control, but is up to you which one to use.<\/p>\n<p>====================================================================================<\/p>\n<p>to remove a user and their home directory, use:<\/p>\n<pre>\u00a0sudo deluser -remove-home &lt;user-name&gt;<\/pre>\n<p>to remove all of their files on the server:<\/p>\n<pre>sudo deluser -remove-all-files &lt;user-name&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adding new users is something that you will need to do if you want to allow other users to use your machine. To add a new user is simple enough. First of all you&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[34,14],"tags":[],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/151"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=151"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2843"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}