Tuesday, May 30, 2023

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 articles


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

No comments:

Post a Comment