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

No comments: