YouTube2Text

sudo = POWER!! (managing users in Linux) // Linux for Hackers // EP4 — Transcript

by NetworkChuck · 6,199 words · 965 segments · language en · Watch on YouTube

Full transcript

  1. 0:00managing users in linux this is
  2. 0:02essential you got to know this if you
  3. 0:03want to get into linux or become a
  4. 0:04hacker or do anything
  5. 0:06don't skip this so assemble the avengers
  6. 0:08we gotta stop thanos
  7. 0:14what
  8. 0:18welcome to linux for hackers and
  9. 0:20everyone because everyone
  10. 0:22needs to learn linux this is episode 4
  11. 0:24and you don't want to miss this when
  12. 0:25we're talking about user management user
  13. 0:27accounts and linux and we're pretty much
  14. 0:29going to cover everything from creating
  15. 0:30users deleting them changing them
  16. 0:32creating groups deleting those putting
  17. 0:34on the infinity gauntlet and giving
  18. 0:35yourself super godlike permissions
  19. 0:37which is also known as sudo or the
  20. 0:39sudoer's file we'll cover all that
  21. 0:41and yeah we're gonna assemble the
  22. 0:42avengers and stop thanos we're going to
  23. 0:44save the world and when i say we i mean
  24. 0:46we because you're going to do this with
  25. 0:47me you're getting a free
  26. 0:48linux lab right here in this video check
  27. 0:50the link in the description thanks to
  28. 0:52our sponsor
  29. 0:52hack the box academy it's seriously
  30. 0:54amazing free to sign up
  31. 0:55hack the box academy is basically a
  32. 0:57trading ground for hackers
  33. 0:59good hackers mind you so if you want to
  34. 1:00follow along with me learn how to manage
  35. 1:02users in linux and save the world
  36. 1:04then click the link below get signed up
  37. 1:05for free and you'll have a linux
  38. 1:07lab right here in your browser and then
  39. 1:09of course whatever else you want to
  40. 1:10learn regarding hacking it's there so
  41. 1:12check that out too also hack the box
  42. 1:13academy now has a student subscription
  43. 1:15and you get cpe credits for completing
  44. 1:18tier 1 modules or above
  45. 1:20kind of killer check it out link below
  46. 1:22to learn more have you hacked the
  47. 1:23youtube algorithm today let's make sure
  48. 1:25you do hit that like button subscribe
  49. 1:26comment
  50. 1:27notification bell let's hack youtube
  51. 1:28today ethically of course
  52. 1:30anyways no time to waste get your
  53. 1:32stinking coffee let's do this
  54. 1:35right now okay here we go we're going to
  55. 1:37learn nearly everything you need to know
  56. 1:38about managing users and linux
  57. 1:40and we're gonna have a bit of fun with
  58. 1:42it too so get your copy and let's go
  59. 1:44now first we gotta launch our lab our
  60. 1:46free linux lab from hack the box academy
  61. 1:49so go ahead and navigate out there
  62. 1:50hack the blogs account of me they are
  63. 1:52our sponsor and they're amazing it's
  64. 1:54completely free if you haven't already
  65. 1:55signed up we'll get signed up i've got a
  66. 1:56video walking you through that right
  67. 1:58here
  68. 1:58so log in to hack the box academy go and
  69. 2:00click on the linux fundamentals course
  70. 2:01to get started go ahead and open up the
  71. 2:03user management module right here and
  72. 2:05then to launch our free amazing phone
  73. 2:06box our lab
  74. 2:08scroll about halfway down and click on
  75. 2:09start instance and it's going to start
  76. 2:11quick coffee break just a little sip and
  77. 2:14it is ready go ahead and click on
  78. 2:15interact to uh
  79. 2:17interact with it and i've said it before
  80. 2:18this is amazing it's your free linux lab
  81. 2:20in your browser that you can mess with
  82. 2:22and break things and
  83. 2:23let's do this okay let's talk about
  84. 2:25users every computer system has a user
  85. 2:28including linux and you know what you're
  86. 2:30a user
  87. 2:32to be able to log into the server this
  88. 2:34linux box and do anything you have to be
  89. 2:36a user on the system which user are you
  90. 2:38let's see in a previous video we showed
  91. 2:40this already so let's go ahead and
  92. 2:41launch our terminal
  93. 2:42our green or yellow box up at the top
  94. 2:44here this is launching our shell
  95. 2:46if you don't know what that is we'll go
  96. 2:47back to the last video and watch that
  97. 2:48one we talk all about it to quickly see
  98. 2:50who you are you simply type in who
  99. 2:52am i and there you are your user account
  100. 2:55and you as user 86527 can log into this
  101. 2:58linux machine
  102. 2:58and do stuff you can launch programs
  103. 3:00play games hack
  104. 3:01create things delete things if you have
  105. 3:03the right permissions we'll cover that
  106. 3:04here in a moment
  107. 3:05you you can do a lot of stuff as a user
  108. 3:07of the system but not all users are the
  109. 3:09same now hey
  110. 3:10i've got some bad news we're under
  111. 3:12attack our system our linux
  112. 3:14box here we're being attacked by
  113. 3:17thanos that's his name right the bad guy
  114. 3:19from avengers yes thanos he's attacking
  115. 3:21us
  116. 3:21bad guy thanos is gonna snap his fingers
  117. 3:23and destroy all our user accounts and we
  118. 3:24won't be able to have fun on linux
  119. 3:26anymore
  120. 3:26we have to stop him but how do we do
  121. 3:28that avengers assemble we need the
  122. 3:30avengers right let's call them do they
  123. 3:32have like a bat signal i don't know how
  124. 3:33you call them
  125. 3:34they just know they need help right or
  126. 3:35that we need help but they're not in our
  127. 3:37system right now we have to create these
  128. 3:38user accounts to come and stop thanos
  129. 3:40before he
  130. 3:41snaps anyways let's start by adding the
  131. 3:44avengers to our system
  132. 3:45let's start with thor he's my favorite
  133. 3:47so the command will be
  134. 3:49add user thor and honestly it's that
  135. 3:52simple that's all we need
  136. 3:53the command add user will obviously add
  137. 3:55a user but it's not the only one that
  138. 3:57does this by the way just so you know
  139. 3:59there's add user and then confusingly
  140. 4:01there's another one called
  141. 4:02user add which they do both add a user
  142. 4:06but this command right here is a little
  143. 4:07lazy
  144. 4:08he doesn't do as much whereas this
  145. 4:09command will do a lot i'll show you the
  146. 4:11difference here real quick we'll bring
  147. 4:12in our other avengers
  148. 4:13anyways let's add thor real quick now
  149. 4:14i'm going to hit enter but it's not
  150. 4:16going to work
  151. 4:17watch only root may add a user a group
  152. 4:19to the system now what is a root
  153. 4:21i mean root's another user on the system
  154. 4:23if you watched our previous videos in
  155. 4:24the series you would know all about root
  156. 4:26not groot
  157. 4:27root but we're going to temporarily
  158. 4:28borrow some power from the root which
  159. 4:30he's also known as the super user um so
  160. 4:33what we're going to do here is hit the
  161. 4:34up arrow to get our command back in
  162. 4:35there add user thor we're going to go to
  163. 4:37the beginning of our command
  164. 4:38and type in sudo or it's also often
  165. 4:41pronounced soo do but it's spelt sudo so
  166. 4:43i want to say that
  167. 4:44this is kind of like saying please in
  168. 4:45linux please do this i'm getting super
  169. 4:47powers to do this
  170. 4:48again i'll explain more about that here
  171. 4:50in a moment but anyways this is gonna
  172. 4:51work
  173. 4:52okay cool we got a fun prompt here let's
  174. 4:54put a password in for thor i'm gonna say
  175. 4:56hammer type it in again hammer full name
  176. 4:58i think it's just thor
  177. 5:00it'll ask you for all this random
  178. 5:01information you don't have to put it all
  179. 5:02in just enter enter enter
  180. 5:03is it correct sure and thor's created he
  181. 5:05is now a user on the system but how do
  182. 5:08we know that where
  183. 5:09is he well to find out what users are on
  184. 5:12your system there's one simple place to
  185. 5:13look
  186. 5:13i'm going to clear my screen real quick
  187. 5:15by typing in clear or i can just do
  188. 5:16control
  189. 5:17l whoo nice and clean there's a file in
  190. 5:19the system that has a list of every user
  191. 5:20on this
  192. 5:21box or this system we're going to use
  193. 5:23the command cat which we learned before
  194. 5:25we're going to cat the forward slash
  195. 5:27etsy forward slash pass
  196. 5:28wd when we do that here's what happens
  197. 5:31boom bunch of users on our system i bet
  198. 5:33you're surprised like where all these
  199. 5:35users come from i mean the first two we
  200. 5:36recognize right i mean the last two
  201. 5:38uh this one right here is us user blah
  202. 5:40blah
  203. 5:41and then thor the one we just created
  204. 5:42there he is all these other entries are
  205. 5:44indeed
  206. 5:45user accounts on this system and they do
  207. 5:47serve a purpose a lot of these you can't
  208. 5:48log in
  209. 5:49with like right here it says no login on
  210. 5:51this account they do serve a purpose not
  211. 5:53the topic for another video anyways now
  212. 5:55real quick
  213. 5:55what does all this right here mean it's
  214. 5:58kind of gobbledygook right i mean the
  215. 5:59first bit we understand what it is the
  216. 6:01username
  217. 6:02thor and user blah blah blah but what's
  218. 6:04all the stuff after it well just after
  219. 6:06the username we have
  220. 6:07just an x sitting there all by himself
  221. 6:09in fact you'll see this on pretty much
  222. 6:10every user account appear
  223. 6:12x max and what the x indicates is that
  224. 6:14your password is stored in a separate
  225. 6:16file called the
  226. 6:17shadow file more specifically it's in a
  227. 6:19place called etsy
  228. 6:21shadow in linux we store our passwords
  229. 6:23in the shadows where they're hidden you
  230. 6:25can't see them but for real
  231. 6:26if we go to it real quick we can
  232. 6:27actually look at it let's do cat
  233. 6:29etc etsy shadow oh permission deny we
  234. 6:32need some
  235. 6:33listen please sudo there we go and right
  236. 6:35here next to the username thor we have
  237. 6:37his password which that's actually not
  238. 6:38his password
  239. 6:39that's the hashed version topic for
  240. 6:41another time anyways now just after x we
  241. 6:43have two numbers
  242. 6:44and they're the same we have one
  243. 6:45thousand one and one thousand one what
  244. 6:48are those
  245. 6:48well those are his ids the first one is
  246. 6:52his user id or a uid it's a number
  247. 6:55which you can obviously see it's 1001.
  248. 6:57the second one is his
  249. 6:59group id we'll cover groups here in a
  250. 7:00second but just know that when we create
  251. 7:02a user in linux
  252. 7:03we both create a user and a group for
  253. 7:06that user so we have a username named
  254. 7:07thor
  255. 7:08we also have a group named thor and the
  256. 7:10member of that group
  257. 7:11is thor and then after that we got some
  258. 7:13like random filler stuff like his name
  259. 7:15and comments and stuff
  260. 7:16and then after that we have his home
  261. 7:19directory where he gives his hammer and
  262. 7:21his
  263. 7:21chest plate i don't know what thor has
  264. 7:23his hair ties for thor his home
  265. 7:25directory is in
  266. 7:26the same place that a lot of people's
  267. 7:27home directories are home
  268. 7:30and then a directory called thor we'll
  269. 7:32look at that here in a moment and then
  270. 7:33just after that
  271. 7:34we have his default shell when thor logs
  272. 7:37into the system
  273. 7:37what shell is he going to be given again
  274. 7:39if you don't know what i'm talking about
  275. 7:40go look at our previous video
  276. 7:42but by default when we created his user
  277. 7:44account with the add user command
  278. 7:46it's going to be bash so that is what
  279. 7:48all that gobbledygook means now let me
  280. 7:49show you what the user add command does
  281. 7:51our
  282. 7:52alternative command which is kind of
  283. 7:54weird so we have thor he's pretty
  284. 7:56awesome but we need some extra help
  285. 7:57i think we need iron man yeah yeah let's
  286. 7:59get iron man in here so we'll do sudo
  287. 8:01and instead of add user we're gonna
  288. 8:03we're gonna do user
  289. 8:05add and same as before we'll just type
  290. 8:07in the user name iron man
  291. 8:09and watch what happens here it is
  292. 8:11different it's simple
  293. 8:13that's it so remember add user like asks
  294. 8:16hey put in his password
  295. 8:17uh what's his first name last name
  296. 8:19what's social security number
  297. 8:21favorite flavor ice cream like all that
  298. 8:22stuff this one just says
  299. 8:24okay you're like uh what else
  300. 8:27what do i do now that's what i meant by
  301. 8:29saying that command is lazy because he
  302. 8:30doesn't do anything but just say okay
  303. 8:32yeah here's a user account i'm not gonna
  304. 8:33do anything else like
  305. 8:34set the password for you like you can do
  306. 8:36that yourself um and i'll show you how
  307. 8:37to do that here in a second but right
  308. 8:38now
  309. 8:39iron man is created but you can't really
  310. 8:40do much with him so if we cat our
  311. 8:42password file again to see what user
  312. 8:44accounts we have in our system cat
  313. 8:45slash etsy pass wd he's there iron man
  314. 8:49is shown up
  315. 8:49but there's a few things missing now for
  316. 8:51example he has the x there saying that
  317. 8:53his password's in the shadow file but is
  318. 8:54it really because we didn't set a
  319. 8:55password did we also notice here that
  320. 8:58um his default shell is different it's
  321. 9:00sh for
  322. 9:01shell instead of bash so real quick i
  323. 9:03want to take a look at the shadow file
  324. 9:05to see if the stuff is there
  325. 9:06that's interesting you can see that he
  326. 9:08does have
  327. 9:09an entry in the shadow file but it
  328. 9:11doesn't seem to be a password
  329. 9:12and i don't think it is but we can set
  330. 9:14this password real quick command to set
  331. 9:16a password for someone or change a
  332. 9:17password for any username
  333. 9:18is going to be password without the o-r
  334. 9:22i'll show you so we'll we'll need super
  335. 9:24powers sudo command is p-a-s-s-w-d
  336. 9:28and then the user name so i'll type in
  337. 9:30iron man and now we can set his password
  338. 9:32jarvis there we go he's got a legit hash
  339. 9:34there so we know it's working now one
  340. 9:36thing the ad user command did not do for
  341. 9:37iron man is it did not give him a home
  342. 9:39he doesn't have a house right now he
  343. 9:40doesn't have a home directory if i
  344. 9:41navigate to the home directory well all
  345. 9:42the
  346. 9:43user directories live i go cd forward
  347. 9:45slash home
  348. 9:46and i type in ls i can see there are two
  349. 9:48directories there for thor and then for
  350. 9:50me
  351. 9:51but iron man he doesn't have a home dude
  352. 9:53and that's one downside of using the
  353. 9:55user ad command
  354. 9:56is again he's lazy he doesn't do this
  355. 9:57kind of stuff if i jump into the thor
  356. 9:59directory by doing cd
  357. 10:01thor and then lsing his contents
  358. 10:04yeah he's got a desktop he's got
  359. 10:05templates if i do ls
  360. 10:07dash al to reveal the hidden files he's
  361. 10:10got a bunch of stuff going on in there
  362. 10:11which we're not going to get into right
  363. 10:13now i mean it is important but right now
  364. 10:14we got to save the world
  365. 10:15thor is here and he's coming clear our
  366. 10:17screen now if we cap the password file
  367. 10:19again
  368. 10:20etsy pass wd i'm super annoyed that iron
  369. 10:23man's
  370. 10:24default shell is not the same as
  371. 10:25everyone else's it's just sh
  372. 10:27let's make sure it is bash we can modify
  373. 10:29user account new command time are you
  374. 10:31ready the command is
  375. 10:32user mod which stands for user
  376. 10:34modification and as you might expect it
  377. 10:36will modify a user account now there are
  378. 10:38a ton of things we can change if you do
  379. 10:40dash h for help to see like what can i
  380. 10:42do with this it'll tell you
  381. 10:44a lot of stuff and i'm not going to
  382. 10:46cover everything right now that take
  383. 10:47forever and
  384. 10:48thanos is here so i'll do sudo because
  385. 10:50we will need special permissions
  386. 10:52user mod and let's say i want to change
  387. 10:53that shell for iron man
  388. 10:55i'll do iron man say that's who i want
  389. 10:57to change it for
  390. 10:58dash dash shell and i'll say ben
  391. 11:02bash done and if we cap the user or the
  392. 11:05cat the password file once more welcome
  393. 11:07iron man you now are using bash just
  394. 11:09like everyone else
  395. 11:09and we can change other things too like
  396. 11:11maybe his name like sometimes iron man
  397. 11:13isn't iron man sometimes he's tony stark
  398. 11:15so if we do sudo user mod once more
  399. 11:18we'll use the switch
  400. 11:19dash l and then we'll put in the new
  401. 11:22information
  402. 11:23tony stark that's his new username and
  403. 11:25then the old one
  404. 11:26iron man done so if i cat the password
  405. 11:30file once more
  406. 11:30huh he's tony stark now but we don't
  407. 11:32need tony stark right now we need iron
  408. 11:33man let's change it back
  409. 11:35okay better okay here we go now again
  410. 11:37thanos is here and we need more than
  411. 11:38just two avengers
  412. 11:40avengers assemble let's create more
  413. 11:42right now real quick
  414. 11:43fast and that is where the user add
  415. 11:45command comes in handy because you can
  416. 11:46add things really quickly enough to go
  417. 11:47through a menu every single time so
  418. 11:49we'll just do it real quick
  419. 11:50and we also have switches to help us
  420. 11:51with that if i do user add dash h
  421. 11:53we can do a lot of the stuff that the
  422. 11:55add user command does just in one line
  423. 11:57so i'll do user add let's bring in
  424. 12:01hulk and i'll do a dash m which dash m
  425. 12:04will actually create a home directory
  426. 12:05form so whereas iron man didn't get one
  427. 12:07by default i almost forgot we need
  428. 12:09superhero permissions there we go let's
  429. 12:11get spider-man in here
  430. 12:13loki why not oh we can't forget captain
  431. 12:15america
  432. 12:16and i suppose we'll need doctor strange
  433. 12:18i don't like that movie that much
  434. 12:19didn't like it at all wasn't a fan but
  435. 12:21he kind of played a key role so we'll
  436. 12:22put him in here
  437. 12:23so now we have some avengers if i do uh
  438. 12:26cat
  439. 12:27etsy password file boom
  440. 12:31we got them they're here if you've seen
  441. 12:33the movies you know it doesn't go
  442. 12:35great at first thanos does get the power
  443. 12:37he gets the
  444. 12:38the gauntlet or what is it called ah
  445. 12:40okay the infinity gauntlet almost forgot
  446. 12:42actually i did forget i had to look it
  447. 12:43up thanos has the power and he does
  448. 12:46flick his fingers or snaps fingers and
  449. 12:48do some bad stuff
  450. 12:50now i'm gonna add the user account
  451. 12:52thanos
  452. 12:53we're bringing him in he's there i'm
  453. 12:55going to set his password real quick
  454. 12:57password inevitable let's see if he's
  455. 13:00here yep there's thanos
  456. 13:01now here in linux the infinity gauntlet
  457. 13:03that gives you super
  458. 13:04awesome powers and has all the stones
  459. 13:06and you can flick your fingers and
  460. 13:07everyone disappears
  461. 13:09in linux that's definitely the pseudo
  462. 13:11command
  463. 13:12or pseudo we haven't really dived into
  464. 13:14that deeply just yet
  465. 13:16but right now we are it's a command we
  466. 13:17use all the time it stands for
  467. 13:20super user do essentially every time we
  468. 13:22use that command it's like we're
  469. 13:23slipping on the infinity gauntlet
  470. 13:24the super powerful glove and this is the
  471. 13:26worst glove you'll ever see we slip that
  472. 13:28glove on and for one moment
  473. 13:30we have powers to do whatever we frickin
  474. 13:31want so the sudo command or the sudo
  475. 13:33command
  476. 13:34were able to grab the powers of the
  477. 13:36super user the root user
  478. 13:37and use them for that command now the
  479. 13:40super user in the system
  480. 13:41which is the root user he's the boss he
  481. 13:43can do whatever stinking wants on linux
  482. 13:45he can change all the settings
  483. 13:46he can delete all the settings he can
  484. 13:48ruin everything delete half your stuff
  485. 13:50rmrf man that's what thanos is gonna do
  486. 13:54and if you can use the pseudo command to
  487. 13:55impersonate him just for a moment
  488. 13:57that's a pretty stinking powerful
  489. 13:59command it's a command that you don't
  490. 14:00want to just give to anyone you want to
  491. 14:02restrict that access and by default it
  492. 14:04is pretty restricted
  493. 14:05now you can see that right now we've
  494. 14:07been using sudo all day
  495. 14:08we have the infinity gauntlet we can put
  496. 14:10that sucker on and use it whenever we
  497. 14:11want to
  498. 14:12but not everyone can use it for example
  499. 14:14iron man he can't use it we can actually
  500. 14:16pretend to be iron man real quick
  501. 14:17new command time you ready the command
  502. 14:19is s u
  503. 14:20s u allows us to impersonate another
  504. 14:22user we're actually switching
  505. 14:24users we're becoming this user so let's
  506. 14:26become iron man
  507. 14:27i've always wanted to be iron man let's
  508. 14:29do this so again the command is su
  509. 14:31we'll do a space a dash or a tick space
  510. 14:33and then the username of who we want to
  511. 14:34switch into
  512. 14:35now real quick by default if you don't
  513. 14:37put anything here just
  514. 14:38su space dash it's going to switch you
  515. 14:41to the root user
  516. 14:42which we can do like watch and i don't
  517. 14:44know the root password
  518. 14:46um actually but we can do this we can
  519. 14:49put our gauntlet on
  520. 14:50put the affinity gauntlet on sudo su
  521. 14:54space dash i just became the root user i
  522. 14:57just became the infinity gauntlet which
  523. 14:58is kind of weird
  524. 14:59you never want to become the infinity
  525. 15:00gauntlet never log in as root that's why
  526. 15:02we have sudo so i'm going to hit ctrl
  527. 15:04d or we can just type in exit or
  528. 15:07log out either of any of those so i'll
  529. 15:10just do ctrl d
  530. 15:11to become myself again but anyways back
  531. 15:13to becoming iron man so i'll do su
  532. 15:14space dash iron man now doing this
  533. 15:18without the gauntlet on i will have to
  534. 15:20know iron man's password this goes for
  535. 15:22any time you use the su command but if i
  536. 15:24were to use sudo
  537. 15:25and put my gauntlet back on i don't have
  538. 15:27to put a password in but anyways
  539. 15:29i'll become iron man put his password in
  540. 15:31jarvis
  541. 15:32i'm iron man now iron man is pretty
  542. 15:34powerful but he cannot use a pseudo
  543. 15:35command let's try it real quick
  544. 15:37i'll do sudo and i'll try to add a user
  545. 15:39user add
  546. 15:40let's try to bring in pepper potts his
  547. 15:42wife right yeah wife
  548. 15:43that's gonna ask for a pseudo password
  549. 15:45okay just type in jarvis
  550. 15:47things are looking pretty good right no
  551. 15:49we're in trouble
  552. 15:50you're not in the sudoers file this
  553. 15:52incident will be reported you're like
  554. 15:54you're grounded iron man you can't do
  555. 15:56this i do love that we're talking about
  556. 15:57marvel and we have this spider-man line
  557. 15:59that comes in
  558. 16:00anyways that's an overused line anyway
  559. 16:02um so real quick
  560. 16:03what is this right here the sue doers
  561. 16:06file which is a very very awkward phrase
  562. 16:09basically this file the sudor's file
  563. 16:11defines
  564. 16:12who can use sudo who can wear the
  565. 16:14gauntlet right now iron man
  566. 16:16is not in that file so we can't put it
  567. 16:18on so what do you say we go take a look
  568. 16:19at that file i know you're itching to so
  569. 16:20let's do it real quick now the scooters
  570. 16:22file is a very important file that you
  571. 16:23don't want to jack up
  572. 16:24and you can jack it up you can ruin your
  573. 16:26entire system by
  574. 16:27messing up the scenarios file but there
  575. 16:29are some checks in place to keep you
  576. 16:30safe now normally in linux
  577. 16:31to edit a file you might just use your
  578. 16:33default text editor right the one you
  579. 16:35love like we might use
  580. 16:36nano or them but with a suitor's file
  581. 16:39the best practice is to do but with the
  582. 16:40scooter
  583. 16:41but with these two doors file there's a
  584. 16:42certain way we have to do it now we will
  585. 16:44have to use sudo to do this so i'm going
  586. 16:45to stop being iron man for a second i'm
  587. 16:47going to
  588. 16:48ctrl d to log out of iron man okay i'm
  589. 16:50me again the command will be sudo
  590. 16:52and then right after that it'll be vi
  591. 16:56sudo this is the only best practice
  592. 16:58recommended way to
  593. 16:59edit the sudoers file so let's uh get in
  594. 17:02there and take a look and it's not a
  595. 17:03crazy big file either it's kind of
  596. 17:05simple in a way so i'll hit enter
  597. 17:07and we're in and then i'll scroll down
  598. 17:08through this document to
  599. 17:10about here right here is where we're
  600. 17:12able to see who's got permission to do
  601. 17:14what obviously root can use sudo and
  602. 17:16i'll explain what all this means here in
  603. 17:18a moment and then down here in this
  604. 17:19section we have allowed members of a
  605. 17:20group
  606. 17:21pseudo access or pseudo to execute any
  607. 17:23command and then just below that we have
  608. 17:25something else we have a percent sign
  609. 17:26and then
  610. 17:27pseudo this actually is a group and if
  611. 17:29you're a member of this group the sudo
  612. 17:31group
  613. 17:32well you can do all this and what this
  614. 17:34actually means is you can enter
  615. 17:35any command at all and you don't have to
  616. 17:37enter
  617. 17:39a password which is pretty dangerous
  618. 17:40kind of risky but
  619. 17:42it's okay so if you're in this file
  620. 17:45you have the power and thanos does have
  621. 17:47the power let's go ahead and add thanos
  622. 17:48real quick
  623. 17:49we'll pretend he's already in there so
  624. 17:51just under root i'm going to add thanos
  625. 17:53so we'll start with the username which
  626. 17:54is
  627. 17:55thanos the first option here is what
  628. 17:57systems
  629. 17:58can thanos have ultimate power on well
  630. 18:01it's the infinity gauntlet
  631. 18:02all systems and this would be if they're
  632. 18:04like multi-system situations but
  633. 18:06and then i'll do a space equals not plus
  634. 18:09sign
  635. 18:09equals all and that all stands for all
  636. 18:13commands now if you want to just give
  637. 18:15thanos options to do one thing like
  638. 18:16maybe add a user we might do forward
  639. 18:18slash
  640. 18:19sbn forward slash user add giving him
  641. 18:22access to that one command
  642. 18:24we don't want to do that thanos has all
  643. 18:26power
  644. 18:27oh and that's all we need i'm going to
  645. 18:29hit control
  646. 18:30x to say i want out of here don't want
  647. 18:32to save it hit y
  648. 18:33hit enter to write it to that file and
  649. 18:36thanos is there
  650. 18:37he's got the gauntlet on he can do
  651. 18:38whatever he wants let's see if he can
  652. 18:40we're going to become thanos for a
  653. 18:41second so i'll do sudo
  654. 18:44su space dash space thanos
  655. 18:47we're thanos right now so let's do sudo
  656. 18:49user ad what's another bad guy he uses
  657. 18:51oh yeah his daughter nebulous little
  658. 18:53spring nebula in here the stanos have
  659. 18:55access let's see
  660. 18:57what's his password inevitable yep
  661. 19:00it did it worked so let's cap the uh
  662. 19:03password file yep there's nebula
  663. 19:05so thanos has ultimate power he's got
  664. 19:07the gauntlet on
  665. 19:08and crap he's about to snap you ready
  666. 19:11he's going to delete half the
  667. 19:12population in our case half the avengers
  668. 19:14we have here to delete a user
  669. 19:16new new command time it's terrible but
  670. 19:19new command time coffee break
  671. 19:22okay i'm ready sudo user
  672. 19:25del or user delete as you might expect
  673. 19:28this command will
  674. 19:29delete a user and we'll take out thor
  675. 19:32thor is gone if we catch the password
  676. 19:35file
  677. 19:36thor he's gone pseudo user delete
  678. 19:39spider-man gone bye doctor strange
  679. 19:43gone and just like that with a snap of
  680. 19:44his fingers we're down to
  681. 19:46hulk loki and captain america oh and
  682. 19:49iron man two there he is
  683. 19:50and just when it seems hopeless just
  684. 19:52when it seems all is lost the avengers
  685. 19:54have a plan ant-man comes in somehow
  686. 19:56quantum stuff anyways we need the
  687. 19:57gauntlet we need pseudo access to be
  688. 19:59able to
  689. 20:00bring captain america back and all the
  690. 20:01other people got got deleted so let's do
  691. 20:03this right now so
  692. 20:04we're gonna explore a new concept we're
  693. 20:06going to create a group to do that
  694. 20:08new command time here we go we'll do
  695. 20:11sudo group
  696. 20:12add and as you might expect group add
  697. 20:14will simply add a new group i'll do a
  698. 20:16space i'll name my group
  699. 20:18infinite
  700. 20:21gauntlet does spell that right i don't
  701. 20:24care that's what it's going to be called
  702. 20:26and the group is there but how do we
  703. 20:28know where is that group at
  704. 20:29well just like we have a password file
  705. 20:31to look at our users in the system
  706. 20:33we have a file to look at the groups and
  707. 20:35it's much more self-explanatory it makes
  708. 20:37more sense
  709. 20:38i'm going to cat the etsy group
  710. 20:41file and there it is infinity gauntlet
  711. 20:45right there
  712. 20:45as well as every other group that was
  713. 20:47created for our users
  714. 20:49i told you whenever a user account is
  715. 20:50created also they have a group created
  716. 20:52for themselves as well
  717. 20:53now what i want to do is make sure that
  718. 20:54the members of the infinity gauntlet
  719. 20:56group
  720. 20:56do have ultimate power because you mean
  721. 20:58you should you have the infinity
  722. 21:00gauntlet on
  723. 21:00so we need to add the infinity gauntlet
  724. 21:02group to our sudoers file
  725. 21:04let's do that real quick so again we'll
  726. 21:05do sudo vi sudo to edit that file the
  727. 21:08only way to do it don't you ever do it a
  728. 21:09different way
  729. 21:10i'm just kidding but seriously um let's
  730. 21:13edit that file we're gonna scroll down
  731. 21:14to
  732. 21:15where we were and then right here right
  733. 21:17now we see that members of the sudo
  734. 21:19group
  735. 21:20can do whatever they want and actually
  736. 21:21real quick let me show you the reason we
  737. 21:23can do whatever we want
  738. 21:24is because we're members of the sudo
  739. 21:26group if i do
  740. 21:27actually new command time if you just
  741. 21:29type in group i'm sorry
  742. 21:31groups groot
  743. 21:34it'll tell you what groups you are a
  744. 21:36member of the current user account
  745. 21:37you're logged in as and here i'm a
  746. 21:38member of my own group user 86527
  747. 21:40and the pseudo group which gives me
  748. 21:43gauntlet
  749. 21:44access anyways let's make sure the
  750. 21:45gauntlet does have the appropriate
  751. 21:47permissions here so just under
  752. 21:49the sudo group i'm going to add percent
  753. 21:51infinity
  754. 21:54gauntlet make sure you spell it right
  755. 21:56i'll do a space and i'll pretty much
  756. 21:57copy the one just above it i'll say all
  757. 21:58which again is all systems
  758. 22:00space equal sign space i'll say no
  759. 22:02password which is nopa sswd like we see
  760. 22:05here
  761. 22:06i'll do a colon and say all essentially
  762. 22:08it's saying you can do everything you
  763. 22:09want
  764. 22:10all commands and you don't need a
  765. 22:11password you got all them stones
  766. 22:13anyways so i'm going to hit control now
  767. 22:16actually you know what real quick before
  768. 22:17i do that
  769. 22:18i'm going to mess it up like i mentioned
  770. 22:20before if you mess up your suitors file
  771. 22:22you can break the entire system
  772. 22:24there is some checks in there that'll
  773. 22:26keep you safe so i'll just go
  774. 22:29and i hit control x to get out of there
  775. 22:32yes to save hit enter it'll say whoa
  776. 22:35whoa whoa
  777. 22:36there is a syntax error right there not
  778. 22:38supposed to do that what are you doing
  779. 22:40what are you going to do now what do you
  780. 22:41want to do are you sure you want to save
  781. 22:42this if i hit enter it will give me some
  782. 22:44options
  783. 22:44and i love this it's like you might want
  784. 22:47to go edit it again hit e
  785. 22:48hit x to get out of there and don't save
  786. 22:50it just forget what you're doing you
  787. 22:51don't know what you're doing or says you
  788. 22:52know what if you're pretty confident
  789. 22:53just hit q and say you want to save it
  790. 22:55danger um let's be smart let's hit e to
  791. 22:59edit it
  792. 23:00and remove that crap we put in there and
  793. 23:02then we can hit ctrl
  794. 23:03x y and enter no errors we're good
  795. 23:07so the infinity gauntlet group does have
  796. 23:10ultimate sudo
  797. 23:11super user due powers and now what's
  798. 23:13left is the avengers have to somehow
  799. 23:15become part of that group
  800. 23:16put on the glove and change history and
  801. 23:18if you've seen the movie
  802. 23:19spoiler alert um iron man he does this
  803. 23:22so we need to somehow get iron man into
  804. 23:25the infinity gauntlet group let's do
  805. 23:26that right now now real quick let's
  806. 23:28demonstrate that iron man can't do crap
  807. 23:29right now so if i
  808. 23:30become iron man and i try to bring back
  809. 23:34spider-man i can't i don't have the
  810. 23:36glove i can't do it man iron man is
  811. 23:37helpless but let's add them to the group
  812. 23:39so to add a user to a group
  813. 23:40pretty simple we're going to use the
  814. 23:41same command we used earlier to modify a
  815. 23:43user the user mod command
  816. 23:45so we'll do sudo and keeping in mind i'm
  817. 23:47logged in as me now not ironman anymore
  818. 23:49i'll do sudo
  819. 23:50user mod and the switch is dash
  820. 23:53g now dash g by itself will add this
  821. 23:56user to a group
  822. 23:57but it will add it to that group and
  823. 23:59kind of eliminate all other groups
  824. 24:01you may not want to do that so we often
  825. 24:03want to change this to
  826. 24:04dash lowercase a capital g the a stands
  827. 24:08for append
  828. 24:08so this command here we're appending the
  829. 24:10groups that ironman
  830. 24:12is part of so just after dash ag we'll
  831. 24:15type in
  832. 24:16the group which is infinity gauntlet
  833. 24:19and then the user we want to add which
  834. 24:21will be iron man
  835. 24:22just like that iron man has the glove on
  836. 24:25we can actually see if that's happening
  837. 24:26by going to
  838. 24:27or catting the group file
  839. 24:30etsy group and here we can see the
  840. 24:33infinity gauntlet group
  841. 24:34the members over here on the right and
  842. 24:35there's iron man right there now again
  843. 24:37if you saw the movie you know that iron
  844. 24:38man and
  845. 24:39and thanos were kind of wrestling with
  846. 24:41the gloves so thanos was in the group
  847. 24:43too
  848. 24:43they kept going back and forth let me
  849. 24:45add thanos in there real quick
  850. 24:46so yes right now iron man and thanos are
  851. 24:48both part of this group they both have
  852. 24:49super awesome
  853. 24:50powerful pseudo access but eventually
  854. 24:53iron man does wrestle the
  855. 24:55glove off of thanos and puts it on
  856. 24:56himself so new command time how do you
  857. 24:58remove
  858. 24:59a user from a group this command is
  859. 25:01called g password
  860. 25:03the commands sometimes are weird um so
  861. 25:05we'll do sudo
  862. 25:06g pass wd we're gonna do dash d for
  863. 25:09delete specify the user we want to
  864. 25:11remove which will be
  865. 25:13thanos take that off take that take it
  866. 25:15and then we'll specify the group
  867. 25:17infinity gauntlet take that thanos look
  868. 25:20at the group once more
  869. 25:21no one's in there so anyways iron man he
  870. 25:23has the gauntlet
  871. 25:24he snaps his fingers and he creates the
  872. 25:27users we lost
  873. 25:28let me become iron man i am iron man
  874. 25:31pseudo
  875. 25:32user ad captain america pseudo
  876. 25:35user ad spiderman done we'll bring back
  877. 25:39doctor strange
  878. 25:40and i forgot who else but anyways you
  879. 25:41get the picture right iron man has the
  880. 25:43gauntlet on he has the power he's part
  881. 25:45of the group
  882. 25:46and he can now bring back everyone and
  883. 25:48shoot while he's at it let's defeat
  884. 25:50thanos right
  885. 25:51sudo user delete
  886. 25:55thanos here we go
  887. 25:58goodbye thanos and then finally iron man
  888. 26:00realizes the infinity gauntlet it's too
  889. 26:02powerful
  890. 26:03for anyone to possess so he destroys it
  891. 26:05i think that's what happens
  892. 26:06that's what we're going to do right now
  893. 26:07so using the principle of least
  894. 26:08privilege
  895. 26:09we're going to remove the the infinity
  896. 26:11gauntlet group we're going to delete
  897. 26:12that group by doing the
  898. 26:14group delete command in fact iron man
  899. 26:16will do it himself right now and he's
  900. 26:17going to
  901. 26:18delete his access to do it at the same
  902. 26:20time which is kind of weird right
  903. 26:21so sudo group delete uh new command time
  904. 26:25i forgot to sit man
  905. 26:26which obviously means we're gonna be
  906. 26:28deleting a group and the usage is pretty
  907. 26:30straightforward just after group delete
  908. 26:32we'll enter the name of the group
  909. 26:33infinity gauntlet now this does not
  910. 26:36delete any
  911. 26:37users in that group it just deletes the
  912. 26:39group and gone are also iron man's
  913. 26:41privileges to do anything special
  914. 26:42anymore
  915. 26:43for example if he got greedy and wanted
  916. 26:45to create the group once more
  917. 26:47sorry iron man you don't have it anymore
  918. 26:49and i think you have other problems to
  919. 26:50worry about
  920. 26:51we did it i think like we saved the
  921. 26:53world right i mean iron man's
  922. 26:54not okay but we we learned how to manage
  923. 26:57users and linux and in the process we
  924. 26:59assembled the avengers and took away the
  925. 27:01infinity gauntlet destroyed it and saved
  926. 27:03the world
  927. 27:04yeah but seriously we learned a lot
  928. 27:06today we learned how to manage users in
  929. 27:07linux
  930. 27:08add them delete them groups permissions
  931. 27:11all that
  932. 27:12and that's essential to managing a linux
  933. 27:13system to becoming a hacker to doing
  934. 27:16anything with linux now and
  935. 27:17pretty much every area of it involves
  936. 27:19linux and also if you want a quick
  937. 27:21review of what we covered in text form
  938. 27:23uh mosey on over to hack the box academy
  939. 27:25the page we were at the whole time
  940. 27:26and look it over they've got the
  941. 27:27commands we we talked about in text form
  942. 27:30and they also have a delightful quiz at
  943. 27:32the very bottom to test your knowledge
  944. 27:33and see how you do
  945. 27:34and if you get it right you earn cubes
  946. 27:36back which with the junk or cubes
  947. 27:38go watch episode one if you don't know
  948. 27:39what they are also if you want to test
  949. 27:41your skills even further
  950. 27:42i've got a quiz in the description below
  951. 27:44it's free click the link
  952. 27:45and uh let's see what you got and again
  953. 27:47huge shout out to our sponsor hack the
  954. 27:49box academy
  955. 27:50it's free to access right now to do what
  956. 27:52we've been doing here if you want to go
  957. 27:53further and learn how to hack wordpress
  958. 27:55and
  959. 27:55and do python stuff and just man just so
  960. 27:58many things
  961. 27:59check them out link below i'll catch you
  962. 28:01guys next time
  963. 28:03[Music]
  964. 28:17[Music]
  965. 28:18you

About this transcript

This page contains the full transcript of sudo = POWER!! (managing users in Linux) // Linux for Hackers // EP4 by NetworkChuck, generated from the public captions YouTube serves with the video. The transcript has 6,199 words across 965 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.