Popular Commands For User Management In Ubuntu

Popular Commands For User Management In Ubuntu

List all Users:

cut -d':' -f 1 /etc/passwd

List all Groups:

cut -d':' -f 1 /etc/group

Add current user to a group:

sudo usermod -aG <groupname> $USER

Add a new user to System:

sudo adduser new_username

To remove/delete user:

sudo userdel username

Or delete the username from the home directory to deleted user account:

sudo rm -r /home/username

To modify user:

  1. Change username:
sudo usermod -l new_username old_username

Change username in Linux/Ubuntu command.

  1. change user password:
sudo passwd username

change user password in Linux/Ubuntu command.


See file permissions:

ls -l <filename>

Example Output:

rw-rw-rw- 1 root docker 0 Nov 28 05:27 docker.sock

Breakdown of Each Component:

  • rw-rw-rw-: These are the file permissions:
    • rw- (Owner: Read and write): The file owner can read and write to the socket.
    • rw- (Group: Read and write): Members of the group can read and write to the socket.
    • rw- (Others: Read and write): All other users on the system can read and write to the socket.
  • 1: Number of hard links to the file.
  • root: The owner of the file is the root user.
  • docker: The group owner of the file is the docker group. Members of this group have permission to access the socket.

To identify which process is using a specific port and terminate it:

  1. Check the process using the port:
sudo lsof -i :<port number>
  1. Terminate the process:
kill -9 <PID>

Replace <PID> with the Process ID displayed in the output of the lsof command.

Do you enjoy this blog post?

Read more