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

No comments: