2024年1月24日水曜日

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 posts
  1. How To Hack
  2. Pentest Tools Url Fuzzer
  3. Hacking Tools Hardware
  4. Hack Apps
  5. Best Hacking Tools 2019
  6. Hacker Tools List
  7. Pentest Tools Port Scanner
  8. Hacker Hardware Tools
  9. Pentest Tools Url Fuzzer
  10. Hacking Tools For Windows 7
  11. Hacking Tools For Windows 7
  12. Pentest Tools List
  13. Best Hacking Tools 2020
  14. Hacking Tools 2019
  15. Hacking Tools For Mac
  16. Pentest Tools Apk
  17. Underground Hacker Sites
  18. Free Pentest Tools For Windows
  19. Tools 4 Hack
  20. Bluetooth Hacking Tools Kali
  21. Hack Tool Apk
  22. Free Pentest Tools For Windows
  23. Hackers Toolbox
  24. Hacking Tools For Kali Linux
  25. Tools For Hacker
  26. Hacking Tools Name
  27. Pentest Tools Kali Linux
  28. Pentest Tools For Windows
  29. Hacker Tools 2019
  30. Hack Tools For Mac
  31. Growth Hacker Tools
  32. Hacking Tools And Software
  33. Hacking App
  34. Pentest Tools
  35. Hacking Tools For Windows Free Download
  36. Hacks And Tools
  37. Hacking Tools For Windows Free Download
  38. Hacking Tools Windows
  39. Hacker Tools For Mac
  40. Best Pentesting Tools 2018
  41. Hacking Tools For Kali Linux
  42. Hacking Tools Windows
  43. Hacker Tools Github
  44. Pentest Tools Alternative
  45. Hacking Tools Mac
  46. Hacking Tools For Windows Free Download
  47. What Is Hacking Tools
  48. Hacking App
  49. Bluetooth Hacking Tools Kali
  50. Kik Hack Tools
  51. Pentest Tools Github
  52. Hacker Tools List
  53. Hacking Tools Mac
  54. Hacking Tools Usb
  55. Hack Tools 2019
  56. Github Hacking Tools
  57. Hacker Tools For Pc
  58. Usb Pentest Tools
  59. Kik Hack Tools
  60. Computer Hacker
  61. Hacking Tools Software
  62. Pentest Tools For Mac
  63. Pentest Tools Subdomain
  64. Hack App
  65. Hacking Tools Online
  66. Hacking App
  67. Termux Hacking Tools 2019
  68. Android Hack Tools Github
  69. Tools Used For Hacking
  70. Hacker Tools
  71. New Hacker Tools
  72. Hacking Tools Name
  73. What Is Hacking Tools
  74. Pentest Tools Review
  75. Hack Tools For Games
  76. Hacker Tools Online
  77. Bluetooth Hacking Tools Kali
  78. Hacker Tools
  79. Hack Tools
  80. Free Pentest Tools For Windows
  81. Hacker Tools 2020
  82. Hacker Tools Linux
  83. Hack App
  84. Bluetooth Hacking Tools Kali
  85. Install Pentest Tools Ubuntu
  86. Hacker Tools Free
  87. Best Hacking Tools 2019
  88. Hack Tools For Ubuntu
  89. Hacking App
  90. Hack Website Online Tool
  91. Hack Tools For Windows
  92. Hacking Tools For Windows 7
  93. Hacker Tools List
  94. Hacking App
  95. Hak5 Tools
  96. Hacker Tools Online
  97. Hacking Tools 2019
  98. Pentest Box Tools Download
  99. Pentest Tools Android
  100. Free Pentest Tools For Windows
  101. Pentest Tools Kali Linux
  102. Hacker Tools 2020
  103. Blackhat Hacker Tools
  104. Hack Tools Download
  105. Hak5 Tools
  106. Hacks And Tools
  107. Hack Tools Online
  108. Game Hacking
  109. Hack Tool Apk
  110. Hack Website Online Tool
  111. Hacker Tools Online
  112. Pentest Box Tools Download
  113. Hacking Tools For Beginners
  114. Hacking Tools And Software
  115. Pentest Tools For Windows
  116. Android Hack Tools Github
  117. Hack Rom Tools
  118. Pentest Tools Alternative
  119. Pentest Tools Apk
  120. Hak5 Tools
  121. Bluetooth Hacking Tools Kali
  122. Hacks And Tools
  123. Pentest Recon Tools
  124. Hacking Tools Online
  125. Hacker Tools Mac
  126. Pentest Tools Apk
  127. Pentest Tools Kali Linux
  128. Ethical Hacker Tools
  129. Hacker Tools Apk Download
  130. Hack Website Online Tool
  131. Pentest Tools Tcp Port Scanner
  132. Hacking Tools Windows
  133. Hacking Apps
  134. Hacker Search Tools
  135. Hackrf Tools
  136. Best Hacking Tools 2020
  137. Pentest Tools Android
  138. Pentest Tools
  139. Hacking Tools For Kali Linux
  140. Pentest Tools Free
  141. Hack Tools Github

0 件のコメント:

コメントを投稿