<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.completenoobs.com/noobs/index.php?action=history&amp;feed=atom&amp;title=Ubuntu_Users</id>
	<title>Ubuntu Users - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.completenoobs.com/noobs/index.php?action=history&amp;feed=atom&amp;title=Ubuntu_Users"/>
	<link rel="alternate" type="text/html" href="https://www.completenoobs.com/noobs/index.php?title=Ubuntu_Users&amp;action=history"/>
	<updated>2026-04-30T03:38:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.completenoobs.com/noobs/index.php?title=Ubuntu_Users&amp;diff=275&amp;oldid=prev</id>
		<title>Noob: Created page with &quot;==Create User Account== add user using a ubuntu script &lt;code&gt;/usr/sbin/adduser&lt;/code&gt;&lt;br \&gt; &lt;code&gt;adduser &lt;username&gt;&lt;/code&gt;&lt;br \&gt; And nice and straightforward.&lt;br \&gt;   Manually for scripts:&lt;br \&gt; &lt;code&gt;useradd&lt;/code&gt;-&gt;&lt;code&gt;/usr/sbin/useradd&lt;/code&gt; &lt;br \&gt; Syntax:&lt;code&gt;useradd -s &lt;path/shell&gt; -d &lt;directory&gt; -m -G &lt;SecondaryGroup&gt; &lt;user&gt;; passwd &lt;user&gt; &lt;/code&gt;&lt;br \&gt; Example&lt;code&gt;useradd -s /bin/bash -d /home/green -m -G sudo green;passwd green&lt;/code&gt; &lt;div class=&quot;toccolours...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.completenoobs.com/noobs/index.php?title=Ubuntu_Users&amp;diff=275&amp;oldid=prev"/>
		<updated>2023-04-02T21:53:08Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Create User Account== add user using a ubuntu script &amp;lt;code&amp;gt;/usr/sbin/adduser&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt; &amp;lt;code&amp;gt;adduser &amp;lt;username&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt; And nice and straightforward.&amp;lt;br \&amp;gt;   Manually for scripts:&amp;lt;br \&amp;gt; &amp;lt;code&amp;gt;useradd&amp;lt;/code&amp;gt;-&amp;gt;&amp;lt;code&amp;gt;/usr/sbin/useradd&amp;lt;/code&amp;gt; &amp;lt;br \&amp;gt; Syntax:&amp;lt;code&amp;gt;useradd -s &amp;lt;path/shell&amp;gt; -d &amp;lt;directory&amp;gt; -m -G &amp;lt;SecondaryGroup&amp;gt; &amp;lt;user&amp;gt;; passwd &amp;lt;user&amp;gt; &amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt; Example&amp;lt;code&amp;gt;useradd -s /bin/bash -d /home/green -m -G sudo green;passwd green&amp;lt;/code&amp;gt; &amp;lt;div class=&amp;quot;toccolours...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Create User Account==&lt;br /&gt;
add user using a ubuntu script &amp;lt;code&amp;gt;/usr/sbin/adduser&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;adduser &amp;lt;username&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
And nice and straightforward.&amp;lt;br \&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Manually for scripts:&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;useradd&amp;lt;/code&amp;gt;-&amp;gt;&amp;lt;code&amp;gt;/usr/sbin/useradd&amp;lt;/code&amp;gt; &amp;lt;br \&amp;gt;&lt;br /&gt;
Syntax:&amp;lt;code&amp;gt;useradd -s &amp;lt;path/shell&amp;gt; -d &amp;lt;directory&amp;gt; -m -G &amp;lt;SecondaryGroup&amp;gt; &amp;lt;user&amp;gt;; passwd &amp;lt;user&amp;gt; &amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
Example&amp;lt;code&amp;gt;useradd -s /bin/bash -d /home/green -m -G sudo green;passwd green&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
flag notes:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;-s&amp;lt;/b&amp;gt; login shell to be used for created account&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;-d&amp;lt;/b&amp;gt; home directory for created account.&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;-m&amp;lt;/b&amp;gt; make home directory if does not exist.&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;-G&amp;lt;/b&amp;gt; add created user to groups.&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;;&amp;lt;/b&amp;gt; separator &amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;passwd $USER&amp;lt;/b&amp;gt; will prompt for a password of created account.&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create User Account with restricted shell===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo useradd -s /usr/bin/rbash -d /home/&amp;lt;username&amp;gt; -m &amp;lt;username&amp;gt;;passwd &amp;lt;username&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Change User Shell==&lt;br /&gt;
Give a user a restricted shell:&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;chsh -s /usr/bin/rbash &amp;lt;user&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Change User Password==&lt;br /&gt;
&lt;br /&gt;
Open a terminal window and type the following command, replacing &amp;quot;username&amp;quot; with the name of the user whose password you want to change:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo passwd username&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:*        You will be prompted to enter and confirm the new password for the user. Follow the on-screen instructions to complete the process.&lt;br /&gt;
&lt;br /&gt;
:*        Once the password has been changed, you can test it by logging in to the Ubuntu server with the user&amp;#039;s credentials.&lt;br /&gt;
&lt;br /&gt;
==Remove/Delete User==&lt;br /&gt;
&lt;br /&gt;
To delete a user and their home directory on Ubuntu 22.04, you can use the userdel command. Follow these steps:&lt;br /&gt;
&lt;br /&gt;
:* Open a terminal window.&lt;br /&gt;
&lt;br /&gt;
:* Make sure you have root privileges or use sudo. You need administrative rights to delete a user. If you&amp;#039;re not logged in as the root user, you can use sudo to execute the command with elevated privileges.&lt;br /&gt;
&lt;br /&gt;
:* Use the &amp;lt;b&amp;gt;userdel&amp;lt;/b&amp;gt; command with the &amp;lt;b&amp;gt;-r&amp;lt;/b&amp;gt; flag to delete the user and their home directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo userdel -r username&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace username with the actual username of the user you want to delete.&lt;br /&gt;
&lt;br /&gt;
The -r flag will remove the user&amp;#039;s home directory, along with their mail spool, and any files they own in their home directory. Be cautious when using this flag, as it will permanently delete the user&amp;#039;s data.&lt;br /&gt;
&lt;br /&gt;
Note: Before deleting a user, ensure that they are not currently logged in and that no processes are running under their account. You can use the who command to see &amp;lt;b&amp;gt;who&amp;lt;/b&amp;gt; is currently logged in and the &amp;lt;b&amp;gt;ps -u username&amp;lt;/b&amp;gt; command to check for any running processes for that user. If necessary, you can terminate processes using the &amp;lt;b&amp;gt;kill&amp;lt;/b&amp;gt; command, followed by the process ID&lt;br /&gt;
&lt;br /&gt;
To delete USER and keep there &amp;lt;b&amp;gt;home directory&amp;lt;/b&amp;gt; on system use:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;userdel username&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Add user to group/s==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
add user to sudo group after account created:&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;usermod -aG sudo &amp;lt;user&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Check if a User is a member of a group==&lt;br /&gt;
To check if a user is a member of a specific group, you can use the groups or id command.&lt;br /&gt;
&lt;br /&gt;
:*        groups command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;groups username&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace username with the actual username. This command will display a list of groups the user is a member of.&lt;br /&gt;
&lt;br /&gt;
:*        id command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;id username&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace username with the actual username. This command will display the user ID, group ID, and the groups the user is a member of.&lt;br /&gt;
&lt;br /&gt;
==See what users are in a specific group==&lt;br /&gt;
&lt;br /&gt;
To see the list of users in a specific group, you can use the getent command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;getent group groupname&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace groupname with the actual name of the group you want to check. This command will display the group name, group ID, and the list of users in that group.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can check the /etc/group file, which contains information about all the groups on your system and their members:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;grep groupname /etc/group&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace groupname with the actual name of the group. This command will display the group name, group ID, and the list of users in that group.&lt;br /&gt;
&lt;br /&gt;
==Find Users on system==&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/passwd&amp;lt;/code&amp;gt; see users&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/shadow&amp;lt;/code&amp;gt; contains hash of passwords.&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;cat /etc/shadow  | grep &amp;lt;user&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Run Command as another user==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo -H -u &amp;lt;user&amp;gt; bash -c &amp;quot;mkdir /home/&amp;lt;user&amp;gt;/.ssh&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;su - &amp;lt;user&amp;gt; -c &amp;quot;mkdir /home/&amp;lt;user&amp;gt;/.ssh&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;su - www-data -c &amp;quot;touch /var/log/logfile&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Monitoring user activity on your system ==&lt;br /&gt;
&lt;br /&gt;
To see what users are currently doing on your system, you can use the following commands:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;who&amp;lt;/code&amp;gt;&lt;br /&gt;
:*    &amp;lt;b&amp;gt;who&amp;lt;/b&amp;gt;: Shows a list of users currently logged in, their terminal, and login time.&lt;br /&gt;
:*    w: Displays information about the users currently on the machine and their processes. This includes the user&amp;#039;s login name, terminal, host, login time, idle time, and the currently running process.&lt;br /&gt;
:*    last: Shows a list of the last logged-in users.&lt;br /&gt;
&lt;br /&gt;
To monitor the activity of a specific user, you can use the ps command with the -u flag, followed by the username:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ps -u username&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command will show a list of processes owned by the specified user.&lt;/div&gt;</summary>
		<author><name>Noob</name></author>
	</entry>
</feed>