DIG DEEPER TO FIND WATER & NOT WIDER -P.M.PATEL

Friday, August 28, 2020

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 info


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

No comments:

Post a Comment