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:
- Change username:
- change user password:
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 theroot
user.docker
: The group owner of the file is thedocker
group. Members of this group have permission to access the socket.
To identify which process is using a specific port and terminate it:
- Check the process using the port:
sudo lsof -i :<port number>
- Terminate the process:
Do you enjoy this blog post?