Friday, January 26, 2024

Linux Command Line Hackery Series - Part 6


Welcome back to Linux Command Line Hackery series, I hope you've enjoyed this series so far and would have learned something (at least a bit). Today we're going to get into user management, that is we are going to learn commands that will help us add and remove users and groups. So bring it on...

Before we get into adding new users to our system lets first talk about a command that will be useful if you are a non-root user.

Command: sudo
Syntax: sudo [options] command
Description: sudo allows a permitted user to execute a command as a superuser or another user.

Since the commands to follow need root privileges, if you are not root then don't forget to prefix these commands with sudo command. And yes you'll need to enter the root password in order to execute any command with sudo as root.

Command: useradd
Syntax: useradd [options] username
Description: this command is used for creating new user but is kinda old school.
Lets try to add a new user to our box.
[Note: I'm performing these commands as root user, you'll need root privileges to add a new user to your box. If you aren't root then you can try these commands by prefixing the sudo command at the very beginning of these command like this sudo useradd joe. You'll be prompted for your root password, enter it and you're good to go]

useradd joe

To verify that this command has really added a user to our box we can look at three files that store a users data on a Linux box, which are:

/etc/passwd -> this file stores information about a user separated by colons in this manner, first is login name, then in past there used to be an encrypted password hash at the second place however since the password hashes were moved to shadow file now it has a cross (x) there, then there is user id, after it is the user's group id, following it is a comment field, then the next field contains users home directory, and at last is the login shell of the user.

/etc/group  -> this file stores information about groups, that is id of the group and to which group an user belongs.

/etc/shadow -> this file stores the encrypted password of users.

Using our command line techniques we learned so far lets check out these files and verify if our user has been created:

cat /etc/passwd /etc/group /etc/shadow | grep joe



In the above screenshot you can notice an ! in the /etc/shadow, this means the password of this user has not been set yet. That means we have to set the password of user joe manually, lets do just that.

Command: passwd
Syntax: passwd [options] [username]
Description: this command is used to change the password of user accounts.
Note that this command needs root privileges. So if you are not root then prefix this command with sudo.

passwd joe



After typing this command, you'll be prompted password and then for verifying your password. The password won't show up on the terminal.
Now joe's account is up and running with a password.

The useradd command is a old school command, lets create a new user with a different command which is kinda interactive.

Command: adduser
Syntax: adduser [options] user
Description: adduser command adds a user to the system. It is more friendly front-end to the useradd command.

So lets create a new user with adduser.

adduser jane



as seen in the image it prompts for password, full name and many other things and thus is easy to use.

OK now we know how to create a user its time to create a group which is very easy.

Command: addgroup
Syntax: addgroup [options] groupname
Description: This command is used to create a new group or add an existing user to an existing group.

We create a new group like this

addgroup grownups



So now we have a group called grownups, you can verify it by looking at /etc/group file.
Since joe is not a grownup user yet but jane is we'll add jane to grownups group like this:

addgroup jane grownups



Now jane is the member of grownups.

Its time to learn how to remove a user from our system and how to remove a group from the system, lets get straight to that.

Command: deluser
Syntax: deluser [options] username
Description: remove a user from system.

Lets remove joe from our system

deluser joe

Yes its as easy as that. But remember by default deluser will remove the user without removing the home directory or any other files owned by the user. Removing the home directory can be achieved by using the --remove-home option.

deluser jane --remove-home

Also the --remove-all-files option removes all the files from the system owned by the user (better watch-out). And to create a backup of all the files before deleting use the --backup option.

We don't need grownups group so lets remove it.

Command: delgroup
Syntax: delgroup [options] groupname
Description: remove a group from the system.

To remove grownups group just type:

delgroup grownups



That's it for today hope you got something in your head.

Related links


  1. Hacking Tools For Kali Linux
  2. Hacker Tools For Mac
  3. Pentest Recon Tools
  4. Pentest Tools For Mac
  5. Pentest Tools Android
  6. Hacking Tools For Games
  7. Wifi Hacker Tools For Windows
  8. Hacking Apps
  9. Pentest Tools Apk
  10. Pentest Tools Apk
  11. New Hacker Tools
  12. Hack Tools Pc
  13. Hacker Tools Mac
  14. Pentest Tools
  15. Kik Hack Tools
  16. Hacking Tools
  17. Hacker Tools Github
  18. Beginner Hacker Tools
  19. New Hack Tools
  20. Hacking Tools Kit
  21. Hacker Tools For Mac
  22. Pentest Tools Find Subdomains
  23. Hack Tools Mac
  24. Hacker Tools
  25. Hacker Tools Online
  26. Hacking Tools 2019
  27. Pentest Tools Website
  28. Hacker Tools Online
  29. Pentest Automation Tools
  30. Kik Hack Tools
  31. Pentest Tools For Windows
  32. Hacks And Tools
  33. Hack Tools Online
  34. Pentest Tools Free
  35. Hack Tools For Pc
  36. Hacking Tools Hardware
  37. Hacking Tools Free Download
  38. What Are Hacking Tools
  39. Pentest Tools Alternative
  40. Hack Tools For Games
  41. Usb Pentest Tools
  42. Hacking App
  43. Nsa Hack Tools Download
  44. Pentest Tools Apk
  45. Hacking Tools For Mac
  46. Pentest Tools Website Vulnerability
  47. Hack Tools
  48. Hacking Tools Windows 10
  49. Hacker Tools Free
  50. Pentest Tools For Mac
  51. Pentest Tools Linux
  52. Hacker Tools Hardware
  53. Growth Hacker Tools
  54. Hack Website Online Tool
  55. Hacker Security Tools
  56. Nsa Hacker Tools
  57. Game Hacking
  58. Hacking Tools Github
  59. What Is Hacking Tools
  60. Hackers Toolbox
  61. Hacking Tools Mac
  62. How To Install Pentest Tools In Ubuntu
  63. Hacker Hardware Tools
  64. Pentest Tools Alternative
  65. Tools 4 Hack
  66. Hack Website Online Tool
  67. Hacking Tools Windows
  68. Pentest Tools Nmap
  69. Hacking Tools For Kali Linux
  70. Hacker Tools Free
  71. Hacker Tools List
  72. New Hacker Tools
  73. Hacking Tools For Windows 7
  74. Hacker Tools Free Download
  75. Hacking Tools Github
  76. Hacking Tools For Windows Free Download
  77. Hacking Tools Kit
  78. Hack Tools
  79. Github Hacking Tools
  80. Hack Tools 2019
  81. Nsa Hack Tools Download
  82. Hacking Tools
  83. Hacker Techniques Tools And Incident Handling
  84. Hacking Apps
  85. Computer Hacker
  86. Hacker Tools For Ios
  87. Pentest Tools List
  88. Black Hat Hacker Tools
  89. Hacking Tools 2019
  90. Hacking Tools For Mac
  91. Hacking Tools Windows
  92. Hacker Tools Mac
  93. Pentest Tools Download
  94. Blackhat Hacker Tools
  95. Game Hacking
  96. Pentest Tools Review
  97. Hacker Tools Free
  98. Growth Hacker Tools
  99. Blackhat Hacker Tools
  100. Hack Tool Apk No Root
  101. Hacker Tools Linux
  102. Pentest Tools Website
  103. Hacker Tools Apk
  104. Hacking App
  105. Hacker Tools Online
  106. Hacks And Tools
  107. Pentest Tools Subdomain
  108. Hacking Tools For Games
  109. Hacking Tools Free Download
  110. Pentest Tools Free
  111. Install Pentest Tools Ubuntu
  112. Hacker Tools Github
  113. Hack App
  114. Hack Tools For Windows
  115. Pentest Tools Github
  116. Pentest Tools
  117. Hacker Tools Windows
  118. Termux Hacking Tools 2019
  119. Hack Tools For Ubuntu
  120. Nsa Hack Tools Download
  121. Hacks And Tools
  122. Hack Rom Tools
  123. Pentest Tools Url Fuzzer
  124. New Hack Tools
  125. Pentest Tools Github
  126. World No 1 Hacker Software
  127. Hacks And Tools
  128. Hacking Tools For Mac
  129. What Is Hacking Tools
  130. Best Hacking Tools 2019
  131. Beginner Hacker Tools
  132. Physical Pentest Tools
  133. Hacking Tools Hardware
  134. Black Hat Hacker Tools
  135. Hack Tools For Ubuntu
  136. Nsa Hack Tools Download
  137. Hacker Tools For Mac
  138. Pentest Tools
  139. Hacking Tools For Windows Free Download
  140. Hack Tool Apk No Root
  141. Pentest Tools Alternative
  142. Github Hacking Tools
  143. Pentest Tools For Windows
  144. Nsa Hack Tools
  145. Hacking Tools For Windows Free Download
  146. Hacking Tools
  147. Hacking Tools For Kali Linux
  148. Hack Tool Apk
  149. Hacking Tools Name
  150. Pentest Tools Review
  151. Termux Hacking Tools 2019
  152. Hacker Tools Github
  153. Top Pentest Tools
  154. Hacker Tools Online
  155. Hacking Apps
  156. New Hacker Tools
  157. Hacking Tools Software
  158. Pentest Reporting Tools
  159. Wifi Hacker Tools For Windows
  160. Hack Tools Github
  161. Hack Tools For Pc
  162. Hacking App
  163. Pentest Tools Download
  164. Hacker Tools Mac
  165. Hacker Tools

0 comments:

Post a Comment