YouTube2Text

Linux Essentials for Ethical Hackers - Full InfoSec Course — Transcript

by freeCodeCamp.org · 53,297 words · 7,749 segments · language en · Watch on YouTube

Full transcript

  1. 0:00this linux course will teach you the
  2. 0:02basics you need to know as a penetration
  3. 0:04tester it was created by hackersploit
  4. 0:07who has one of the most popular cyber
  5. 0:09security channels on youtube hey guys
  6. 0:11hackersploit here back again with
  7. 0:13another video and welcome to the linux
  8. 0:15essentials for hackers the 20 you need
  9. 0:18to know and uh first of all let me
  10. 0:20explain to you what this series is about
  11. 0:22before we actually take a look at what
  12. 0:24we'll be covering and the various issues
  13. 0:27that uh you know uh
  14. 0:28beginners in infosec
  15. 0:30and ethical hacking usually face when
  16. 0:33dealing with the topic of linux so uh it
  17. 0:36comes as no surprise that linux is very
  18. 0:38very important uh to learn if you are
  19. 0:40going to get into infosec because uh you
  20. 0:42will be
  21. 0:43using various linux based uh offensive
  22. 0:47distributions like kali linux or parrot
  23. 0:49os and it's it's imperative that you
  24. 0:51understand how to use the system to your
  25. 0:53advantage how to become efficient at it
  26. 0:56and that's primarily what this course is
  27. 0:58focused on now if you are a system
  28. 1:00administrator then it is uh worth also
  29. 1:03going through this course because we'll
  30. 1:05be covering a various aspects that you
  31. 1:07might not have known about but again if
  32. 1:10you're a beginner this is perfect for
  33. 1:11you this will cover exactly what you
  34. 1:13need to know to be efficient and
  35. 1:16effective with linux uh when it comes
  36. 1:18down to pen testing or ethical hacking
  37. 1:21getting started is very simple if you
  38. 1:22are a pen tester or you're a beginner to
  39. 1:25linux uh you can install linux from
  40. 1:27scratch or run it in a virtual machine i
  41. 1:30prefer running you know installing it
  42. 1:32from scratch on a physical machine
  43. 1:34however if you are interested in you
  44. 1:36know delving into the various
  45. 1:38distributions that exist you can check
  46. 1:40out distrowatch.com and you can start
  47. 1:42playing around with them uh you know in
  48. 1:44a vm
  49. 1:45or you could opt to set up a linux
  50. 1:47server all right so that's pretty much
  51. 1:49all that i wanted to talk about in
  52. 1:51regards to an introduction to this
  53. 1:53course and without further ado let's get
  54. 1:55cracking
  55. 2:00in this video we're going to get started
  56. 2:02with taking a look at the various
  57. 2:03keyboard shortcuts that will help you
  58. 2:06navigate around the system much easier
  59. 2:08and work with the terminal at a much
  60. 2:10more efficient rate all right so let's
  61. 2:12get started now i'm currently using
  62. 2:14ubuntu you can be using any other linux
  63. 2:17distribution that you want
  64. 2:19and we're going to be primarily working
  65. 2:21with the terminal first before we
  66. 2:23actually delve into desktop environments
  67. 2:26uh and you know various other
  68. 2:28distributions so we're going to be using
  69. 2:30debian and again ubuntu is based off
  70. 2:32debian and for our package manager we'll
  71. 2:35be taking a look at the aptitude package
  72. 2:37manager but as i said we'll be delving
  73. 2:39into all of that later on all right so
  74. 2:41with ubuntu uh getting opening up a
  75. 2:44terminal with your keyboard is very
  76. 2:46simple you have your control alt n t key
  77. 2:49or you have your super and t if you're
  78. 2:51running debian or any other distribution
  79. 2:53so on ubuntu it's ctrl alt n t
  80. 2:56or your super nt and you can customize
  81. 2:58your keyboard shortcuts uh however you
  82. 3:01want all right so
  83. 3:02let me just uh let me just minimize this
  84. 3:04now uh the other interesting thing that
  85. 3:07you can do or very helpful thing that
  86. 3:09you can do when working with various
  87. 3:11windows it doesn't have to be a
  88. 3:13a terminal window is you can perform
  89. 3:16tiling and that is by using the super
  90. 3:17key and your arrow keys to direct the
  91. 3:20location of the windows and you can tile
  92. 3:22them appropriately right so as you can
  93. 3:25see i've used the super and up key and
  94. 3:27that maximizes it and of course i can
  95. 3:29take it to the left or i can take it to
  96. 3:31the right and i can you know leave it
  97. 3:33where where it was previously right so
  98. 3:35let me just expand it now let me talk
  99. 3:37about a font size right so font size is
  100. 3:40very easy to change and to actually
  101. 3:42increase and reduce so if i wanted to
  102. 3:44increase my font size i would use the
  103. 3:46control shift and the plus key on my
  104. 3:49keyboard and that would increase the
  105. 3:50font size right
  106. 3:52i can then minimize it by using the
  107. 3:54control and the minus key on my keyboard
  108. 3:56and that will reduce the font size so
  109. 3:58again increasing it is ctrl shift and
  110. 4:01and the plus key
  111. 4:03and reducing the font size is control
  112. 4:05and the minus key on your keyboard right
  113. 4:08so
  114. 4:09that is how to increase and reduce your
  115. 4:12font size now let's talk about
  116. 4:14actually clearing your screen which is
  117. 4:16very very simple so i'll just use a
  118. 4:18generic command here you don't have to
  119. 4:20worry about what that command is so if i
  120. 4:22wanted to clear my terminal i would
  121. 4:24simply say clear and that will get rid
  122. 4:26of all the content that was currently on
  123. 4:28the terminal however
  124. 4:30i can also use a keyboard
  125. 4:33keyboard shortcut so again if i just
  126. 4:36list the same command here i can use the
  127. 4:38control and l key and that will clear
  128. 4:40the terminal for me without me having to
  129. 4:42type the clear command all right so
  130. 4:44let's talk about some uh some other
  131. 4:46keyboard shortcuts that you should be
  132. 4:48aware of right so uh if we are working
  133. 4:51with a particular process so for example
  134. 4:54i can say
  135. 4:55nmap i can run a quick nmap scan here
  136. 4:58and i can just say sv
  137. 5:00192.168.1.1
  138. 5:02and we can hit enter i can use the
  139. 5:04control c key
  140. 5:06to actually end the currently running
  141. 5:09process and it will return you back to
  142. 5:11your uh to your shell uh in this case
  143. 5:14we're using the bash shell so if i want
  144. 5:16to end a process that's currently
  145. 5:18running like the one i was running which
  146. 5:20was nmap i use the control and c
  147. 5:22keyboard shortcut right now if i wanted
  148. 5:25to suspend or to pause this
  149. 5:27or to pause a particular task or a
  150. 5:30process i can use the control and z key
  151. 5:33right so if i was running nmap s v the
  152. 5:36same key or the same command i can type
  153. 5:39that out however here are other useful
  154. 5:41keyboard shortcuts that you can use so i
  155. 5:44can cycle through my previously used
  156. 5:46commands by using the up arrow key and
  157. 5:49that will again cycle through all my all
  158. 5:51my previously used commands so again i
  159. 5:53can just go to this previous command and
  160. 5:55hit enter and then i can use ctrl and z
  161. 5:58to actually uh pause and suspend that
  162. 6:00process uh in memory and remember it
  163. 6:03hasn't stopped it you have just
  164. 6:04suspended it all right now let's talk
  165. 6:06about tab uh
  166. 6:08let's talk about the tab key and auto
  167. 6:10completion right so uh we can use the
  168. 6:13tab key uh to auto complete file and
  169. 6:16directory names so let me just clear
  170. 6:18this out and i can use the control and l
  171. 6:20key so if i go to my uh well i can
  172. 6:22actually work from my home directory but
  173. 6:25let's say i wanted to cat a particular
  174. 6:28file so let me just list all the files
  175. 6:30in here so let's say i wanted to cat my
  176. 6:33let's see or let's say i wanted to get
  177. 6:35my my password file so again i can say
  178. 6:38cat
  179. 6:39etsy
  180. 6:40and i can say password right now
  181. 6:43if i wanted to auto complete this i
  182. 6:45could use the tab key and again it'll if
  183. 6:48i use it two times it will give me the
  184. 6:50various suggestions here so a single tab
  185. 6:52will auto complete it if it has an
  186. 6:55accurate uh id of of the particular file
  187. 6:58or directory you're referring to so
  188. 7:00again if i said uh if i give it a bit
  189. 7:02more information in regards to the file
  190. 7:04or directory i was looking for i would
  191. 7:07simply just hit tab and it gives me the
  192. 7:09file there however i can hit double tab
  193. 7:12and that again gives me the files that
  194. 7:14are related to the particular data that
  195. 7:17have entered here so again if i reduced
  196. 7:18it just to ap and i hit tab twice it
  197. 7:21will give us the recommendations as to
  198. 7:24uh in in reference to the to to the
  199. 7:27to the particular files that uh that
  200. 7:29begin with the word p and again if i can
  201. 7:31increase that uh probability or the
  202. 7:34specification of the file i'm looking
  203. 7:36i'm looking for by increasing the amount
  204. 7:38of letters so again
  205. 7:40again i can tap it twice and now you can
  206. 7:41see the results are more fine-tuned so
  207. 7:43again i can
  208. 7:45i can use tab to auto complete it to
  209. 7:47password and i can hit enter and that
  210. 7:49displays the contents of the password
  211. 7:50file so that is how to use uh the tab
  212. 7:53key and those are the various uh you
  213. 7:55know commands that uh or keyboard
  214. 7:57shortcuts that you can use while working
  215. 7:59in the terminal and hopefully those will
  216. 8:00make your life a whole lot easier so
  217. 8:02again control and l that clears
  218. 8:04everything for me
  219. 8:06now let's talk about how to close your
  220. 8:08terminal so again closing your terminal
  221. 8:10is very simple you can use the control
  222. 8:13shift and w key so again i can say
  223. 8:15control shift and w here
  224. 8:18right over here and that works pretty
  225. 8:20universally among all distributions so
  226. 8:22again control alt d that opens up your
  227. 8:25terminal uh increasing the font size
  228. 8:27control shift and the plus key and so on
  229. 8:30and so forth and you can tile your
  230. 8:32terminal or any window in your system by
  231. 8:34using the super key and your arrow keys
  232. 8:37or your directional keys here
  233. 8:39all right so those are all uh the basic
  234. 8:43keyboard shortcuts that i wanted to
  235. 8:44start off with i'll be referencing
  236. 8:46others throughout the series uh let me
  237. 8:48know which ones are i missed and i'll be
  238. 8:50seeing you in the next video in this
  239. 8:52series
  240. 8:56in this video we're going to be taking a
  241. 8:58look at file management and file
  242. 9:00manipulation uh in linux so let's get
  243. 9:03started so i'm just going to open up my
  244. 9:05terminal here and let's just expand this
  245. 9:08and let's increase the font size so we
  246. 9:10can see what's going on all right so
  247. 9:12let's start off with a bit of directory
  248. 9:15navigation and understanding uh what
  249. 9:18files exist within a directory right so
  250. 9:21the first question any beginner to linux
  251. 9:24has is when the in the terminal is how
  252. 9:26do i know where i am or how do i know
  253. 9:29what directory i'm in right so they want
  254. 9:31to know where where they actually exist
  255. 9:34in the linux file system so by default
  256. 9:37if you are logged in as a user uh you
  257. 9:39know that a user is not the root user uh
  258. 9:42so you know a normal user account for
  259. 9:44example i'm logged in as a lexis
  260. 9:47so i'm going to be in my current home
  261. 9:50directory now you can confirm this by
  262. 9:53typing in pwd all right pwd means print
  263. 9:57current working directory or print
  264. 9:59working directory and that is
  265. 10:01self-explanatory it prints the current
  266. 10:03directory that you are in and that you
  267. 10:06uh will be working in or any commands
  268. 10:08that you actually run will be executed
  269. 10:10within this directory right so i'm going
  270. 10:12to hit enter
  271. 10:14and as you can see it tells you i'm in
  272. 10:16the home alexis directory now user
  273. 10:18accounts are usually sorted out this way
  274. 10:21so the root account usually has its own
  275. 10:24folder in the root directory
  276. 10:26of the file system of the linux file
  277. 10:29system whereas other users like alexis
  278. 10:32here
  279. 10:33will be found within the home directory
  280. 10:35and then furthermore their own
  281. 10:36individual directories based on their
  282. 10:38usernames and this is where all their
  283. 10:40files will be stored all right which
  284. 10:42brings us to the next question which is
  285. 10:44how do i list the files within a
  286. 10:46particular directory and this is very
  287. 10:48simple we use the ls command which means
  288. 10:50list all right so i'm going to hit enter
  289. 10:53and this will list the files and the
  290. 10:56directories within the current directory
  291. 10:58right so i'm going to enter and as you
  292. 11:00can see it tells us within this current
  293. 11:02directory we we have the desktop
  294. 11:04directory uh the documents directory
  295. 11:07downloads etc etc right so
  296. 11:10this is the simple way of listing files
  297. 11:12now the ls command has the ability to be
  298. 11:15run with other arguments or commands or
  299. 11:18options that allow you to increase or to
  300. 11:21modify the way the output is
  301. 11:24or the way the files are displayed to
  302. 11:26you right so a quick example of this is
  303. 11:29by using the ls hyphen or dash l command
  304. 11:33all right so this will list all the
  305. 11:35files and directories in this directory
  306. 11:39uh in the format of a list or a table
  307. 11:42which makes it easier to read for users
  308. 11:45right so i'm going to hit enter and
  309. 11:46immediately you can see it gives you a
  310. 11:49vital information like the total
  311. 11:51right of here the permissions the owner
  312. 11:54the ownership of these files and
  313. 11:56directories
  314. 11:57you have the date modified and the name
  315. 11:59of the file uh of the files and
  316. 12:01directories
  317. 12:02all right so
  318. 12:04that is how to use ls in combination
  319. 12:06with another command now you can also
  320. 12:08get more output by combining the ls
  321. 12:11command with other options so again if
  322. 12:13we wanted to list all the files that are
  323. 12:15all the files and directories that are
  324. 12:17currently in this working directory i
  325. 12:19can use the a command which essentially
  326. 12:22is an abbreviation for all now when i
  327. 12:24say all in the context of a linux it
  328. 12:26means all hidden files all files within
  329. 12:29this directory will be displayed all
  330. 12:31right so if i list the files again here
  331. 12:33you can see that it only displays the
  332. 12:36the files and directories that are
  333. 12:38visible to users if we want to display
  334. 12:41all the files and directories including
  335. 12:43hidden files and directories we can say
  336. 12:44ls and we can say a
  337. 12:47all right and this again will give us
  338. 12:49all files and directories including
  339. 12:51hidden files and directory so you can
  340. 12:52see the hidden files in linux have the
  341. 12:55dot or the full stop
  342. 12:57before the file name here so again the
  343. 12:59bash aliases file is a file that is used
  344. 13:02in configuration of your bash profile so
  345. 13:05again it allows you to configure aliases
  346. 13:07when working with bash again so the
  347. 13:09hidden files in nx typically are used
  348. 13:12for configuration of various system uh
  349. 13:15system environment variables or various
  350. 13:18system tools uh you know so on and so
  351. 13:20forth we'll be working with this later
  352. 13:22on and it will all make sense shortly
  353. 13:25now the great thing about the list
  354. 13:26command is that i can use it in
  355. 13:28combination with the previous command so
  356. 13:30if i wanted to list this in a way that
  357. 13:32was much easier to read i can say ls a l
  358. 13:36and this will list all the files and
  359. 13:37directories including the hidden files
  360. 13:39and directories in the format of a list
  361. 13:42or a table and i hit enter and there you
  362. 13:44are you can see
  363. 13:46it displays all the files and
  364. 13:47directories in the form of a list here
  365. 13:49and again it gives you information in
  366. 13:51regards to the ownership and the
  367. 13:52permissions more of which we'll touch
  368. 13:54upon later on in the course all right so
  369. 13:57i'm just going to clear the terminal
  370. 13:58here and let's take a look at the ls
  371. 14:00command a little bit more all right so
  372. 14:02let's say i wanted to um to actually
  373. 14:05list the files um in a more
  374. 14:08readable format for users so again i can
  375. 14:11just type in ls
  376. 14:13l and i can use the h command all right
  377. 14:15so if i hit enter again this displays it
  378. 14:18in a much easier way for uh for users to
  379. 14:21understand what's going on and the
  380. 14:22context i'm referring to is more to do
  381. 14:26with the size all right so if i say ls l
  382. 14:28you can see that the data here or the
  383. 14:31size of the files is in bytes right now
  384. 14:34when we use the ls h or the h where the
  385. 14:37h stands for human readable format you
  386. 14:39can see it displays the actual size in
  387. 14:41kilobytes a much easier way for you to
  388. 14:44understand the sizes of files
  389. 14:46etc etc all right so let me just clear
  390. 14:49the terminal here
  391. 14:51and
  392. 14:52let's take a look at one more uh command
  393. 14:55that we can use with ls and that is if
  394. 14:58we wanted to uh show uh subdirectories
  395. 15:01right so remember when we show when we
  396. 15:03use the ls command
  397. 15:05it shows us the directories within this
  398. 15:07current working directory but let's say
  399. 15:09we had other directories within um let's
  400. 15:12see
  401. 15:13within pictures right so we could have
  402. 15:15other directories within pictures or
  403. 15:17documents or the downloads folder etc so
  404. 15:20again we can say
  405. 15:22uh if i wanted to list
  406. 15:24the the the subdirectories within the
  407. 15:26desktop folder i can say
  408. 15:29ls
  409. 15:30l and we'll use the capital r command
  410. 15:33and this again means recursively so we
  411. 15:36can then specify the folder we want
  412. 15:38which is going to be desktop or the
  413. 15:40directory we want again it's going to be
  414. 15:41desktop and we hit enter and again it
  415. 15:44will list for us the files that exist on
  416. 15:47the desktop first of all and again it
  417. 15:49shows us that we have
  418. 15:51a directory called c
  419. 15:53and a txt file called todo.txt
  420. 15:57all right within the c folder or the c
  421. 15:59directory we have three files we have a
  422. 16:02temp dot c
  423. 16:03we have a test binary and a test.c file
  424. 16:06so again it's displayed to us what is on
  425. 16:09the desktop and then what is uh what is
  426. 16:12in the directory c on the desktop so
  427. 16:14again it's used for recursive a listing
  428. 16:16of the of files and directories and sub
  429. 16:19directories that way all right so i hope
  430. 16:22that makes sense now let's talk about uh
  431. 16:24some directory navigation all right
  432. 16:27which is quite important here
  433. 16:29uh before we actually talk about uh file
  434. 16:31manipulation um and copying files etc so
  435. 16:36as i said we are currently in the home
  436. 16:38alexis directory now if i wanted to move
  437. 16:41a step back or to move to a parent
  438. 16:43directory i can say cp all right so cd
  439. 16:47will change directory to the actual home
  440. 16:49directory uh so again if i type in pwd
  441. 16:52you can see it will not do anything now
  442. 16:54if i wanted to go a step back i can type
  443. 16:57in cd
  444. 16:58and i can follow that or yes i can
  445. 17:01follow that up with two full stops and
  446. 17:03that will take me a step back and
  447. 17:06immediately on your bash shell you'll be
  448. 17:08given the current directory that you're
  449. 17:10in now so again it's telling us we are
  450. 17:12in the home directory and we can confirm
  451. 17:14this by typing in pwd right so if we
  452. 17:17list the files within the home directory
  453. 17:19you can see that the only directory that
  454. 17:21exists is the alexis folder and that's
  455. 17:23because that's the only use on the
  456. 17:25system so let's take a step back right
  457. 17:27so i can take a step back and i hit
  458. 17:30enter and now we are currently in the
  459. 17:32root directory the root file system
  460. 17:34directory for the off for linux right so
  461. 17:37again i can list all the files in here
  462. 17:39and i can hit enter and as you can see
  463. 17:41we are now in the root this is the
  464. 17:44actual root directory of the linux file
  465. 17:46system not the root folder or the root
  466. 17:48user directory just the root
  467. 17:51of the file system so
  468. 17:53you can now see all the various folders
  469. 17:55that the linux file system is comprised
  470. 17:57of all right so that is how to actually
  471. 18:00navigate a step back now if i wanted to
  472. 18:02navigate into any one of these
  473. 18:04directories i could say cd and then i
  474. 18:07specify cd is an abbreviation for change
  475. 18:11directory and i can specify the
  476. 18:12directory i want to move into so i can
  477. 18:15say cd home
  478. 18:16right and again that will take me into
  479. 18:18my home directory and then i can list
  480. 18:20the files in here and this tells me oh
  481. 18:22we have a directory called alexisd
  482. 18:24and then i can say change directory into
  483. 18:27the directory alexis and that will take
  484. 18:28me into the uh the directory alexis
  485. 18:32all right now i can also use um i can
  486. 18:36also use the forward slash to refer to a
  487. 18:39directory that is currently not in this
  488. 18:41particular directory so let's say i
  489. 18:44wanted to move into the um let's see
  490. 18:47i wanted to move into the
  491. 18:50um let's try the etsy folder i can say
  492. 18:54cd
  493. 18:56forward slash etsy and this refers to a
  494. 18:59directory that is currently not in this
  495. 19:01directory but at the root at the root of
  496. 19:04the linux file system so i hit enter and
  497. 19:07that takes us into the etsy folder so
  498. 19:09again i can confirm this by typing in
  499. 19:11pwd and again it tells me i'm currently
  500. 19:13in the etsy folder
  501. 19:15right now if i want to navigate back to
  502. 19:18my user home directory so i'm currently
  503. 19:21logged in as the user alexis if i want
  504. 19:24to go back to alexis home directory i
  505. 19:26can simply do this by typing
  506. 19:29home alexis right that's very very
  507. 19:31simple but if i want to even make this
  508. 19:33shorter i can use
  509. 19:35the command right over here and again i
  510. 19:38can hit enter
  511. 19:40and
  512. 19:41i can
  513. 19:42easily just navigate back to my home
  514. 19:43directory so if i hit enter you see and
  515. 19:46i type in pwd it's going to take me into
  516. 19:48my home directory right over here all
  517. 19:51right now that we have taken a look at
  518. 19:52you know directory navigation and moving
  519. 19:55around directories let's take a look at
  520. 19:57uh creating files copying etc all right
  521. 20:00so i'm currently on my in my home
  522. 20:02directory so let's talk about
  523. 20:05actually copying a file
  524. 20:07now before we actually do that we need
  525. 20:09to actually understand how to create
  526. 20:11files really really quickly right so
  527. 20:13the first thing i want to do is i'll go
  528. 20:16into my desktop here and i'll say cd
  529. 20:18desktop and i'm going to hit enter and
  530. 20:20i'm in my desktop now all right so if i
  531. 20:23wanted to create a file really easily i
  532. 20:26can use touch all right so touch is a
  533. 20:29is a tool or a utility that allows you
  534. 20:31to you know easily create files again
  535. 20:33let me show you a command that will help
  536. 20:35you understand what various commands and
  537. 20:37tools are so if i want to know uh
  538. 20:40i want information about a particular
  539. 20:42command i can use the what is
  540. 20:44the what is command so i can type in
  541. 20:46what is and then i can say what is touch
  542. 20:49and i can hit enter and again it tells
  543. 20:52me change the file timestamps all right
  544. 20:54or so i can also say what is
  545. 20:56uh let's see what is nano right nano is
  546. 20:59a text editor so i can hit enter and
  547. 21:02it's going to tell nano is another
  548. 21:03editor etc so it gives you information
  549. 21:05about a particular command or tool all
  550. 21:07right so i can use touch to create a
  551. 21:09file remember without any content right
  552. 21:11so i can say touch
  553. 21:13and i can say the file name is going to
  554. 21:15be test.txt
  555. 21:17all right i can hit enter and if i list
  556. 21:20all the files in the desktop you can see
  557. 21:22i have the test.txt file right over here
  558. 21:25all right so
  559. 21:27i can now
  560. 21:28direct data into this file so again i
  561. 21:30can use the ech command and if we want
  562. 21:33to learn more about the echo command i
  563. 21:34can type in what is and i can say echo
  564. 21:37and i can hit enter and it's going to
  565. 21:39say display a line of text right so we
  566. 21:41can say echo
  567. 21:43alexis is
  568. 21:46alexis is
  569. 21:47you can say alexis is not cool i know
  570. 21:51something like that
  571. 21:52and i can just hit enter and again it
  572. 21:54will display on our terminal alexis is
  573. 21:56not cool all right so it simply just
  574. 21:58displays a line of text however we can
  575. 22:00redirect this data into a particular
  576. 22:03file and in this case we want to dis we
  577. 22:06want to redirect this data into the
  578. 22:08test.txt file right so i can say echo
  579. 22:12we can say hello
  580. 22:14and we'll just use this simple string of
  581. 22:16text here and i can say
  582. 22:20redirect to this and we use the greater
  583. 22:22than sign to redirect data to a
  584. 22:25particular file or to a particular
  585. 22:27command so i can say test dot txt all
  586. 22:30right and i hit enter and now this file
  587. 22:34should have the words or the string
  588. 22:36hello now if you want to easily just
  589. 22:39display the context uh or the content of
  590. 22:41a file i can use the cat command all
  591. 22:43right now again we can use the what is
  592. 22:45command to find uh to find out more
  593. 22:48about what the
  594. 22:49cat command does so i can hit enter and
  595. 22:51it's going to tell us it concatenates
  596. 22:53files and prints on the standard output
  597. 22:55so again it gives us the output of all
  598. 22:57the content it prints out the content of
  599. 22:59a particular file uh so again i can say
  600. 23:01cat test dot txt and hit enter and again
  601. 23:05it prints out what we had redirected
  602. 23:07into it
  603. 23:09all right so that is how to use the cat
  604. 23:11command now again i can redirect a lot
  605. 23:13of text into this uh so let's say i
  606. 23:15wanted to edit this uh this file or i
  607. 23:18wanted to remove this file which is a
  608. 23:20much better way of actually taking a
  609. 23:21look at you know file manipulation
  610. 23:24technique so again i've shown you how to
  611. 23:25create a file a very simple file
  612. 23:27redirecting output
  613. 23:28we can also
  614. 23:30use cat to redirect output so for
  615. 23:32example if i wanted to redirect the
  616. 23:34contents of the password file i can say
  617. 23:37cat hc password and i'm using the
  618. 23:39relative directory you can see here so
  619. 23:41the the the contents of the password
  620. 23:44file i want to redirect into the
  621. 23:47test.txt file however if i wanted to
  622. 23:50create another file i could easily do it
  623. 23:52directly from here i could say password
  624. 23:54dot txt and i hit enter and now we can
  625. 23:57display the contents of the password.txt
  626. 24:00file and again i can use the tab
  627. 24:02autocompletion here and i hit enter and
  628. 24:04again it gives us all the content was
  629. 24:06redirected into this new txt file
  630. 24:09excellent so now let's talk about
  631. 24:11actually you know create removing files
  632. 24:14copying them etc so if i wanted to
  633. 24:16remove this file here the test.txt file
  634. 24:20i use the rm command which stands for
  635. 24:22remove right again you can use the what
  636. 24:24is command and again use it again it
  637. 24:26tells you this is used to remove files
  638. 24:28and directories so let's talk about
  639. 24:30removing files first
  640. 24:33all right so we can say remove uh test
  641. 24:35dot txt all right and again we use tab
  642. 24:39auto completion and i hit enter and this
  643. 24:41will have removed the file over here
  644. 24:44right so um
  645. 24:46that is essentially how to remove a file
  646. 24:48now
  647. 24:50uh if i want to remove a directory uh i
  648. 24:53can now i need to specify that it is a
  649. 24:56recursive action but before we do that
  650. 24:58let's talk about creating a directory
  651. 25:00first because that that's quite
  652. 25:02important as well so if i want to create
  653. 25:04a directory i use the make directory
  654. 25:06command which is abbreviated into mkdir
  655. 25:09so make a directory and i give it a name
  656. 25:12so i can say test all right so this is
  657. 25:13going to create a folder or id or a
  658. 25:16directory called test
  659. 25:18right once i hit enter and i list all
  660. 25:20the files here you can see we have the
  661. 25:21test directory over here uh so what i
  662. 25:24can do is
  663. 25:26i can you know i can navigate into it i
  664. 25:28can copy files into it so let's say i
  665. 25:31wanted to copy a file into this uh
  666. 25:33directory so again i can say
  667. 25:36let's say i wanted to say touch um or we
  668. 25:39can do the same thing so i can say cat
  669. 25:41etsy
  670. 25:43password and i want to redirect this
  671. 25:45into a file called
  672. 25:47password.txt and once that is done i
  673. 25:50want to copy the file so i want to say
  674. 25:52cp that means copy and i want to specify
  675. 25:54the file that i want to copy which is
  676. 25:56going to be password dot txt and i want
  677. 25:59to copy that into the test directory so
  678. 26:01i specify the directory i want to copy
  679. 26:03in i want to copy it into
  680. 26:05in this case the test directory is
  681. 26:07within the current working directory so
  682. 26:09i don't have to specify a relative path
  683. 26:11if i was specifying a relative path i
  684. 26:13would use the forward slash here so i
  685. 26:15can just say test
  686. 26:17and i hit enter and now if i remember if
  687. 26:20i wanted to list the contents of the sub
  688. 26:22directories recursively i could say ls
  689. 26:25lr and i hit enter and you can see the
  690. 26:27contents of the test directory uh
  691. 26:30password.txt
  692. 26:32excellent so again if i want to remove
  693. 26:34the the password file i can say
  694. 26:36removepassword.txt
  695. 26:38if i want to remove a directory and the
  696. 26:40directory what we want to remove is the
  697. 26:42test directory i can say remove and i
  698. 26:44use the capital r which means
  699. 26:47recursively remove and i say test and i
  700. 26:50use the tab autocompletion and i hit
  701. 26:52enter and now if we list the files in
  702. 26:54the on the desktop you can see we've
  703. 26:56gotten rid of all of these folders and
  704. 26:59files
  705. 27:00all right so
  706. 27:01now that we know how to actually create
  707. 27:04a directory we can actually um
  708. 27:07let me talk about removing a directory i
  709. 27:09actually covered it with the remove
  710. 27:11command however we can also use um
  711. 27:14another command called remove directory
  712. 27:16which is abbreviated into rmdir
  713. 27:20this will only allow you to remove a
  714. 27:22directory if you do not have any files
  715. 27:24within that directory right so let's say
  716. 27:26i uh
  717. 27:28by the way you can cycle through your
  718. 27:30previously used commands using your
  719. 27:31arrow keys in this case you can use the
  720. 27:34uh the up arrow key so let's say i
  721. 27:36wanted to catch i wanted to you know
  722. 27:38redirect output of the password file
  723. 27:40into a file called password.txt and i
  724. 27:42wanted to copy this file or let's
  725. 27:45actually talk about
  726. 27:46moving files so if i wanted to move a
  727. 27:48file i would say mv and again you can
  728. 27:51use the what is command so what is mv
  729. 27:54so i can say mv i want to move the
  730. 27:57password txt file into the test
  731. 28:00directory here i'm going to hit enter
  732. 28:02and now you can see that the
  733. 28:04the password file has been moved into
  734. 28:06the test directory so again i can
  735. 28:09i can list all the files within the test
  736. 28:11directory here and that again it tells
  737. 28:13me that we only have the password.txt
  738. 28:15file in here so if i use the rm dir
  739. 28:19command which means remove directory and
  740. 28:21i say test remove directory test you can
  741. 28:24see it's going to tell me that this
  742. 28:26directory is not empty so as a result we
  743. 28:28need to specify remove
  744. 28:30recursively
  745. 28:32test and we're going to hit enter and
  746. 28:33now it gets rid of the test directory
  747. 28:36for us all right so those are uh very
  748. 28:39very simple ways of
  749. 28:41you know creating copying and of of
  750. 28:43course deleting commands now uh
  751. 28:45before we actually end this video which
  752. 28:47i know has been going on for quite a
  753. 28:49while i'm going to be covering file
  754. 28:50directory permissions later but i want
  755. 28:53to talk
  756. 28:53i want to talk about file manipulation a
  757. 28:56little bit more uh so we've talked about
  758. 28:58uh you know using the cat command
  759. 29:00redirecting output uh using touch as
  760. 29:02well moving files let's talk about you
  761. 29:05know renaming files
  762. 29:07uh and also taking a look at the content
  763. 29:09of particular files here so what i want
  764. 29:12to do now is
  765. 29:13let's actually take a look at um
  766. 29:16at actually renaming files all right so
  767. 29:18i'm going to again use the similar
  768. 29:20command that we had used i'm just going
  769. 29:21to you know
  770. 29:23i'm going to redirect the output of the
  771. 29:25password file into a file called
  772. 29:26password.txt
  773. 29:28and now if i wanted to rename the
  774. 29:30filepassword.txt
  775. 29:32into something else i would use the mv
  776. 29:34command right so there isn't a command
  777. 29:36to rename files in linux you use the mv
  778. 29:40command which means move
  779. 29:42in this case it's very simple the syntax
  780. 29:44is uh you specify the file that you want
  781. 29:47to change the name of which is going to
  782. 29:48be password.txt and i changed the file
  783. 29:51name to let's say
  784. 29:53test
  785. 29:54dot txt
  786. 29:56and hit enter and now if we list all the
  787. 29:58files in the directory you can see that
  788. 29:59it changes it to test.txt and indeed if
  789. 30:03we actually uh if we actually
  790. 30:06display the contents of the file you can
  791. 30:08see that the the content is preserved
  792. 30:10while we've changed the name and we can
  793. 30:12also change the extension of the file so
  794. 30:15i could say move
  795. 30:16test.txt into test
  796. 30:19let's say test.c we can we can change
  797. 30:22the contents into a c file right and now
  798. 30:24if i say uh cat test dot c
  799. 30:27i can hit enter and there you are now
  800. 30:29let's talk about uh editors and then
  801. 30:31i'll talk about the content of the files
  802. 30:33uh before we actually end this video so
  803. 30:37um
  804. 30:38there are two uh standard editors that
  805. 30:40are pretty much the standard when it
  806. 30:42comes to linux and working within the
  807. 30:44terminal i'm not talking about graphical
  808. 30:46uh gui based editors like uh g edit and
  809. 30:50stuff so if i wanted to edit this file
  810. 30:52within the terminal i have two options i
  811. 30:54have nano so again i can use the what is
  812. 30:57command and say what is nano and again
  813. 30:59that's an editor and i have we have vim
  814. 31:02which is pretty much the most popular
  815. 31:04option and i'll be making independent
  816. 31:06videos on this editors and how to
  817. 31:07configure them so again if i want to
  818. 31:10edit the test.txt file i can say nano
  819. 31:13test.tx
  820. 31:15test.c
  821. 31:16let's actually rename it back to
  822. 31:18test.txt
  823. 31:20dot txt and we say nano test
  824. 31:23dot txt and we're hit enter and that
  825. 31:26takes us into nano now exiting nano is
  826. 31:28very simple again you can navigate
  827. 31:30around make changes uh exiting it we use
  828. 31:32control and x and that's it now with v
  829. 31:35vim or vi we simply type in vi or vim
  830. 31:38and we say test.txt hit enter and again
  831. 31:42with them the syntax is very different
  832. 31:43if i want to make changes or i want to
  833. 31:45add content i type in i to insert text
  834. 31:48and again i can play around with it and
  835. 31:50once i'm done i hit escape and then i
  836. 31:52can write changes to this file or i can
  837. 31:54quit and discard any changes by typing
  838. 31:56in q
  839. 31:57and the exclamation mark and hit enter
  840. 32:00and that's how to use the various
  841. 32:01editors i'm not covering them uh you
  842. 32:03know to their full to their fullest
  843. 32:05extent and that's because we have
  844. 32:06various videos that will be actually
  845. 32:09focused on editors themselves so um
  846. 32:12that's pretty much all that i wanted to
  847. 32:13cover in this video there's quite a bit
  848. 32:15hopefully you guys can actually learn a
  849. 32:17lot from this video
  850. 32:22in this video we're going to be talking
  851. 32:23about file and directory permissions and
  852. 32:26ownership all right so again there's
  853. 32:28quite a bit to cover and hopefully i'll
  854. 32:30explain the various ways of doing it and
  855. 32:32i hopefully i can explain it as best as
  856. 32:34i can all right so let me just open up a
  857. 32:37terminal here and we can get started
  858. 32:38immediately right so
  859. 32:40let's just expand this and there we are
  860. 32:42all right so the first thing i'm going
  861. 32:44to do is i'm just going to go on to my
  862. 32:45desktop or change my directory onto my
  863. 32:48desktop and i'm just going to clear this
  864. 32:50now one thing i want to talk about
  865. 32:51before i actually get started if i list
  866. 32:53all the files in here you can see that
  867. 32:55directories will typically be
  868. 32:57highlighted in blue and to keep this on
  869. 33:00a standardized basis you want the color
  870. 33:02scheme for your terminal to be the linux
  871. 33:05console or you can use xterm if you want
  872. 33:07and again that will just keep it really
  873. 33:09standardized but for the purpose of this
  874. 33:11video i'm just going to stick to the
  875. 33:13linux console again just so directories
  876. 33:16and
  877. 33:17your directories are highlighted blue
  878. 33:19and again executable files are
  879. 33:21highlighted green all right so that'll
  880. 33:23keep things uh more simple and very easy
  881. 33:25to understand all right so let's get
  882. 33:27started so again if i list all the files
  883. 33:30in this directory uh you can see that um
  884. 33:34typically when i list it in the form of
  885. 33:36a list or a table we have various bits
  886. 33:38of information right so again i can also
  887. 33:41you know
  888. 33:42type this in and print it out print it
  889. 33:44out in human readable format but again
  890. 33:47that doesn't explain
  891. 33:49a lot of the information that already is
  892. 33:51here all right so we have the first
  893. 33:53column which is your file permissions
  894. 33:55file and directory permissions um you
  895. 33:58then have the user and the group all
  896. 34:01right so this is to do with ownership
  897. 34:03these two are to do with ownership you
  898. 34:05then have the file size uh and the date
  899. 34:07modified and of course you have the the
  900. 34:10file or the directory name
  901. 34:12as is
  902. 34:13as as is and as was created all right so
  903. 34:17what i'm going to do is the first thing
  904. 34:18i want to do is i'm just going to create
  905. 34:20a simple file i'm just going to call it
  906. 34:21test
  907. 34:23test dot sh because i know many of you
  908. 34:25don't like me sticking with one type of
  909. 34:27file
  910. 34:28and what i'm going to do is i'm just
  911. 34:29going to cut the contents of the
  912. 34:31password file
  913. 34:32into the test dot sh file right
  914. 34:36and i can just hit enter and we can
  915. 34:37clear this out and let me also create a
  916. 34:39directory here and we'll just call it
  917. 34:41test and let's clear this out all right
  918. 34:43so now if i list all the files here
  919. 34:45you can see that
  920. 34:47we have the new files that we just
  921. 34:49created test.sh and the test directory
  922. 34:52so
  923. 34:53if we take a look at the permissions for
  924. 34:55the sh file which is a shell file and is
  925. 34:58potentially executable however in this
  926. 35:00current state it isn't and you might be
  927. 35:02asking well why isn't it executable and
  928. 35:05that's where file and directory
  929. 35:07permissions come into play now
  930. 35:10permissions in linux are very very
  931. 35:11simple to understand now many people
  932. 35:14usually you know complicate it quite a
  933. 35:16bit and there isn't a need for this uh
  934. 35:19again there are two ways of handling it
  935. 35:21which is where most of the confusion
  936. 35:23starts that is the symbolic mode format
  937. 35:26and the uh the octal mode or the binary
  938. 35:29mode as it's so referred to as all right
  939. 35:32and these basically deal with various
  940. 35:34techniques as to which you can ascertain
  941. 35:36or set
  942. 35:37uh you know their various permissions
  943. 35:40for files and directories but the first
  944. 35:41thing you need to understand first of
  945. 35:43all if you're a beginner is there three
  946. 35:45types of permissions that you can apply
  947. 35:47to a file or directory in linux those
  948. 35:50are read which is represented by r as
  949. 35:53you can see right over here uh the the
  950. 35:55second one is the w or the right
  951. 35:58permissions and the last one is the x
  952. 36:01permission which stands for executable
  953. 36:03so these basically mean read this allows
  954. 36:06this means that you're allowed to read
  955. 36:08the file uh the right permission means
  956. 36:11you're allowed to write changes to the
  957. 36:13file and the x permission means you're
  958. 36:15allowed to execute the file now you
  959. 36:17might be saying well we have various uh
  960. 36:20various
  961. 36:21sequences of these permissions appearing
  962. 36:24here how is it sorted out and that's a
  963. 36:26very good question so let's take a
  964. 36:28simple example of the test.sh file right
  965. 36:31over here all right so first of all uh
  966. 36:34as you'll see right over here each of
  967. 36:36these is sorted into
  968. 36:38six uh into six columns however they're
  969. 36:41really not separated but that's how you
  970. 36:43have to understand them so you have your
  971. 36:44first one here you have your second one
  972. 36:47here and you have your third one here
  973. 36:49now this initial prefix here is
  974. 36:52is there to tell you the type of file
  975. 36:55you're dealing with in this case we're
  976. 36:56dealing with a file so it leaves that
  977. 36:58blank in the case of if of a directory
  978. 37:01it will be annotated by a d and that
  979. 37:04tells you that you're dealing with a
  980. 37:06directory all right so let's let's talk
  981. 37:08about the other columns here so the
  982. 37:10first uh the first one here is for the
  983. 37:13owner of the file alright so these are
  984. 37:16the owner permissions now when we're
  985. 37:18talking about ownership for this
  986. 37:19particular file we can see that the
  987. 37:21owner of the file and the group that it
  988. 37:23belongs to
  989. 37:25is alexis all right now if it belonged
  990. 37:27to another user that means that these
  991. 37:29permissions were specific to that
  992. 37:31particular user or the owner of the file
  993. 37:34the second column here is in uh these
  994. 37:37are the permissions for the group all
  995. 37:39right so again these are group
  996. 37:40permissions and the last one are for all
  997. 37:43other users on the system so let's say i
  998. 37:46created a file and i'm currently in the
  999. 37:48alexis uh the home alexis desktop
  1000. 37:51directory here
  1001. 37:52uh let's say i was logged in as another
  1002. 37:55user and i navigated into this directory
  1003. 37:59and i tried to execute this file over
  1004. 38:01here well given that i would be i was
  1005. 38:04using another user
  1006. 38:06the permissions for this file
  1007. 38:08explicitly state that i can read the
  1008. 38:11file however i cannot execute it or i
  1009. 38:14cannot write any particular changes to
  1010. 38:16it so hopefully that makes sense now
  1011. 38:19let's talk about changing these
  1012. 38:20permissions or setting these permissions
  1013. 38:22for these files now this is where the
  1014. 38:24chmod command comes into place all right
  1015. 38:28so the chmod commands allows you to
  1016. 38:30change the mode for files and
  1017. 38:32directories and allows you to change
  1018. 38:34permissions for the file and directories
  1019. 38:36so again i can say i can use the what is
  1020. 38:38command with chmod and you can see it
  1021. 38:41allows you to change the file mode bits
  1022. 38:43and change the permissions of a file or
  1023. 38:45directory right quite simple
  1024. 38:48now let's talk about this for a second
  1025. 38:49it's very easy to use we say chmod
  1026. 38:52and then we specify the options that we
  1027. 38:55want and finally after the options we
  1028. 38:57specify the file to which we want to
  1029. 39:00apply these permissions to all right so
  1030. 39:02very very simple syntax however as i
  1031. 39:04mentioned there are two ways of doing
  1032. 39:05this many people are comfortable with
  1033. 39:07their own way and i recommend that you
  1034. 39:09find your own way of going about this
  1035. 39:11but i will make a recommendation to make
  1036. 39:14things a whole lot easier and maybe uh
  1037. 39:16one way that you can understand it you
  1038. 39:18know a whole lot better all right so
  1039. 39:20that the the first way is by using the
  1040. 39:23symbolic mode format all right and the
  1041. 39:25second way is by using the octal
  1042. 39:28or the binary mode all right so let's
  1043. 39:31start off with the symbolic mode format
  1044. 39:34all right so let's say i wanted to
  1045. 39:36change the permissions
  1046. 39:38for the file
  1047. 39:39the file test dot sh right over here all
  1048. 39:42right so you can see that we we
  1049. 39:45currently cannot execute it so uh what
  1050. 39:47i'm going to do is let me just remove or
  1051. 39:50i can just
  1052. 39:51what i can do is just
  1053. 39:53get etsy or we can just say dev null and
  1054. 39:56don't worry what i'm doing here i just
  1055. 39:58want to
  1056. 40:01dot sh and we can actually just say echo
  1057. 40:05um we can say
  1058. 40:07echo hello world and we can just use
  1059. 40:10this and we can pipe that into the file
  1060. 40:13test.sh and now if we try and execute
  1061. 40:16this file
  1062. 40:17you can see that we hit enter we can see
  1063. 40:20that we do not have the particular or
  1064. 40:22the necessary permissions to execute
  1065. 40:24this so that will be our goal here our
  1066. 40:26goal is to set uh or to provide uh the
  1067. 40:29user lexis with executable permissions
  1068. 40:32all right so let me just list this one
  1069. 40:34more time and we can take a look at the
  1070. 40:35permission so for the owner alexis he
  1071. 40:38can only read and write changes to the
  1072. 40:41file which we we pretty much did already
  1073. 40:43uh for the group they can only read the
  1074. 40:45file uh and for all other users they can
  1075. 40:49only read it all right so let's talk
  1076. 40:50about the symbolic mode format
  1077. 40:52so the symbolic mode format is very
  1078. 40:55simple to understand of course i've
  1079. 40:56mentioned it has to do with the various
  1080. 40:58permissions so read write and execute
  1081. 41:01and it is done in conjunction with the
  1082. 41:03chmod command all right so now with the
  1083. 41:06chmod command i can now specify
  1084. 41:10the specification in regards to the
  1085. 41:12uh to the user the group uh
  1086. 41:16the uh the other or for all users all
  1087. 41:18right so what this means is
  1088. 41:20if i wanted to specify permissions or
  1089. 41:23set permissions for uh for the current
  1090. 41:25user i would do that by typing in chmod
  1091. 41:28u
  1092. 41:29and then i can add permissions i can say
  1093. 41:32you um i can say i can add permissions
  1094. 41:36by using the plus sign or i can say u is
  1095. 41:39equal to and then i would set the
  1096. 41:41permission so i can say user
  1097. 41:44the current user is going to be
  1098. 41:46read write and execute
  1099. 41:48we're going to provide this user with
  1100. 41:50the read write and execute permissions
  1101. 41:52and then we specify the file that we
  1102. 41:54want to apply these permissions to so i
  1103. 41:56can say test dot sh all right and i can
  1104. 41:59hit enter now if i list all the files
  1105. 42:01here again you can now see that the the
  1106. 42:04user alexis or the owner alexis has read
  1107. 42:08write an executable permissions which
  1108. 42:09means we can now execute this file and
  1109. 42:12we just entered a simple piece of uh
  1110. 42:14code here so again we can say test.sh
  1111. 42:17and again we we cannot we can actually
  1112. 42:19just modify this sorry uh we can say
  1113. 42:21just going to test.sh and we can just
  1114. 42:23say
  1115. 42:24echo
  1116. 42:25so that whenever we print it out we can
  1117. 42:27actually get those
  1118. 42:29this little string of text here again so
  1119. 42:31let me just write and exit there and you
  1120. 42:34can see that that was successful so
  1121. 42:36again if we execute the file here you
  1122. 42:38can see it prints out the string hello
  1123. 42:40world excellent so now we have set the
  1124. 42:42permissions for the user using the
  1125. 42:44symbolic mode format all right so we can
  1126. 42:47also remove permissions
  1127. 42:49uh and again i've shown you how to
  1128. 42:51explicitly set the permission so again
  1129. 42:53let's go over that one more second one
  1130. 42:55more time so chmod and now let's say we
  1131. 42:58wanted to apply uh these same
  1132. 43:00permissions for all the users on the
  1133. 43:03system all right and for for for for the
  1134. 43:06group all right so to do this we use the
  1135. 43:09group
  1136. 43:10uh and the o sign uh or we can also use
  1137. 43:13the a sign all right
  1138. 43:15and that will mean a group and all other
  1139. 43:18users on the system so group and all of
  1140. 43:20these users on the system so again the
  1141. 43:23standard definition is
  1142. 43:25for use the current user or the owner of
  1143. 43:27the file g is for the group uh and again
  1144. 43:30o is for other and a is for all all
  1145. 43:33right so that will set for all so we can
  1146. 43:35say group and we can then say group and
  1147. 43:37other
  1148. 43:38uh is will have read write and
  1149. 43:41executable permissions and then we
  1150. 43:43specify the file here and we hit enter
  1151. 43:46and then that will set the permissions
  1152. 43:47explicitly so again if we list all the
  1153. 43:49files now you can see that the the the
  1154. 43:52current user uh the group and all other
  1155. 43:55users have read write and executable
  1156. 43:57permissions which means i can now
  1157. 43:59execute this file if i was logged in as
  1158. 44:01another user that belongs to any other
  1159. 44:04group on the system which is not
  1160. 44:06recommended so let's talk about how to
  1161. 44:08remove these permissions all right so i
  1162. 44:10can say chmod
  1163. 44:13and let's say i wanted to remove the uh
  1164. 44:16the right and executable permissions for
  1165. 44:19for the groups and other users on the
  1166. 44:21system so again we say go and now we say
  1167. 44:25minus
  1168. 44:26wx so the right and executable
  1169. 44:29permissions and we say test dot sh and
  1170. 44:31we hit enter and now if we list all the
  1171. 44:34files here you can see that now we have
  1172. 44:36removed all these permissions so the
  1173. 44:39only the current user is only allowed to
  1174. 44:41read write and execute the file however
  1175. 44:43the group and the other users on the
  1176. 44:45system are only able to read it so that
  1177. 44:48is essentially how to use the symbolic
  1178. 44:50mode format so you can see it's a very
  1179. 44:52simple system to use let me just go over
  1180. 44:54it one more time we use the chmod
  1181. 44:57command we then specify the user uh the
  1182. 44:59group
  1183. 45:00uh other
  1184. 45:02uh other or all all right so again ugo a
  1185. 45:05that is the standard uh
  1186. 45:08the standard definition there and then
  1187. 45:10of course we use the plus or the equal
  1188. 45:12signs to add permissions or to
  1189. 45:14explicitly set them so for example if i
  1190. 45:18wanted to give the group execute
  1191. 45:20executable permissions i would say chmod
  1192. 45:24group plus x all right so we're setting
  1193. 45:27it for the group and we're giving it
  1194. 45:29executable permissions we then specify
  1195. 45:31the file
  1196. 45:32and we hit enter and now if we list all
  1197. 45:34the files here you can see that it gives
  1198. 45:36the group executable permissions so it
  1199. 45:39can read the file and execute it however
  1200. 45:41it cannot it cannot write changes to the
  1201. 45:43file so i can i can also get rid of it
  1202. 45:46so again chmod minus we can say group
  1203. 45:49minus x
  1204. 45:50uh so remove the executable permissions
  1205. 45:52and then we specify the file we hit
  1206. 45:55enter and again if we list the files
  1207. 45:57here you can see we're back to the old
  1208. 45:59uh permission so again a very simple way
  1209. 46:02of setting permissions
  1210. 46:04all right now let's talk about uh the
  1211. 46:06binary or the octal mode of setting
  1212. 46:09permissions
  1213. 46:10all right so now let's talk about the
  1214. 46:12octal or the binary mode of setting
  1215. 46:15permissions right which is again very
  1216. 46:17simple and is my preferred way of
  1217. 46:19actually going about doing it now again
  1218. 46:21as i said it's entirely up to you all
  1219. 46:23right so again we are still using the
  1220. 46:25chmod operator here and again this is
  1221. 46:29the standard so again we can say chmod
  1222. 46:31and then now when dealing with the
  1223. 46:34binary or the octal mode of setting
  1224. 46:36permissions
  1225. 46:37the read write and executable
  1226. 46:40permissions are now denoted in a binary
  1227. 46:43format and you might be saying well if
  1228. 46:45that's the case doesn't that make it a
  1229. 46:47little bit complex well i'll explain why
  1230. 46:50it it will not make it complex all right
  1231. 46:52so let me explain something so typically
  1232. 46:55as i said the read uh right and
  1233. 46:57executable permissions are now
  1234. 46:58represented by a binary value all right
  1235. 47:02so the read value is
  1236. 47:04the the read permission is represented
  1237. 47:06by a value of four all right the right
  1238. 47:09permission
  1239. 47:11is execute is uh is denoted or
  1240. 47:13represented by a value of two sorry and
  1241. 47:17the executable permission is represented
  1242. 47:20by a value of one all right and again
  1243. 47:23we're still following the previous uh
  1244. 47:26the previous format of going of actually
  1245. 47:28uh understanding permissions here so
  1246. 47:31again we have the uh the owner now the
  1247. 47:33owner of the file or the directory uh
  1248. 47:36you then have the group and others uh
  1249. 47:39other users on the system
  1250. 47:41all right so let's work with the test.sh
  1251. 47:44file and i'll talk about setting
  1252. 47:45directory permissions which is again
  1253. 47:47very very simple as well
  1254. 47:49all right so
  1255. 47:51let's say we wanted to get rid of the
  1256. 47:55the write and execute permissions for
  1257. 47:57the owner of the file which is right
  1258. 48:00over here you can see it has read write
  1259. 48:02and execute permissions so to do this
  1260. 48:04with the the binary mode or the octal
  1261. 48:08mode
  1262. 48:09again we need to specify chmod and now
  1263. 48:12the permissions if you already know
  1264. 48:14about this are now represented by the by
  1265. 48:17binary values all right so as i said for
  1266. 48:21the owner
  1267. 48:22we want to actually specify the
  1268. 48:25following so again we can say
  1269. 48:28chmod
  1270. 48:29and for the owner we need to specify the
  1271. 48:33we want to get rid of the right and
  1272. 48:35executable permissions so we only have
  1273. 48:38the
  1274. 48:38the write permission which again as we
  1275. 48:41said is going to have a value
  1276. 48:43of four all right so we start off with
  1277. 48:46the value of four so we're going to say
  1278. 48:47chmod four
  1279. 48:49and then for the other files uh uh also
  1280. 48:51for the other for the group and for the
  1281. 48:54other uh users on the system we want to
  1282. 48:56use the same permission we so we're
  1283. 48:59gonna say chmod four 444
  1284. 49:02and then we specify the file name
  1285. 49:05test.sh and we hit enter and now if we
  1286. 49:08list the files in here you can see that
  1287. 49:10now the file
  1288. 49:11only has read permissions
  1289. 49:14for the owner the group and other users
  1290. 49:16on the system all right so that's how to
  1291. 49:18set it now if i wanted to give the um
  1292. 49:21the owner of the file read write and
  1293. 49:23execute permissions we would need to add
  1294. 49:26these binary values together all right
  1295. 49:28so read is going to be equal to four all
  1296. 49:31right right is going to be equal to two
  1297. 49:34and um
  1298. 49:35and execute is going to be equal to one
  1299. 49:38all right so two plus four
  1300. 49:40is going to be six six plus one is going
  1301. 49:42to be 7. so we say chmod 7 that is for
  1302. 49:46the user permissions or the owner
  1303. 49:48permission so read write and execute
  1304. 49:50let's say for the group and the other
  1305. 49:54users on the system we want to give them
  1306. 49:56only read permissions which again is
  1307. 49:58denoted by four so that's four uh read
  1308. 50:02permissions for the group
  1309. 50:03and for other users on the system the
  1310. 50:05same thing and then we type in the name
  1311. 50:08of the file all right and i'm gonna hit
  1312. 50:10enter
  1313. 50:11and we can now display this and
  1314. 50:13immediately you can see we now have read
  1315. 50:15write and executable permissions for the
  1316. 50:17owner for for the group we only have
  1317. 50:19read permissions and for other users on
  1318. 50:22the system we only have read permissions
  1319. 50:24all right so that's very easy to
  1320. 50:25understand now if it is complex i will
  1321. 50:28leave a uh a resource in the description
  1322. 50:30section that has a table of all of these
  1323. 50:33permissions but the math is very simple
  1324. 50:35right so again we're simply adding 4
  1325. 50:37plus
  1326. 50:38plus 2 plus 1 and that is for all
  1327. 50:41permissions so this is
  1328. 50:43right
  1329. 50:44so again this is
  1330. 50:46sorry this is read write
  1331. 50:48and this is execute so 4 plus 2 plus 1
  1332. 50:50is going to be 7. if i only want read
  1333. 50:53permissions it's going to be four if i
  1334. 50:55only want
  1335. 50:57read and write permissions it's going to
  1336. 50:58be six again that would be uh seven six
  1337. 51:02six or if i only wanted um
  1338. 51:06read
  1339. 51:06uh and execute permissions that would be
  1340. 51:09uh so for example if we wanted for the
  1341. 51:11user or the owner read write and execute
  1342. 51:14permissions that would be seven and then
  1343. 51:16for the group and for all of the users
  1344. 51:18we only wanted read and execute
  1345. 51:20permissions that would be seven five
  1346. 51:21five all right so it's very easy to set
  1347. 51:24permissions this way and again you're
  1348. 51:26always setting explicitly for the user
  1349. 51:29uh for for the owner the the the user
  1350. 51:32the group and then all the other users
  1351. 51:34on the system so that's something you
  1352. 51:36need to take
  1353. 51:37into consideration all right so now
  1354. 51:39let's move on to actually uh changing
  1355. 51:42you know directory permissions all right
  1356. 51:44so if i list all the files here again
  1357. 51:46you can use the symbolic mode or the uh
  1358. 51:48the octal mode whatever is comfortable
  1359. 51:50with you we have the test directory that
  1360. 51:52we created so again if we wanted to
  1361. 51:54provide it with all permissions you can
  1362. 51:56see that it has read write permissions
  1363. 51:59for the current user and for the group
  1364. 52:02and the other users it only has read
  1365. 52:03permission so again we can say chmod
  1366. 52:06uh user we if we use the symbolic mode
  1367. 52:09we can say user
  1368. 52:11uh user group and other that's going to
  1369. 52:13be equal to read write and execute and
  1370. 52:16then we say test the name of the
  1371. 52:18directory and we hit enter and now if we
  1372. 52:20list all the files in here you can see
  1373. 52:22that the permissions have been set
  1374. 52:24uh and then again if we wanted to go
  1375. 52:26back i can say chmod
  1376. 52:29and let's say we only wanted the file to
  1377. 52:32be re we only wanted the user to be able
  1378. 52:35to read and
  1379. 52:37write to this particular directory then
  1380. 52:39we would say this is going to be equal
  1381. 52:41to 4 plus 2 is going to be 6
  1382. 52:444 4 and then we say test and we hit
  1383. 52:46enter we again we can just confirm the
  1384. 52:49permissions have been changed and there
  1385. 52:50you are so that's how to set uh
  1386. 52:52permissions on a directory however if
  1387. 52:55there are other directories and files
  1388. 52:57within this directory then we need to
  1389. 53:00set these permissions we can set them
  1390. 53:02recursively and to do this we can then
  1391. 53:05type in chmod
  1392. 53:07and if we use the r command the capital
  1393. 53:09r command that means recursive
  1394. 53:11permissions so again we can then say uh
  1395. 53:14before we do that let's actually move
  1396. 53:16this file the test file the test.sh file
  1397. 53:20into the test directory
  1398. 53:22and you can see it it tells us that we
  1399. 53:25do not have adequate permissions and
  1400. 53:27that's because again if we list all the
  1401. 53:30if we list all the permissions here for
  1402. 53:32the the directory
  1403. 53:35uh if we say for example uh for this
  1404. 53:37particular file
  1405. 53:39let's say we want to say chmod 755 test
  1406. 53:43dot sh and now we say move uh test dot
  1407. 53:46sh into the test directory and we hit
  1408. 53:49enter that is telling us that we cannot
  1409. 53:51move it nuts primarily because of the
  1410. 53:54the the permissions for the directory so
  1411. 53:56we can say chmod 755 a test and we hit
  1412. 53:59enter and then we can say move
  1413. 54:02we can then say test.sh into the test
  1414. 54:05folder here and we hit enter and now we
  1415. 54:07can move it all right so that proves
  1416. 54:09again that the importance of permissions
  1417. 54:12and understanding them so now if we
  1418. 54:14check the directory test uh the the
  1419. 54:17files within the directory test we have
  1420. 54:19the test.sh file so now if we wanted to
  1421. 54:22to actually provide this directory and
  1422. 54:25all the files within it files and
  1423. 54:27directories within it recursively with
  1424. 54:29all permissions i could say chmod
  1425. 54:33777 and that gives it read write and
  1426. 54:35executable permissions for the the owner
  1427. 54:38uh the group and all other users on the
  1428. 54:40system so again i would say chmod
  1429. 54:43recursively 777 and i'm using the octal
  1430. 54:46mode as you would have guessed and then
  1431. 54:48we specify the directory and hit enter
  1432. 54:50and now if we list all uh the directory
  1433. 54:52itself you can see it has all
  1434. 54:54permissions if we list uh all the files
  1435. 54:57uh within the the test directory if we
  1436. 55:00list the permissions here you can see
  1437. 55:02that the test.sh file now has all has
  1438. 55:04also uh those permissions and they have
  1439. 55:07been applied recursively so if i had any
  1440. 55:10other files or directories within this
  1441. 55:11directory uh they would have been
  1442. 55:13applied as well all right so now that we
  1443. 55:15have actually uh taken a look at file
  1444. 55:17ownership uh sorry file permissions
  1445. 55:20let's take a look at file ownership
  1446. 55:25in this video we're going to be talking
  1447. 55:27about file ownership which is a fairly
  1448. 55:29simple topic to understand and again in
  1449. 55:32the previous video we used the chmod
  1450. 55:35operator
  1451. 55:36or the chmod tool and in this video
  1452. 55:38we're going to be using the ch own tool
  1453. 55:41again which is quite self-explanatory it
  1454. 55:44allows us to change the ownership of
  1455. 55:46files and directories which is quite
  1456. 55:48important all right so as we did in the
  1457. 55:50previous video
  1458. 55:52you can see that we were able to
  1459. 55:54change the permissions for this for the
  1460. 55:57test directory and the test files within
  1461. 56:00it and i've just changed them back to
  1462. 56:02some pretty standard uh uh to some
  1463. 56:04pretty standard permissions here and
  1464. 56:06again uh we also had the
  1465. 56:10we also had the uh the test.sh file
  1466. 56:13within the test directory so
  1467. 56:15let's talk about ownership so as i
  1468. 56:17mentioned the current owner of this file
  1469. 56:20right over here is alexis and this is
  1470. 56:22the this is denoted uh right over here
  1471. 56:24so the ownership information and the
  1472. 56:26group ownership information if there is
  1473. 56:29any
  1474. 56:30now as i said uh we we haven't talked
  1475. 56:32about adding users and groups which is
  1476. 56:34fairly simple we haven't talked about
  1477. 56:36you know setting particular permissions
  1478. 56:37for users uh you know uh within the uh
  1479. 56:40the sudo as file but that's something
  1480. 56:42we'll get to later
  1481. 56:43so if we wanted to change the ownership
  1482. 56:45of this file
  1483. 56:47to
  1484. 56:48uh
  1485. 56:49to to let's say the root user i can do
  1486. 56:51that very very easily so again i can say
  1487. 56:54let me just go into the the root user
  1488. 56:56here and now i'm currently logged in as
  1489. 56:59the root user so if i wanted to change
  1490. 57:00the ownership and i'll go into the test
  1491. 57:03directory if i wanted to change the
  1492. 57:05ownership of the test.sh file
  1493. 57:08what i can do now is i can say ch own
  1494. 57:11and again you can use the what is tool
  1495. 57:13or the what is utility to actually give
  1496. 57:15you some more information about the the
  1497. 57:18ch own tool so again it tells you this
  1498. 57:20allows you to change your file owner and
  1499. 57:23group and of course change the ownership
  1500. 57:25of a file
  1501. 57:26all right so now if i wanted to change
  1502. 57:28the ownership of the test.sh file
  1503. 57:31from alexis to to the root user i can do
  1504. 57:34this very very easily so i can say
  1505. 57:37i can say ch own
  1506. 57:38and then i specify the the the user i
  1507. 57:41want to uh to actually change the
  1508. 57:44ownership to in this case to the root
  1509. 57:46user and then i'll specify the file name
  1510. 57:48which is going to be test.sh and i hit
  1511. 57:50enter and now if i list all the files
  1512. 57:53here you can see that the owner of the
  1513. 57:55file has been changed to root however
  1514. 57:57the group of this file is still alexis
  1515. 58:00all right so that's something that we
  1516. 58:01also have to change to change the group
  1517. 58:04or to change the group order here
  1518. 58:06it's very simple we use the change group
  1519. 58:08command which again is denoted by
  1520. 58:11uh it is denoted by change grp so chgrp
  1521. 58:15and again we can use the what is tool
  1522. 58:16change drp hit enter and this allows you
  1523. 58:19to change group ownership so let's say
  1524. 58:21we want to change the group ownership to
  1525. 58:23root as well or to the root group
  1526. 58:26if we type in groups and we say root
  1527. 58:29again that tells us what
  1528. 58:31what group the root user belongs to and
  1529. 58:34as you can see it belongs to the root uh
  1530. 58:36due to the root group uh and again we
  1531. 58:39can say groups alexis and uh you can see
  1532. 58:42these are the groups that the user lexis
  1533. 58:43belongs to it belongs to the to the
  1534. 58:46group alexis adm cd rom sudo etc etc
  1535. 58:50all right so let's say i wanted to
  1536. 58:52change the group of this file so change
  1537. 58:54group
  1538. 58:55um
  1539. 58:56and then i say change it to the group
  1540. 58:59root
  1541. 59:00and i want you to change the file
  1542. 59:01test.sh and now if we list the
  1543. 59:03permissions here or the ownership sorry
  1544. 59:05um
  1545. 59:07we can see now that the owner of the
  1546. 59:09file is the root user
  1547. 59:11and the the group ownership of this file
  1548. 59:13belongs to the to to to the group uh two
  1549. 59:16to the root group right over here all
  1550. 59:19right so that is how to use the ch own
  1551. 59:22and the ch
  1552. 59:23group or the change group command to
  1553. 59:25change the ownership of a file now again
  1554. 59:27we haven't experimented with users yet
  1555. 59:29and that's something we'll be touching
  1556. 59:30upon quite soon so we'll be explaining
  1557. 59:34this as we move along
  1558. 59:39in this video we're going to be talking
  1559. 59:40about how to use the grep tool in
  1560. 59:42regards to looking for data or
  1561. 59:44information in files all right so this
  1562. 59:46is one of the most important linux
  1563. 59:48utilities or tools that uh you can you
  1564. 59:51can learn how to use and it will really
  1565. 59:52improve your efficiency when dealing
  1566. 59:54with data and working in the terminal
  1567. 59:57okay so let's actually get started with
  1568. 59:59understanding what it is and what it
  1569. 1:00:01does all right so the first thing we can
  1570. 1:00:02do is we can just use the waters command
  1571. 1:00:04to give us a bit of a context or
  1572. 1:00:06information in in regards to what this
  1573. 1:00:07tool is and what it does so again it
  1574. 1:00:09tells you
  1575. 1:00:10this prints lines matching a particular
  1576. 1:00:12pattern and again if you're interested
  1577. 1:00:14in learning more about the tool you can
  1578. 1:00:15always use the manual pages or go
  1579. 1:00:17through the manual pages for the
  1580. 1:00:19particular tool so there you are it
  1581. 1:00:20gives you information or in regards to
  1582. 1:00:22how to use it the purpose of this video
  1583. 1:00:24is to show you how to use it in the most
  1584. 1:00:26efficient way or in a way to therefore
  1585. 1:00:28in increase your understanding on on how
  1586. 1:00:31to use the tool
  1587. 1:00:32and how to make you efficient with using
  1588. 1:00:34it
  1589. 1:00:34all right so uh before we we actually
  1590. 1:00:37take a look at a concrete example of how
  1591. 1:00:39to use grep
  1592. 1:00:40we must understand two things all right
  1593. 1:00:42the first thing you need to understand
  1594. 1:00:44is there are two ways of using grip the
  1595. 1:00:45first way is by using grip on its own
  1596. 1:00:47all right so again we can just type in
  1597. 1:00:50grep here
  1598. 1:00:51uh and the other way of using grip is by
  1599. 1:00:53actually piping the output of another
  1600. 1:00:55command into grep and then finding what
  1601. 1:00:57you're looking for all right so you
  1602. 1:00:59might be a little bit confused but let
  1603. 1:01:00me explain what it does in a very simple
  1604. 1:01:02way so grep is a tool that allows you to
  1605. 1:01:04find strings or patterns in files
  1606. 1:01:06alright so that means you can search or
  1607. 1:01:08specify for the data or the strings
  1608. 1:01:10you're looking for in a particular file
  1609. 1:01:12all right so let's take a look at a com
  1610. 1:01:14at a concrete example uh we're going to
  1611. 1:01:16be looking for a word within a the
  1612. 1:01:19proxychains.configuration file now if
  1613. 1:01:21you're not familiar with what
  1614. 1:01:22proxychains is uh you can check out my
  1615. 1:01:24proxy change video where i show how to
  1616. 1:01:26set it up uh and install it but again
  1617. 1:01:28it's it really doesn't matter because
  1618. 1:01:30you can follow up with any other files
  1619. 1:01:32you're working with all right so let's
  1620. 1:01:34say i
  1621. 1:01:35i wanted to find the word dynamic within
  1622. 1:01:37the file the cro the proxy chains
  1623. 1:01:39configuration file
  1624. 1:01:41let's let's take a look at how to use it
  1625. 1:01:43using the first method which is using
  1626. 1:01:44grep on its own without piping the
  1627. 1:01:46output of another command so we can say
  1628. 1:01:48grep and then the command we want to
  1629. 1:01:50specify after or the parameter
  1630. 1:01:52or the variable rather is the the data
  1631. 1:01:54we're looking for so again you want to
  1632. 1:01:56encapsulate this within double quotation
  1633. 1:01:58marks so again if it's a word we can
  1634. 1:01:59type in dynamic now the thing you you
  1635. 1:02:02must ensure is that this this search
  1636. 1:02:04will be case sensitive and i'll show you
  1637. 1:02:06how to omit at the case sensitive
  1638. 1:02:07searches so let's say we're looking for
  1639. 1:02:09the uh the the word dynamic and then we
  1640. 1:02:12specify the location of the file we want
  1641. 1:02:14to search
  1642. 1:02:15for this particular word in so again
  1643. 1:02:17proxychains.conf
  1644. 1:02:19and again we can use the double tab here
  1645. 1:02:21like so and we hit enter and again that
  1646. 1:02:23displays the word dynamic chain to us
  1647. 1:02:26again that's the the word that it was
  1648. 1:02:28able to find within the entire file
  1649. 1:02:31however as i said this say
  1650. 1:02:34this particular search is going to be
  1651. 1:02:35case sensitive now if we want to omit
  1652. 1:02:38the case sensitive search we can use the
  1653. 1:02:40i parameter or the i argument here
  1654. 1:02:43so once we hit i that means that it will
  1655. 1:02:46search for all files
  1656. 1:02:48or for all words within this particular
  1657. 1:02:50file uh
  1658. 1:02:52called a dynamic all right so once we
  1659. 1:02:54hit enter you can see now it gives us
  1660. 1:02:56two lines in the files uh they are both
  1661. 1:02:58different in the fact that the first one
  1662. 1:03:00is in case and the second one starts
  1663. 1:03:02with an uppercase d all right so again
  1664. 1:03:05it's a very simple tool to to use and
  1665. 1:03:07again you can now see how efficient and
  1666. 1:03:09how great it is at finding bits of
  1667. 1:03:11information within files so again we can
  1668. 1:03:14say let's say we want to look for
  1669. 1:03:16particular users within the password
  1670. 1:03:18file so i can say grep
  1671. 1:03:20and i can say let's say we're looking
  1672. 1:03:22for the user alexis in the password file
  1673. 1:03:24and then i say etsy
  1674. 1:03:26password and we hit enter and then it
  1675. 1:03:28displays the user account information
  1676. 1:03:30for the user lexis all right so that's
  1677. 1:03:32very simply how to use it now let's take
  1678. 1:03:34a look at the second method or way of
  1679. 1:03:37using grep and that's by piping the
  1680. 1:03:39output of one command
  1681. 1:03:41into crep and then of course finding the
  1682. 1:03:43data you're looking for that way and the
  1683. 1:03:45way to do this is by using the pipe the
  1684. 1:03:48pipe symbol or the pipe key on your
  1685. 1:03:50keyboard now you can find this key on
  1686. 1:03:52the extreme right of your keyboard just
  1687. 1:03:54before your numpad if you do have one
  1688. 1:03:57all right so the way we use it is let's
  1689. 1:03:59say we wanted to cut the contents of the
  1690. 1:04:01password file so let's say we wanted to
  1691. 1:04:03say cat etsy
  1692. 1:04:06password and we say we want to look for
  1693. 1:04:09a particular string within this file and
  1694. 1:04:12to do this with grep we now enter the
  1695. 1:04:15pipe symbol
  1696. 1:04:16which means we are redirecting the
  1697. 1:04:18output of this initial command
  1698. 1:04:20and we are now passing it on to grep so
  1699. 1:04:22now grep can do something with this
  1700. 1:04:24output so we say grep i want you to look
  1701. 1:04:26for the word dynamic all right
  1702. 1:04:29and we type we hit enter and we and
  1703. 1:04:31there you are so again it does not give
  1704. 1:04:33us any options here um and that's
  1705. 1:04:36because i did not specify user here so
  1706. 1:04:38again say alexis and again that gives us
  1707. 1:04:40the using the user account information
  1708. 1:04:43for the user lexus and again we can just
  1709. 1:04:45change it to the
  1710. 1:04:46proxychains.configuration file here
  1711. 1:04:48and we hit enter and we change this to
  1712. 1:04:50dynamic sorry um like so and it gives us
  1713. 1:04:53the data now a lot of people have been
  1714. 1:04:55asking me since uh since i covered
  1715. 1:04:58redirecting output uh as i mentioned
  1716. 1:05:00there are two ways of redirecting output
  1717. 1:05:02the pipe
  1718. 1:05:03key or the pipe command is used to
  1719. 1:05:05redirect output and you know further
  1720. 1:05:07process the data that you're outputting
  1721. 1:05:09the difference between the pipe uh the
  1722. 1:05:11pipe uh command or redirecting output
  1723. 1:05:14with pipe and the greater than symbol is
  1724. 1:05:15the greater than symbol will not display
  1725. 1:05:18the information on to your terminal it
  1726. 1:05:20will actually just output everything or
  1727. 1:05:23redirect all the output of the command
  1728. 1:05:25that you have
  1729. 1:05:26that you've used into a file or even
  1730. 1:05:28another command so again if i say cat
  1731. 1:05:31fc password and i use this i wanted to
  1732. 1:05:33redirect the output into it uh into a
  1733. 1:05:35txt file i can say desktop
  1734. 1:05:38and say test.txt and i hit enter and now
  1735. 1:05:41if i actually get uh the the the file on
  1736. 1:05:44my desktop sorry i believe i'm in my
  1737. 1:05:46home directory here and i say test.txt
  1738. 1:05:48hit enter it it actually has the content
  1739. 1:05:50of the file so again that's the
  1740. 1:05:51difference when uh when i'm actually
  1741. 1:05:53talking about uh redirecting output with
  1742. 1:05:56both the pipe and the greater than sign
  1743. 1:05:58uh which is very different so
  1744. 1:06:00again the pipe symbol is the preferred
  1745. 1:06:02way of using or actually passing the
  1746. 1:06:04output of one command and processing it
  1747. 1:06:06with another command
  1748. 1:06:08like
  1749. 1:06:08leg grip and you can use it with other
  1750. 1:06:10utilities that will actually show you
  1751. 1:06:11how to use uh for the further further
  1752. 1:06:14along the series here
  1753. 1:06:16so
  1754. 1:06:17you can use this with any other command
  1755. 1:06:18that displays output onto the screen so
  1756. 1:06:20i'm just going to use one more command
  1757. 1:06:22just to show you how efficient this is
  1758. 1:06:23so let's say i typed in ifconfig and i
  1759. 1:06:26just want my inet information i can pipe
  1760. 1:06:28the output of the ifconfig command and i
  1761. 1:06:30can say i net
  1762. 1:06:32uh and i can just say grab i net here
  1763. 1:06:34and i hit enter and it gives a it gives
  1764. 1:06:36me my inet information whether that be
  1765. 1:06:38ipv4 or ipv6 all right so you can now
  1766. 1:06:41see how useful this is and i want you
  1767. 1:06:44guys to experiment with this let me know
  1768. 1:06:46what you think
  1769. 1:06:47where you're not understanding how to
  1770. 1:06:48use it and i'll be sure to make up for
  1771. 1:06:51full follow-up videos if you guys are
  1772. 1:06:52interested in it
  1773. 1:06:56in this video i'm going to be showing
  1774. 1:06:58you how to use the locate utility to
  1775. 1:06:59find files and i'll be also making an
  1776. 1:07:02another video after this to show you how
  1777. 1:07:03to use the find tool to actually find
  1778. 1:07:06files as well so they're two utilities
  1779. 1:07:07that you can use in this video we're
  1780. 1:07:09going to be taking a look at how to use
  1781. 1:07:10the locate tool it's a tool that goes
  1782. 1:07:12ignored by many beginners or newcomers
  1783. 1:07:14mostly because of its relative
  1784. 1:07:15simplicity but it's a very efficient
  1785. 1:07:17tool and does what it's supposed to do
  1786. 1:07:19so again
  1787. 1:07:20we can use the what is uh utility here
  1788. 1:07:22to tell us more about what this tool is
  1789. 1:07:24so again we can just say what is locate
  1790. 1:07:26and as you can see it tells us it finds
  1791. 1:07:28files by the name which is very simple
  1792. 1:07:30and again you can use the manual page
  1793. 1:07:33you can use the manual for this
  1794. 1:07:34particular tool to learn how to use it
  1795. 1:07:36so i'm just going to be covering just
  1796. 1:07:38enough to make you efficient with the
  1797. 1:07:39tool and make you understand how it
  1798. 1:07:41works and how you can use it in
  1799. 1:07:42conjunction with grip
  1800. 1:07:44all right so
  1801. 1:07:46uh let's actually get started with a
  1802. 1:07:48very simple example right so let's say i
  1803. 1:07:50wanted to locate a file on the system
  1804. 1:07:52right and
  1805. 1:07:53i wanted to locate a the password file
  1806. 1:07:56so i can say locate
  1807. 1:07:57password and hit enter and you can see
  1808. 1:08:00it's given me a lot of a lot of
  1809. 1:08:02information here a lot of files called
  1810. 1:08:04password on my system
  1811. 1:08:05right now this is really not efficient
  1812. 1:08:08because um again i'm looking for a
  1813. 1:08:11particular file that i'm looking for
  1814. 1:08:13which is bill which actually exists in
  1815. 1:08:14the etsy file and we can see the result
  1816. 1:08:17well that's not actually the result here
  1817. 1:08:19with this is the result right at the top
  1818. 1:08:20here all right however this really is
  1819. 1:08:23not efficient or an efficient way of
  1820. 1:08:24going about it right so uh this is where
  1821. 1:08:27we can now specify the options that we
  1822. 1:08:29can use
  1823. 1:08:30uh that we can use with uh with a tool
  1824. 1:08:33like locate so let's say we wanted to
  1825. 1:08:36get only the files that match this
  1826. 1:08:38particular pattern or these particular
  1827. 1:08:40uh strings here so the password string
  1828. 1:08:43so to do this we type a or we use the uh
  1829. 1:08:45we can use the all parameter or option
  1830. 1:08:48here and once we hit enter again that
  1831. 1:08:50gives us the same information so what
  1832. 1:08:51does that means is it's actually
  1833. 1:08:53displaying all the files on the system
  1834. 1:08:56uh that actually match the patterns of
  1835. 1:08:58password here
  1836. 1:09:00and because this file really doesn't
  1837. 1:09:01have any extension we now have to deal
  1838. 1:09:03with the actual path or the path that we
  1839. 1:09:06we might want to be uh finding this file
  1840. 1:09:09in now of course that is counter
  1841. 1:09:11intuitive given that um
  1842. 1:09:13i can say that this belongs in the etsy
  1843. 1:09:15in the etsy directory and again that now
  1844. 1:09:18it now actually narrows down uh the
  1845. 1:09:20files into what they may be so again
  1846. 1:09:22that's the the actual file where we were
  1847. 1:09:24looking for but you can see how tedious
  1848. 1:09:26this is so we can actually shorten this
  1849. 1:09:29now by actually using the grep tool
  1850. 1:09:31which actually showed you how to use and
  1851. 1:09:33it's very very simple so again we're
  1852. 1:09:35simply going to use grip to look for
  1853. 1:09:37particular information related to the uh
  1854. 1:09:40to the information that is is given to
  1855. 1:09:42us by locate so we can now say locate
  1856. 1:09:45and then we say we're looking for
  1857. 1:09:47password and
  1858. 1:09:49we close that and now we say we pipe the
  1859. 1:09:51output and we say grip let's look for
  1860. 1:09:54password uh within etsy within the etsy
  1861. 1:09:58directory so again
  1862. 1:09:59we can now say etsy here sorry fc and
  1863. 1:10:05we say password or we can just say the
  1864. 1:10:07etsy directory here and then we can hit
  1865. 1:10:09close and you can see it gives us the
  1866. 1:10:11results we're looking for it highlights
  1867. 1:10:13them in red or depending on the color
  1868. 1:10:15scheme you're using in your terminal so
  1869. 1:10:16again we can improve the efficiency of
  1870. 1:10:18this by typing in
  1871. 1:10:20etsy password and we hit enter so this
  1872. 1:10:23is a file without a particular extension
  1873. 1:10:25which makes it relatively difficult to
  1874. 1:10:27actually find but you can find it
  1875. 1:10:29relatively easily if you use grep here
  1876. 1:10:31um so so let's actually talk about um
  1877. 1:10:34about another file that has an extension
  1878. 1:10:35that we can use to explain this here
  1879. 1:10:38all right so
  1880. 1:10:40um let's say we're working with the
  1881. 1:10:43the the resolve file or the resolve
  1882. 1:10:46configuration file which is used for to
  1883. 1:10:48modify your name servers which is
  1884. 1:10:50available on our linux systems what we
  1885. 1:10:52can say is we can say locate
  1886. 1:10:56resolve and uh sorry resolve and we hit
  1887. 1:10:58enter and again tons of files but now we
  1888. 1:11:01know that this file has an extension so
  1889. 1:11:03we can say uh locate it's uh we can say
  1890. 1:11:05locate resolve uh dot conf and read
  1891. 1:11:08enter and again it still gives us a lot
  1892. 1:11:09of files but we're looking for the one
  1893. 1:11:11that belongs in the that exists in the
  1894. 1:11:13etsy folder again so what we can do now
  1895. 1:11:16is we can say locate and we want to
  1896. 1:11:18actually
  1897. 1:11:20we're looking for we can use the all uh
  1898. 1:11:22the old parameter here
  1899. 1:11:23and then we say we're looking for
  1900. 1:11:26uh all files with an extension or we're
  1901. 1:11:29looking for a file with the with an
  1902. 1:11:30extension of uh conf or config here so
  1903. 1:11:34we'll use the wildcard option to mean
  1904. 1:11:36that this we're looking for for all
  1905. 1:11:38files with this particular extension so
  1906. 1:11:39we say
  1907. 1:11:40um all and then we say conf and we close
  1908. 1:11:44those um these quotation marks and now
  1909. 1:11:46we pipe the output into grep here and
  1910. 1:11:48now with grep we can then say we are
  1911. 1:11:51looking for resolve here and we sorry
  1912. 1:11:53that is we're looking for resolve when
  1913. 1:11:55we enter and now it gives us the
  1914. 1:11:57information we're looking for
  1915. 1:11:59and the first option here so again
  1916. 1:12:01that's with the
  1917. 1:12:02the actual extension of confirm so again
  1918. 1:12:04we're limiting the results to
  1919. 1:12:07only the files that have an extension of
  1920. 1:12:08config or configuration and then we can
  1921. 1:12:10use grep to find the particular string
  1922. 1:12:13that is most important to us so let me
  1923. 1:12:15give you another example because this
  1924. 1:12:16seems very simple
  1925. 1:12:18so let's say
  1926. 1:12:20we're looking for the proxy chains right
  1927. 1:12:23uh so we can say proxy change and hit
  1928. 1:12:25enter and there you are you can see
  1929. 1:12:27immediately now because that is a unique
  1930. 1:12:29string it gives us the results
  1931. 1:12:31immediately with the uh we with the uh
  1932. 1:12:33the extension here and that's because we
  1933. 1:12:35specified it so again we can just say
  1934. 1:12:37locate you know proxy chains
  1935. 1:12:40and hit enter and there's a ton of files
  1936. 1:12:42now another thing you might find useful
  1937. 1:12:44is actually
  1938. 1:12:46displaying how many results are matching
  1939. 1:12:49the particular pattern you have
  1940. 1:12:50specified exist so let's say i want to
  1941. 1:12:52say locate i can say all that means all
  1942. 1:12:55the the the matching uh the matching
  1943. 1:12:58patterns here so we say all and then we
  1944. 1:13:00can use the c uh the c argument here
  1945. 1:13:03which specifies or prints the number of
  1946. 1:13:05matching results and then we say we
  1947. 1:13:08specify the string we're looking for or
  1948. 1:13:10we can just say we're looking for proxy
  1949. 1:13:12chains and we enter and it tells us here
  1950. 1:13:14that we have 25 uh files
  1951. 1:13:17uh or results that actually have the
  1952. 1:13:19matching patterns here now if we limit
  1953. 1:13:21it to
  1954. 1:13:22conf and we hit enter now you can see we
  1955. 1:13:24only have two so that's essentially how
  1956. 1:13:26to use this tool uh in regards to you
  1957. 1:13:28know displaying the amount of matching
  1958. 1:13:30uh patterns you have and if you wanted
  1959. 1:13:32to locate so if we get rid of this here
  1960. 1:13:36and let's hit enter you can now see the
  1961. 1:13:37results that it tells us here so we have
  1962. 1:13:39the one in the etsy folder and one in
  1963. 1:13:42the the debian package management uh
  1964. 1:13:45the debian package management folder uh
  1965. 1:13:47in regards to its actual configuration
  1966. 1:13:50there so
  1967. 1:13:51that's how to use the locate tool now
  1968. 1:13:52again let me just cover one more
  1969. 1:13:54additional parameter you can use and
  1970. 1:13:56that is the the eye parameter which
  1971. 1:13:58again is very important and that means
  1972. 1:14:00that you want to ignore case uh that's
  1973. 1:14:02something i should have mentioned
  1974. 1:14:03earlier all searches with locate are
  1975. 1:14:05typically going to be case sensitive so
  1976. 1:14:08again i can say proxy chains
  1977. 1:14:10and i hit enter and we have no results
  1978. 1:14:12right so if i wanted to ignore the case
  1979. 1:14:14sensitivity of what i've just hit uh of
  1980. 1:14:16the the pattern i've just entered i can
  1981. 1:14:18just hit i and i'd enter and again we
  1982. 1:14:20get the same results and i can now limit
  1983. 1:14:22this to proxychains.conf and there you
  1984. 1:14:24are and again i can i can partner these
  1985. 1:14:26or i can actually combine these commands
  1986. 1:14:28with each other to give us the
  1987. 1:14:30information we're looking for so again a
  1988. 1:14:32very very simple tool to use but again
  1989. 1:14:34it gives you very consistent results
  1990. 1:14:40in this video we're going to be taking a
  1991. 1:14:41look at how to enumerate uh system
  1992. 1:14:43information on linux now you might be
  1993. 1:14:45wondering what exactly do you mean here
  1994. 1:14:47well i'm simply referring to uh
  1995. 1:14:49important information about your system
  1996. 1:14:51and the user currently logged in as just
  1997. 1:14:54information that you might need when
  1998. 1:14:56you're currently logged onto a system
  1999. 1:14:57and you might want to know more about
  2000. 1:14:59what you're dealing with all right so
  2001. 1:15:00let's get started now the first
  2002. 1:15:03uh the the first thing we need to do is
  2003. 1:15:05we need to find out what user we're
  2004. 1:15:07currently logged in as and the host name
  2005. 1:15:09and the use id etc etc all right so
  2006. 1:15:13let's get started with that
  2007. 1:15:15so the first thing i want to know when
  2008. 1:15:17i'm logged in is who am i exactly and
  2009. 1:15:20that tells me the current user that i'm
  2010. 1:15:21logged in as and then if i type in host
  2011. 1:15:23name
  2012. 1:15:24uh that again gives me the current
  2013. 1:15:26hostname of this workstation or of this
  2014. 1:15:28computer in my case it tells me i'm
  2015. 1:15:30running uh the hostname is alexis
  2016. 1:15:32workstation now if you do want to change
  2017. 1:15:34your uh your hostname you can you can do
  2018. 1:15:38so by by modifying the host name file i
  2019. 1:15:41believe that's what it's called the yeah
  2020. 1:15:44there we are and you can see that mine
  2021. 1:15:46is set to alexis workstation or ws which
  2022. 1:15:49is an abbreviation of workstation so you
  2023. 1:15:51can change this and in my case i don't
  2024. 1:15:53want to do this so i'm just going to
  2025. 1:15:54exit out of here
  2026. 1:15:56so that is how to find out the current
  2027. 1:15:58user logged in as and the host name
  2028. 1:16:01now if you want to find the user id that
  2029. 1:16:03you're currently logged in as you can
  2030. 1:16:04simply type in id
  2031. 1:16:06that gives you the current use id
  2032. 1:16:09and again of course the user you then
  2033. 1:16:10have the group id which is quite
  2034. 1:16:12important and the other groups that this
  2035. 1:16:13user is currently a part of
  2036. 1:16:15now um
  2037. 1:16:17in regards to groups and the groups that
  2038. 1:16:20a particular user may be part of the way
  2039. 1:16:23to enumerate this information is by
  2040. 1:16:25typing in groups and then the name of
  2041. 1:16:27the user so we can type in groups alexis
  2042. 1:16:30and once we hit enter again it tells us
  2043. 1:16:33the user lexis is a part of these groups
  2044. 1:16:35so it's a part of the group alexis sudo
  2045. 1:16:38among the other ones here that are
  2046. 1:16:40essentially system uh system accounts
  2047. 1:16:42here that you or system groups that uh
  2048. 1:16:45really have to do with just permissions
  2049. 1:16:47to a particular service
  2050. 1:16:49um so that is basic user enumeration now
  2051. 1:16:51let's talk about a little bit about the
  2052. 1:16:53system and enumerating information like
  2053. 1:16:56um
  2054. 1:16:57like your uh
  2055. 1:16:59like your linux distribution the version
  2056. 1:17:01stuff like that so uh i'm currently
  2057. 1:17:03using a debian system or i'm using
  2058. 1:17:06ubuntu so again it's based on debian so
  2059. 1:17:08the the practices are all the the
  2060. 1:17:10techniques and the commands are quite
  2061. 1:17:12similar on both ends now when dealing
  2062. 1:17:14with uh you know systemd based
  2063. 1:17:16distributions
  2064. 1:17:17uh and all of course red hat based
  2065. 1:17:18distributions the process is going to be
  2066. 1:17:20slightly different and i'll explain why
  2067. 1:17:22and how
  2068. 1:17:23um so on linux if you on sorry on
  2069. 1:17:27on on tpn or on ubuntu if you want to
  2070. 1:17:29enumerate your linux uh if you want to
  2071. 1:17:32enumerate your linux distribution
  2072. 1:17:34version and the name you simply type in
  2073. 1:17:37lsb release a and of course
  2074. 1:17:40lsb is a utility and you may not have it
  2075. 1:17:43installed but again it comes with um
  2076. 1:17:46with db and ubuntu by default so again
  2077. 1:17:49that tells us the distributor the
  2078. 1:17:50distributor id the description again
  2079. 1:17:53ubuntu 18.04
  2080. 1:17:550.3 lts
  2081. 1:17:57the release name
  2082. 1:17:58sorry the release version and the code
  2083. 1:18:00name here which in this case is bionic
  2084. 1:18:02beaver
  2085. 1:18:03so again you can also use the check the
  2086. 1:18:05contents of the issue file
  2087. 1:18:08so if we type in cat etsy issue you can
  2088. 1:18:10see it tells us the same thing here
  2089. 1:18:12um
  2090. 1:18:14so that is for debian based
  2091. 1:18:16distributions now um
  2092. 1:18:18when dealing with system d distributions
  2093. 1:18:21like um
  2094. 1:18:23centos arch
  2095. 1:18:25red hat
  2096. 1:18:27also debian to to some extent you can
  2097. 1:18:29also use the you can also take a look at
  2098. 1:18:32the content within the os release
  2099. 1:18:34file which will also enumerate on debian
  2100. 1:18:36as well but i just wanted to explain
  2101. 1:18:38that so you guys don't get confused all
  2102. 1:18:40right so what you can do is just simply
  2103. 1:18:42type in cat let's see
  2104. 1:18:44os
  2105. 1:18:46os release and again that gives us the
  2106. 1:18:47information that we were looking for now
  2107. 1:18:50on um on ubuntu and on db and if i hit
  2108. 1:18:53enter it tells us nothing there if i
  2109. 1:18:56then use the star or the wildcard we hit
  2110. 1:18:58enter that gives us the linux
  2111. 1:19:00distribution information
  2112. 1:19:02and a bit more information regarding the
  2113. 1:19:04privacy policy
  2114. 1:19:06uh support url stuff like that
  2115. 1:19:09and um now that's uh now that we've also
  2116. 1:19:12covered the system the uh base
  2117. 1:19:14distributions let's talk about uh
  2118. 1:19:16dealing with red hat now on red hat um
  2119. 1:19:18if you want to take a look at the
  2120. 1:19:20uh the red hat release version uh you
  2121. 1:19:23can i believe you can find it if i type
  2122. 1:19:24in cat hc and then you type in red hat
  2123. 1:19:28release now i'm currently not using a
  2124. 1:19:30red hat based distribution so that would
  2125. 1:19:32pretty much give you the red release
  2126. 1:19:34version um so that's basically
  2127. 1:19:36enumerating your distribution name uh
  2128. 1:19:40your distribution version and name um if
  2129. 1:19:42you are using you know some of these uh
  2130. 1:19:45distributions based on debian or the
  2131. 1:19:47systemd based distributions like arch
  2132. 1:19:50centos or red at enterprise linux
  2133. 1:19:53so again let's talk about you know
  2134. 1:19:56enumerating information about your
  2135. 1:19:57processor or your cpu
  2136. 1:19:59so you can easily do this by typing your
  2137. 1:20:01ls cpu and we can hit enter and again
  2138. 1:20:03that enumerates information about your
  2139. 1:20:05cpu so it gives you information like
  2140. 1:20:07your architecture and the instruction
  2141. 1:20:09set
  2142. 1:20:10um the amount of uh the amount of cores
  2143. 1:20:14the threads per core the cost per socket
  2144. 1:20:17sockets
  2145. 1:20:18vend id
  2146. 1:20:19cpu family the model model name in this
  2147. 1:20:22case it's an i5 8400
  2148. 1:20:25uh the stepping the
  2149. 1:20:27the
  2150. 1:20:28frequency here in megahertz so max and
  2151. 1:20:31minimum as well so 4 gig by 4 gigahertz
  2152. 1:20:34and the minimum of 800 megahertz
  2153. 1:20:36uh
  2154. 1:20:38virtualization and then the l1 l2 and l3
  2155. 1:20:41cache and so information about your cpu
  2156. 1:20:44all right so now that we've taken a look
  2157. 1:20:47at enumerating cpu information let's
  2158. 1:20:48take a look at enumerating kernel uh
  2159. 1:20:50information which is done using the you
  2160. 1:20:52name
  2161. 1:20:53uh
  2162. 1:20:54using the unnamed command or utility
  2163. 1:20:55which essentially stands for unix name
  2164. 1:20:59so again if we just type in what is your
  2165. 1:21:01name here and you can see it says prints
  2166. 1:21:03system information and guess the name
  2167. 1:21:05and information about the current uh
  2168. 1:21:07kernel so using it is very very simple
  2169. 1:21:09so if you type in your name a that
  2170. 1:21:11displays all the information so again it
  2171. 1:21:13gives you information about like your uh
  2172. 1:21:15your host name the current linux kernel
  2173. 1:21:17that's that's installed and currently
  2174. 1:21:19running
  2175. 1:21:20and then you have the uh you then have
  2176. 1:21:23the instruction set here i'm going over
  2177. 1:21:24the the important information so again
  2178. 1:21:27we can uh we can actually take a look at
  2179. 1:21:29the various options that are available
  2180. 1:21:31here so again we can say
  2181. 1:21:33if we want the kernel uh we if we want
  2182. 1:21:36the kernel version here we can type in
  2183. 1:21:38uh we can say you name
  2184. 1:21:41s and that tells us the kernel that
  2185. 1:21:43we're currently running which is the
  2186. 1:21:44linux kernel the version here can be
  2187. 1:21:47printed out by typing you name
  2188. 1:21:49uh i believe it's your name r that's the
  2189. 1:21:51current release so in our case it's
  2190. 1:21:53version 4.15 which i believe is stable
  2191. 1:21:57not too sure
  2192. 1:21:58um and then if you want again if you
  2193. 1:22:00want the
  2194. 1:22:03the information about the the
  2195. 1:22:04instruction set for your processor you
  2196. 1:22:06can type in your name
  2197. 1:22:08you name p
  2198. 1:22:09again that gives you the instruction set
  2199. 1:22:10in our case x 86 64.
  2200. 1:22:14uh and then if we want the hardware
  2201. 1:22:16platform we can type in you name i
  2202. 1:22:19so we can say you name i
  2203. 1:22:21the hardware platform again that's the
  2204. 1:22:23that's uh the information in regards to
  2205. 1:22:25the architecture and then the operating
  2206. 1:22:28system
  2207. 1:22:29uh we can say you name
  2208. 1:22:31o and it enter gnu linux so again just
  2209. 1:22:33basic information regarding your system
  2210. 1:22:36but uh the key bits of the important
  2211. 1:22:39pieces of information here are your
  2212. 1:22:40kernel and the instruction set of course
  2213. 1:22:43so that's essentially all the
  2214. 1:22:45information uh that you might want to
  2215. 1:22:48enumerate regarding your system or you
  2216. 1:22:50might be interested in now dealing with
  2217. 1:22:53um with disk usage and um disk uh and
  2218. 1:22:57disk usage disk space i'll be making a
  2219. 1:22:59separate video on that so uh you guys
  2220. 1:23:01can stay tuned for that but in regards
  2221. 1:23:03to your system this these all the
  2222. 1:23:05commands that you can use to find
  2223. 1:23:06information about your the current user
  2224. 1:23:08that's logged in
  2225. 1:23:10uh so again if i type in who again that
  2226. 1:23:12tells me the current users that are
  2227. 1:23:14logged in in my case it's uh the only
  2228. 1:23:17user is alexis so that's just an
  2229. 1:23:19additional tidbit so again we've covered
  2230. 1:23:22you know the user id the group id and
  2231. 1:23:26we've also covered enumerating
  2232. 1:23:27distribution information and the kernel
  2233. 1:23:29information so
  2234. 1:23:34in this video we're going to be covering
  2235. 1:23:35how to use the find tool and we'll also
  2236. 1:23:37be taking a look at some challenges on
  2237. 1:23:39of the wire bandit uh more related to
  2238. 1:23:41what we're taking a look at in this
  2239. 1:23:42video which is how to correctly utilize
  2240. 1:23:45the find command to look for files or
  2241. 1:23:46directories within your system so an
  2242. 1:23:48extremely uh you know very useful tool
  2243. 1:23:51that will really help you save time when
  2244. 1:23:53looking for particular files and i'll be
  2245. 1:23:55showing you how to use it right now most
  2246. 1:23:56efficiently so again we can use the what
  2247. 1:23:58is utility to find out more information
  2248. 1:24:00about the tool so again it tells you at
  2249. 1:24:02this this tool allows you to search for
  2250. 1:24:04files and in a directory hierarchy you
  2251. 1:24:07can also check out the man pages for
  2252. 1:24:08this particular tool
  2253. 1:24:10and again you can go through all of this
  2254. 1:24:12if you want to i'm going to be covering
  2255. 1:24:14all uh the the information that is
  2256. 1:24:16necessary or that will make you the most
  2257. 1:24:18efficient with this tool
  2258. 1:24:20all right so let's get started let's
  2259. 1:24:21stop wasting time so using the tool is
  2260. 1:24:23very simple we say find and then after
  2261. 1:24:25sayings find we need to specify uh the
  2262. 1:24:28directory we want to we want to search
  2263. 1:24:30in so again we can specify the current
  2264. 1:24:32directory that we are currently in uh by
  2265. 1:24:34you know using the full stop or the dot
  2266. 1:24:37uh or we can specify the entire linux
  2267. 1:24:39file system directory which is done by
  2268. 1:24:41using a forward slash like so as you
  2269. 1:24:43would when navigating directories
  2270. 1:24:45or i can specify an individual directory
  2271. 1:24:47that i want to uh that i want to search
  2272. 1:24:49in so i can say home
  2273. 1:24:51alexis which is pretty much the
  2274. 1:24:52directory we're working in so what i'm
  2275. 1:24:54going to do is i'm just going to search
  2276. 1:24:55the entire linux file system directory
  2277. 1:24:57which if you're going to do you do
  2278. 1:24:58require root or pseudo privileges
  2279. 1:25:00otherwise you'll not be able to access
  2280. 1:25:02files and directories that you know you
  2281. 1:25:04do not have adequate permissions to
  2282. 1:25:05access
  2283. 1:25:06so i will also add the pseudo command
  2284. 1:25:09here
  2285. 1:25:10so again we're going to find files
  2286. 1:25:11within the linux file system directory
  2287. 1:25:13we then specify the other bit of
  2288. 1:25:15information that uh will help us
  2289. 1:25:16fine-tune our results which is of course
  2290. 1:25:18going to be the type that we're dealing
  2291. 1:25:20with so the type in regards to the find
  2292. 1:25:22command is very simple it simply refers
  2293. 1:25:24to what you're dealing with so are you
  2294. 1:25:26looking for a file or a directory and
  2295. 1:25:28that can be denoted by either using f
  2296. 1:25:31for file or d for directory in our case
  2297. 1:25:33we're looking for a file so we're just
  2298. 1:25:35going to hit file all right so very
  2299. 1:25:37simple next we specify the other
  2300. 1:25:39variable that again will help us
  2301. 1:25:40fine-tune our search results and is very
  2302. 1:25:43important which is the name so what is
  2303. 1:25:45the name of the file you're looking for
  2304. 1:25:46so i can say proxy chains
  2305. 1:25:49and i know i'm using the same example
  2306. 1:25:51but again i'll show you how robust this
  2307. 1:25:53is in a second so i can say
  2308. 1:25:54proxychains.conf
  2309. 1:25:56and after this i can pretty much hit
  2310. 1:25:58enter now the important thing to note
  2311. 1:26:00here
  2312. 1:26:01is that i can use uh the grep command in
  2313. 1:26:03conjunction with find to you know pipe
  2314. 1:26:05output and specify configuration files
  2315. 1:26:07by themselves similar to what we looked
  2316. 1:26:09at when we're taking a look at the
  2317. 1:26:10locate tool uh so i can just hit enter
  2318. 1:26:13and you can see we found the
  2319. 1:26:14configuration file and we didn't have
  2320. 1:26:17adequate permission for some files which
  2321. 1:26:19is perfectly fine
  2322. 1:26:20um so that's how to use the find tool
  2323. 1:26:22and i've shown you the various
  2324. 1:26:23parameters you can use so you can
  2325. 1:26:24specify the type uh the name uh which
  2326. 1:26:27i'll show you how to how robust it can
  2327. 1:26:28be in a second so let's take a look at
  2328. 1:26:30the same example so i'm just going to
  2329. 1:26:32say find um and you know we can just say
  2330. 1:26:35sudo sudo find
  2331. 1:26:37and we say the type is going to be
  2332. 1:26:40a file which you can also change to
  2333. 1:26:42directory if you are looking for a
  2334. 1:26:43directory so for example i can say
  2335. 1:26:46directory and then i can say name
  2336. 1:26:48and their name is going to be alexis
  2337. 1:26:50look for the directory lexis and hit
  2338. 1:26:52enter and their ui tells us oh we have
  2339. 1:26:54various uh directories here so we can
  2340. 1:26:56see we have um
  2341. 1:26:58we have the home directory here and a
  2342. 1:27:00few other files here that uh i've
  2343. 1:27:02actually popped up from my external hard
  2344. 1:27:04drive which i don't think are that
  2345. 1:27:05important
  2346. 1:27:07but there you go that just shows you how
  2347. 1:27:09robust this tool is in regards to you
  2348. 1:27:11know looking for particular files so you
  2349. 1:27:13can change that up so so let's go back
  2350. 1:27:14to our previous example so i'm just
  2351. 1:27:15going to say the name is going to be
  2352. 1:27:17proxy chains now i mentioned in the
  2353. 1:27:19previous video the the case sensitivity
  2354. 1:27:21which is quite important so if you are
  2355. 1:27:24performing a search
  2356. 1:27:26uh in which you do not want any case
  2357. 1:27:28sensitivity you use the i name command
  2358. 1:27:30instead of the name command and then
  2359. 1:27:32after this you can say i can say alexis
  2360. 1:27:34for example and of course it will ignore
  2361. 1:27:36all the cases here so i can you know i
  2362. 1:27:39can combine it with whatever uppercase
  2363. 1:27:41up and lowercase uh characters i want
  2364. 1:27:43and i'll still get i'll still get the
  2365. 1:27:45same results
  2366. 1:27:46uh and i can just hit enter
  2367. 1:27:49and uh this time again it gave us uh the
  2368. 1:27:52same results but uh it gave us different
  2369. 1:27:54results because we are looking for a
  2370. 1:27:56file so if we change this into a
  2371. 1:27:57directory here you can see that it's
  2372. 1:27:59going to give us the same results that
  2373. 1:28:00we had in the in the initial run when
  2374. 1:28:02we're looking for uh you know
  2375. 1:28:04directories uh called alexis so that's
  2376. 1:28:06how robust this tool is so i talked
  2377. 1:28:08about using um using extensions which is
  2378. 1:28:11again very very simple so let's say
  2379. 1:28:13we're looking for extensions and we're
  2380. 1:28:15looking for all uh conf files which
  2381. 1:28:17belong in the etsy directory so i'm just
  2382. 1:28:19going to say etsy and we've now written
  2383. 1:28:21it down we can say name is going to be
  2384. 1:28:24i can say um
  2385. 1:28:27uh we can just say conf and we'll use
  2386. 1:28:28the wildcard uh so i say conf we'll just
  2387. 1:28:31use the same configuration file
  2388. 1:28:32extension
  2389. 1:28:33uh and then i can say grep and then i
  2390. 1:28:35specify the name of the file right so uh
  2391. 1:28:38you know i can hit enter and this is
  2392. 1:28:40going to display all the configuration
  2393. 1:28:42files within the etsy directory but
  2394. 1:28:44again i have to specify the
  2395. 1:28:46uh the file specification here and i'm
  2396. 1:28:48going to enter
  2397. 1:28:49and there you are so it gives you all
  2398. 1:28:50the configuration files so very simple
  2399. 1:28:53tool to use now let's talk about the
  2400. 1:28:54other variables that you can use to
  2401. 1:28:56specify
  2402. 1:28:57that will help you fine-tune your your
  2403. 1:28:59search results and that is by specifying
  2404. 1:29:01the size of the file
  2405. 1:29:03and the permissions all right so again
  2406. 1:29:05we can just use a simple example i'm
  2407. 1:29:07just going to say find and i'm going to
  2408. 1:29:09say we'll say type and that's going to
  2409. 1:29:11be you don't really need to specify the
  2410. 1:29:13type if you don't want to it's just
  2411. 1:29:14there to help you fine tune your results
  2412. 1:29:16so i can perfectly ignore it if i know
  2413. 1:29:18what i'm looking for
  2414. 1:29:19precisely i can then say you know name
  2415. 1:29:22and the name is going to be proxy chains
  2416. 1:29:25i can say epoxychains.conf you know i
  2417. 1:29:26have the whole name
  2418. 1:29:28and then i can say size i'm looking for
  2419. 1:29:30a file with a particular size so i can
  2420. 1:29:32then use the various options i have so i
  2421. 1:29:34can say it's going to be plus one
  2422. 1:29:36megabyte which can be done like so uh or
  2423. 1:29:39i can you know i can save plus a hundred
  2424. 1:29:41megabytes whatever i want to say so in
  2425. 1:29:43this case let me just say plus one
  2426. 1:29:44megabytes and hit enter
  2427. 1:29:46and uh well we're getting uh various
  2428. 1:29:48permission errors here and that's
  2429. 1:29:50because we'll just say etsy
  2430. 1:29:52hit enter
  2431. 1:29:54and i will say sudo and
  2432. 1:29:57there we are and we got no results at
  2433. 1:29:59all i just wanted to to actually provide
  2434. 1:30:01it with the adequate the adequate
  2435. 1:30:02permissions so that i can show you that
  2436. 1:30:05if we use uh you know
  2437. 1:30:07if we use parameters like these size and
  2438. 1:30:10we specify it down to due to the actual
  2439. 1:30:13size of the file we can sort of uh
  2440. 1:30:14fine-tune our results very very uh to a
  2441. 1:30:16very deep granular level
  2442. 1:30:18so if i just um
  2443. 1:30:21let's say um etsy and i can then grab
  2444. 1:30:26proxy chains
  2445. 1:30:28conf and
  2446. 1:30:29i hit enter here you can take a look at
  2447. 1:30:32let me just change this to a human
  2448. 1:30:34readable format so you can say it's
  2449. 1:30:36about uh four kilobytes here and uh we
  2450. 1:30:39can then you know you can specify the
  2451. 1:30:41size depending on on how you want it and
  2452. 1:30:43i'll get back to this uh when we'll be
  2453. 1:30:45taking a look at the uh the over the
  2454. 1:30:46wire banded challenges because that's
  2455. 1:30:48where i really want to showcase the
  2456. 1:30:49power of the fine tool
  2457. 1:30:51let's talk about permissions before we
  2458. 1:30:53actually get started with at the over
  2459. 1:30:54the wire bandit challenges and the
  2460. 1:30:56permissions are very simple to to
  2461. 1:30:58actually specify here i'm going to be
  2462. 1:31:00covering you know users and groups and
  2463. 1:31:01we'll be taking a look at that example
  2464. 1:31:03but let's talk about uh permissions
  2465. 1:31:05first so permissions allow you to find
  2466. 1:31:07again files that have particular
  2467. 1:31:09permissions very very straightforward
  2468. 1:31:11here so you know i can say um
  2469. 1:31:14let's say i create a file go to my
  2470. 1:31:16desktop here and i'll say touch
  2471. 1:31:18alexis dot sh you know just a simple
  2472. 1:31:21shell script or a bash script here hit
  2473. 1:31:23enter and i say chmod
  2474. 1:31:25400 alexis dot sh and hit enter and they
  2475. 1:31:29say find within
  2476. 1:31:30the home directory i can then say
  2477. 1:31:34let's say we're looking for a file
  2478. 1:31:36type is going to be a file we don't have
  2479. 1:31:38a name but we have permissions so i can
  2480. 1:31:40say firm
  2481. 1:31:41let's look for
  2482. 1:31:43let's look for files with the permission
  2483. 1:31:44of 400 which means
  2484. 1:31:47um
  2485. 1:31:48which means that the the the owner or
  2486. 1:31:50the user can read the file um but the
  2487. 1:31:53other group and all other users on the
  2488. 1:31:55system are not able to access it so
  2489. 1:31:58again uh that should give us a few
  2490. 1:32:00results but we don't have adequate
  2491. 1:32:01permissions for the other files so you
  2492. 1:32:03can see we get the result right over
  2493. 1:32:05here so you can use permissions to help
  2494. 1:32:07fine-tune your search results and get
  2495. 1:32:09the exact results you're looking for
  2496. 1:32:11you know we can also specify 744 we hit
  2497. 1:32:14enter and uh
  2498. 1:32:16it looks like we had a few files with
  2499. 1:32:18those particular permissions but
  2500. 1:32:20nothing no no important files that we
  2501. 1:32:23that don't have the correct permission
  2502. 1:32:25so you can see that this can help you
  2503. 1:32:26find a files on your system that have
  2504. 1:32:28incorrect permissions and then you can
  2505. 1:32:30rectify them uh you know like so instead
  2506. 1:32:32of going manually and checking for their
  2507. 1:32:34permission so very useful tool now that
  2508. 1:32:36we've taken a look at how to use the
  2509. 1:32:38tool let's take a look at how to
  2510. 1:32:40implement it in some challenges and
  2511. 1:32:42that's what we're going to do in the
  2512. 1:32:43next step which is the over the wire
  2513. 1:32:45challenges so you can follow along if
  2514. 1:32:46you want to and i'll see you there
  2515. 1:32:48all right so we are back on over the
  2516. 1:32:50wire and i'm currently on the bandit uh
  2517. 1:32:53on the bandit web page here and uh you
  2518. 1:32:56you can get access to this challenge by
  2519. 1:32:58following the instructions on level zero
  2520. 1:32:59uh the levels we're interested in are
  2521. 1:33:01going to be levels four five
  2522. 1:33:03uh level fours uh to level four to level
  2523. 1:33:06six so again we'll just go to level four
  2524. 1:33:08here and i currently have access and
  2525. 1:33:09i've solved the challenges uh all
  2526. 1:33:12all up till level four so we can get
  2527. 1:33:14started
  2528. 1:33:15all right so
  2529. 1:33:16uh you can see that uh level four
  2530. 1:33:18pertains uh
  2531. 1:33:20actually finding a file so you can see
  2532. 1:33:22the password for the next file or for
  2533. 1:33:24the next level is stored in the in the
  2534. 1:33:26only human readable file
  2535. 1:33:28in the in here directory uh tip if your
  2536. 1:33:31terminal is messed up you can try the
  2537. 1:33:33reset command and again it gives you the
  2538. 1:33:35various commands that you can use to
  2539. 1:33:36solve this level so again let's go back
  2540. 1:33:38into our terminal as you can see i'm
  2541. 1:33:40currently on bandit 4 and we can list
  2542. 1:33:42the files within this home directory and
  2543. 1:33:44you can see we have an in here directory
  2544. 1:33:46so let's uh let's go in here let's see
  2545. 1:33:48what's going on
  2546. 1:33:50so if you list the files here you can
  2547. 1:33:52see we have various files and if i if i
  2548. 1:33:54try cutting one of these uh one of these
  2549. 1:33:56files you can see that um
  2550. 1:33:59sorry let's specify that hyphen there
  2551. 1:34:02let's say file zero zero we can hit
  2552. 1:34:04enter and you can see it has a various
  2553. 1:34:06uh
  2554. 1:34:07it has various pieces of data and of
  2555. 1:34:09course our job is to look for files
  2556. 1:34:11within this in here directory that have
  2557. 1:34:14uh human readable data so again what we
  2558. 1:34:16can do is we can use the find command
  2559. 1:34:18here uh to actually find uh you know the
  2560. 1:34:21various files that have human readable
  2561. 1:34:23data so i can say uh in this current
  2562. 1:34:25directory and we are looking for um
  2563. 1:34:28[Music]
  2564. 1:34:29we can actually just say find and then
  2565. 1:34:31in this directory uh we're looking for
  2566. 1:34:34the type
  2567. 1:34:35it's going to be a type of file here and
  2568. 1:34:37then we can grip the output or we can
  2569. 1:34:39pipe the output sorry and within we can
  2570. 1:34:41use the x args command here to look for
  2571. 1:34:45um i believe it's uh if we just expand
  2572. 1:34:48this uh let's take a look at how to use
  2573. 1:34:50x cogs one more time
  2574. 1:34:51uh we wanted to display uh the file read
  2575. 1:34:54items from a file uh instead of standard
  2576. 1:34:57uh standard input
  2577. 1:35:00uh
  2578. 1:35:00and yeah this if we type in file that
  2579. 1:35:03should tell us the files that we're
  2580. 1:35:04dealing with all right and this will
  2581. 1:35:06help us shorten the process so let's go
  2582. 1:35:08back in here as we say file in it enter
  2583. 1:35:11and as you can see it tells us that in
  2584. 1:35:13file 0 7 we have some ascii text however
  2585. 1:35:17in all the other files we have data so
  2586. 1:35:18again we can access this file now we can
  2587. 1:35:20just cap the contents of this file and
  2588. 1:35:22we should get the password next level
  2589. 1:35:24all right excellent so we can copy this
  2590. 1:35:26let me exit and we'll go to bandit level
  2591. 1:35:29five here i'm going to enter we'll just
  2592. 1:35:32paste in the password
  2593. 1:35:34and we can get started now all right so
  2594. 1:35:36let's take a look at what a challenge or
  2595. 1:35:38level five uh pertains
  2596. 1:35:40so again it says the password for the
  2597. 1:35:42next level is stored in a file somewhere
  2598. 1:35:44under the in here directory and has all
  2599. 1:35:47of the following properties it's human
  2600. 1:35:49readable um okay all right it's going to
  2601. 1:35:52be a human readable file um 1033 bytes
  2602. 1:35:56in size
  2603. 1:35:57and it's not executable all right so
  2604. 1:35:59that's uh an option these are all the
  2605. 1:36:01these are all parameters that we'll have
  2606. 1:36:03to specify to some extent
  2607. 1:36:05so let's actually get started so
  2608. 1:36:07uh these are going to be in the in here
  2609. 1:36:10directory so i'll just go into the in
  2610. 1:36:11here directory and you can see we have
  2611. 1:36:13uh other directories within this so
  2612. 1:36:15we're going to just say find
  2613. 1:36:17uh and we're going to say type is going
  2614. 1:36:19to be a file uh we were told that we
  2615. 1:36:22have it's going to be human readable so
  2616. 1:36:24you can use x args there
  2617. 1:36:27uh
  2618. 1:36:27size i showed you how to specify size
  2619. 1:36:29now the the thing about specifying size
  2620. 1:36:32in bytes is if we just take a look at um
  2621. 1:36:37we take a look at the at the find tool
  2622. 1:36:38and we just
  2623. 1:36:40grip for some for size you can see that
  2624. 1:36:43it tells us the size does not count
  2625. 1:36:45indirect blocks uh
  2626. 1:36:47etc so size one megabyte is not
  2627. 1:36:49equivalent is not equivalent to size so
  2628. 1:36:51if you're specifying it in bytes you
  2629. 1:36:53need to specify uh the actual number and
  2630. 1:36:55then the c here all right so that's what
  2631. 1:36:58we have to do so um we just go back in
  2632. 1:37:01here and we go to type a file and then
  2633. 1:37:03we say size
  2634. 1:37:04is going to be 10 33 c and then after
  2635. 1:37:07this um
  2636. 1:37:09we're supposed to us
  2637. 1:37:11the file is not
  2638. 1:37:12is not executable so we can then use the
  2639. 1:37:15logic um operators here so we're going
  2640. 1:37:18to say
  2641. 1:37:19not executable and executable is another
  2642. 1:37:22parameter you can specify and then we
  2643. 1:37:24can use xrx here
  2644. 1:37:26and we're going to say file and hit
  2645. 1:37:28enter
  2646. 1:37:29and you can see it tells us
  2647. 1:37:31that maybe here07 and file2 has some
  2648. 1:37:34ascii text with very long lines all
  2649. 1:37:37right so let's cut the content off this
  2650. 1:37:39file
  2651. 1:37:40and just get it we're just going to
  2652. 1:37:42enter here and we have the password so
  2653. 1:37:44let's exit and go on to the final level
  2654. 1:37:46in this particular video so i'm gonna
  2655. 1:37:48go into level six hit enter
  2656. 1:37:51and i'm gonna paste the password in here
  2657. 1:37:53and we can now take a look at what level
  2658. 1:37:56six pertains
  2659. 1:37:58uh so level six the password for the
  2660. 1:38:00next level is stored somewhere on the
  2661. 1:38:02server and has all of the following
  2662. 1:38:04properties so yeah this is now where we
  2663. 1:38:06have the user and group specifications
  2664. 1:38:09which is really simple so again we're
  2665. 1:38:11told to look for a file
  2666. 1:38:13on the entire server
  2667. 1:38:15owned or the the entire linux file
  2668. 1:38:17system that is owned by the user bandit
  2669. 1:38:19seven
  2670. 1:38:20and is owned by the group bandit six and
  2671. 1:38:23in 33 bytes in size all right so we can
  2672. 1:38:27then say um
  2673. 1:38:28it's on the entire server we have any
  2674. 1:38:30files here no we don't so we can say
  2675. 1:38:32find and we're looking for a user which
  2676. 1:38:36is going to be bandit seven and a group
  2677. 1:38:39which is again very easy to specify
  2678. 1:38:41group is going to be bandit 6
  2679. 1:38:46the particular file we're looking for is
  2680. 1:38:48going to be
  2681. 1:38:5033 bytes so 33c
  2682. 1:38:54[Music]
  2683. 1:38:55i think that's pretty much it in regards
  2684. 1:38:57to the options or the parameters that we
  2685. 1:38:59were given so let's actually see if we
  2686. 1:39:01can find this file when it enter
  2687. 1:39:05and
  2688. 1:39:05we get various
  2689. 1:39:07you know permission denied errors here
  2690. 1:39:10and it looks like we get a password file
  2691. 1:39:13here so that's under the var folder or
  2692. 1:39:15the var directory and it's a bandit 7
  2693. 1:39:18password so let's copy the directory do
  2694. 1:39:19that the actual file path the relative
  2695. 1:39:22file path and cat the contents of that
  2696. 1:39:24and we get the password to the next
  2697. 1:39:26level and i'm just going to hit exit and
  2698. 1:39:29we can move on to bandit level 7 which
  2699. 1:39:32is now
  2700. 1:39:32is is going to pertain to another
  2701. 1:39:34challenge which is out of the scope of
  2702. 1:39:36this video so
  2703. 1:39:40in this video i'm going to be talking
  2704. 1:39:41about shells now this might be a little
  2705. 1:39:43bit confusing for you if you're a
  2706. 1:39:45beginner to linux but um
  2707. 1:39:47you the only thing you need to
  2708. 1:39:49understand is that your the various
  2709. 1:39:51types of shields you can use on linux
  2710. 1:39:53now if you're using ubuntu or debian the
  2711. 1:39:56default shell that you'll be you'll be
  2712. 1:39:58given is going to be called the bash
  2713. 1:40:00shell all right and again i can confirm
  2714. 1:40:03this by echoing my variable my shell
  2715. 1:40:05variable here so i can say echo shell
  2716. 1:40:07and again it tells you the the current
  2717. 1:40:09shell that i'm using which is bash now
  2718. 1:40:11bash is an acronym for the born again
  2719. 1:40:14shell
  2720. 1:40:15uh so that means that there was a born
  2721. 1:40:17shell and you're familiar with it and
  2722. 1:40:19that is the sh or the sh shell so uh
  2723. 1:40:23all of these shells can be used to to
  2724. 1:40:26actually work with the linux system
  2725. 1:40:28that's that's entirely up to you my
  2726. 1:40:30objective in this video is to explain
  2727. 1:40:33how to change your default shell and not
  2728. 1:40:35work with the bash shell
  2729. 1:40:37all right now
  2730. 1:40:38on linux if you want to actually display
  2731. 1:40:40all the shelves that you currently have
  2732. 1:40:42that can be used uh you can essentially
  2733. 1:40:45just read the contents
  2734. 1:40:47of the shells file in the etsy directory
  2735. 1:40:49and i can hit enter and you can see it's
  2736. 1:40:52going to tell me it's going to tell you
  2737. 1:40:53the valid login shells you have
  2738. 1:40:55so we have the born shell which is the
  2739. 1:40:58sh we have the born again shell which is
  2740. 1:41:00bash which is the preferred
  2741. 1:41:02shell to use you then have our bash and
  2742. 1:41:04dash which is pretty good and then you
  2743. 1:41:06have fish now i just installed fish and
  2744. 1:41:09again many of you have been asking me to
  2745. 1:41:11cover this i'll explain it after i've
  2746. 1:41:13after actually explained passion how to
  2747. 1:41:15use it how to customize it and stuff
  2748. 1:41:17like that so for the purpose of this
  2749. 1:41:19video i'm going to be using i'm going to
  2750. 1:41:21be using bash and i'll later on cover
  2751. 1:41:23the other the other shelves that you can
  2752. 1:41:24use and you know using fish
  2753. 1:41:27so the first thing is how to switch from
  2754. 1:41:30shell to shell within a given terminal
  2755. 1:41:32instance
  2756. 1:41:33so i'm currently using the bash shell if
  2757. 1:41:36i wanted to switch into the bond shell i
  2758. 1:41:38can just hit sh and hit enter and you
  2759. 1:41:41can see i'm now in the bond shell and
  2760. 1:41:42again all the linux commands work
  2761. 1:41:44perfectly fine i can hit all the various
  2762. 1:41:46linux commands that i could run so i can
  2763. 1:41:49list all the files in here etc etc you
  2764. 1:41:51get the idea right so i can then say cat
  2765. 1:41:54etsy shelves and again we can take a
  2766. 1:41:57look at the shelves we have i can now go
  2767. 1:41:59back into bash
  2768. 1:42:00i can go into dash if i want to and
  2769. 1:42:02again that takes me to in into into dash
  2770. 1:42:05you can say echo and we can again
  2771. 1:42:08confirm this and hit enter and it tells
  2772. 1:42:10us we're still in pin bash that is
  2773. 1:42:12because we're currently within this
  2774. 1:42:14instance but if i changed it as my
  2775. 1:42:16default login shell which i'll show you
  2776. 1:42:18in a second how to do so let me just go
  2777. 1:42:20back into bash
  2778. 1:42:21and we will actually let me just clear
  2779. 1:42:24this out so there we all right so
  2780. 1:42:26you can see how easy it is to switch
  2781. 1:42:28between shells in a particular terminal
  2782. 1:42:30instance now
  2783. 1:42:32by default as a user account on a linux
  2784. 1:42:34system
  2785. 1:42:35uh a
  2786. 1:42:36you will be specified a particular shell
  2787. 1:42:39to use and that can be found in the
  2788. 1:42:40password file so if i hit enter so let
  2789. 1:42:42me just grab it and display my account
  2790. 1:42:45you can see that the shell is specified
  2791. 1:42:47here and i'll explain this when talking
  2792. 1:42:48about users and groups you can see that
  2793. 1:42:50uh the default login shell that i have
  2794. 1:42:53been specified to use is the bash shell
  2795. 1:42:57which is perfectly fine now the great
  2796. 1:42:58thing about linux is when creating the
  2797. 1:43:00user you can specify the shell that
  2798. 1:43:02they're going to use however you can
  2799. 1:43:04also change the shell of the user or the
  2800. 1:43:06user can change the shell that they want
  2801. 1:43:08to use when they log in or every time
  2802. 1:43:10they log in and the way we do that is by
  2803. 1:43:12using the change shell command or the
  2804. 1:43:15change shell utility which is defined by
  2805. 1:43:18chsh or that's an actual abbreviation of
  2806. 1:43:21the command so i can type in what is
  2807. 1:43:23chsh
  2808. 1:43:24and i'm going to enter you can see it
  2809. 1:43:26tells you this allows you to change the
  2810. 1:43:28login shell
  2811. 1:43:29all right so if i want to change uh the
  2812. 1:43:32default login shell all i need to do is
  2813. 1:43:34let me first display the shells that i
  2814. 1:43:36have here one more time all i need to
  2815. 1:43:38specify is their relative path all right
  2816. 1:43:40so if i say chs8 it's going to ask me
  2817. 1:43:42for the password of my user here when it
  2818. 1:43:45enter and it's going to say changing the
  2819. 1:43:46login shell for the user lexis enter new
  2820. 1:43:49value or press enter for the default the
  2821. 1:43:51default login shell for me is bash so if
  2822. 1:43:54i wanted to change it to
  2823. 1:43:56to fish for example i would say
  2824. 1:43:58user
  2825. 1:44:00sorry that is user
  2826. 1:44:02bin and i say fish i'm going to enter
  2827. 1:44:04and that changes it for me all right so
  2828. 1:44:07what this means in essence if i type in
  2829. 1:44:09cat hc password here
  2830. 1:44:12what this means
  2831. 1:44:13let me just display the results here you
  2832. 1:44:15can see that it changes uh the default
  2833. 1:44:17login shell so this means that uh when i
  2834. 1:44:20log out and i log back in
  2835. 1:44:22uh what's gonna happen is that i'm gonna
  2836. 1:44:24be given the fish shell as my default
  2837. 1:44:26shell instead of bash so if you're
  2838. 1:44:28wondering what the fish shell is uh you
  2839. 1:44:30can install it very easily by typing
  2840. 1:44:32sudo apt install or apt-get install
  2841. 1:44:35whatever you find is useful for you
  2842. 1:44:38just hit enter and i already have it
  2843. 1:44:40installed so that's how to install it so
  2844. 1:44:42what is fish fish is a friendly as a
  2845. 1:44:45friendly interactive show it's a great
  2846. 1:44:47show for beginners extremely
  2847. 1:44:48customizable and you can see once i
  2848. 1:44:50typed in fish it allowed me to log in
  2849. 1:44:52the great thing about fish is it allows
  2850. 1:44:54allows me to actually it actually gives
  2851. 1:44:57me predictions in regards to the
  2852. 1:44:59commands that i might be interested in
  2853. 1:45:00running we'll get to this in a second
  2854. 1:45:01let me go into bash
  2855. 1:45:03all right so that is how to change your
  2856. 1:45:05default login shell
  2857. 1:45:07all right so again i'm right now i'm
  2858. 1:45:09currently set to use fish as the default
  2859. 1:45:12shell when i log in every time
  2860. 1:45:14but let's talk about bash because that's
  2861. 1:45:16uh that that's the primary goal of this
  2862. 1:45:18video because it's the most used shell
  2863. 1:45:20and the one you'll be coming across
  2864. 1:45:22mostly so in my current home directory
  2865. 1:45:24so in the user lexis directory here i
  2866. 1:45:27have various bash files bash
  2867. 1:45:29configuration files uh within this
  2868. 1:45:32directory so i'm just gonna grab them
  2869. 1:45:34and i'll say bash and of course they're
  2870. 1:45:36gonna be hidden
  2871. 1:45:37so i'm just gonna hit enter and as you
  2872. 1:45:38can see i have a bash aliases file which
  2873. 1:45:41you're not going to have by default i
  2874. 1:45:42created this and i created it to to
  2875. 1:45:45prove a point and to actually
  2876. 1:45:46demonstrate an example here we then have
  2877. 1:45:48the bash history uh file which has uh
  2878. 1:45:51all your history of all your commands
  2879. 1:45:53and this is very different to your
  2880. 1:45:55actual
  2881. 1:45:56gnu history uh utility
  2882. 1:45:59um
  2883. 1:46:00you have bash log out and bash rc bash
  2884. 1:46:02rc is your bash configuration file i'm
  2885. 1:46:04not gonna cover how to configure it it's
  2886. 1:46:06extremely straightforward and you can
  2887. 1:46:08pretty much configure it directly uh by
  2888. 1:46:10using the preferences tab right over
  2889. 1:46:12here
  2890. 1:46:13but we can take a look at it i just want
  2891. 1:46:15to show you how it is so and if we take
  2892. 1:46:17a look at it here through vim you can
  2893. 1:46:20see that
  2894. 1:46:21it essentially allows you to to
  2895. 1:46:23configure set
  2896. 1:46:25variables i change the color change the
  2897. 1:46:27the size of the history of the history
  2898. 1:46:29file um
  2899. 1:46:31let's see what else you can actually do
  2900. 1:46:34here so there you can you can change the
  2901. 1:46:36color
  2902. 1:46:38this is all to do with color and you can
  2903. 1:46:40you can do a lot of other stuff with uh
  2904. 1:46:42in regards to customizing how it appears
  2905. 1:46:44and and how it works so for example if i
  2906. 1:46:47wanted um if i wanted bash to actually
  2907. 1:46:51run the fish shell instead of the bash
  2908. 1:46:54shell every time i started up
  2909. 1:46:56i started bash up i would type in fish
  2910. 1:46:58right just at the bottom here and let me
  2911. 1:47:01save this file now and if i open up a
  2912. 1:47:03new terminal you can see immediately it
  2913. 1:47:05opens up the fish shell
  2914. 1:47:07so that's pretty cool but this isn't the
  2915. 1:47:09correct way of doing it or the preferred
  2916. 1:47:11way of doing it so i'll just get rid of
  2917. 1:47:13this fish command here
  2918. 1:47:15and i'll save the changes here all right
  2919. 1:47:16so now that we've talked about um
  2920. 1:47:20now that we've talked about the bash rc
  2921. 1:47:22file let's talk about the bash history
  2922. 1:47:25file which is very important all right
  2923. 1:47:26so
  2924. 1:47:27by default in linux you have the history
  2925. 1:47:30command um which again let me just type
  2926. 1:47:32it in the history command is essentially
  2927. 1:47:35the new history library now the the
  2928. 1:47:36history uh
  2929. 1:47:38this essentially allows you to to
  2930. 1:47:40actually check uh a lot it stores a
  2931. 1:47:42history of all the commands you've run
  2932. 1:47:45and uh you know you can clear your
  2933. 1:47:46history very easily by typing in history
  2934. 1:47:49c right and it's as simple as that but
  2935. 1:47:52it's not to be mistaken or confused with
  2936. 1:47:55bash history which is again uh
  2937. 1:47:57is specific to the bash shell or the
  2938. 1:48:00bone again shell
  2939. 1:48:01so again this file will contain a list
  2940. 1:48:04of all the commands that i've run and
  2941. 1:48:06and i'll show you how to clear it so if
  2942. 1:48:08i get the contents of the file
  2943. 1:48:10uh you can see that it it has all of
  2944. 1:48:13these commands that i've been running so
  2945. 1:48:15far you know perfectly fine
  2946. 1:48:17and if i wanted to clear it it's very
  2947. 1:48:20easy i can just redirect the the
  2948. 1:48:22contents of the so i can say dev
  2949. 1:48:25null and then
  2950. 1:48:27[Music]
  2951. 1:48:28i can redirect the output into the
  2952. 1:48:30actual bash history file they bash
  2953. 1:48:33history here hit enter clear this out
  2954. 1:48:36if i now try and catch the contents of
  2955. 1:48:39the bash history file
  2956. 1:48:41you can see it has nothing so i've been
  2957. 1:48:43able to clear my bash history i think
  2958. 1:48:44i've covered this in my one of the
  2959. 1:48:46videos where i spoke about uh actually
  2960. 1:48:49clearing your tracks on linux so this is
  2961. 1:48:51a great way of doing that and of course
  2962. 1:48:53you can then use the history command if
  2963. 1:48:55you want to do that so that's to do with
  2964. 1:48:57actually using the um
  2965. 1:49:00with actually working with the actual
  2966. 1:49:02bash history here now let me talk about
  2967. 1:49:04the bash aliases file all right so the
  2968. 1:49:06aliases file is very simple it allows
  2969. 1:49:08you to specify aliases or command
  2970. 1:49:10aliases that you'd like to use now you
  2971. 1:49:12can just create a file within your home
  2972. 1:49:14directory and just name it bash aliases
  2973. 1:49:16so what i'll do is i'll actually just
  2974. 1:49:18show you the contents of the file
  2975. 1:49:21so i can just show it show it to you
  2976. 1:49:22right over here so bash aliases hit
  2977. 1:49:24enter and you can see i have two aliases
  2978. 1:49:27i have alias update which runs the
  2979. 1:49:29command sudo apt-get update and then i
  2980. 1:49:31have upgrade which runs the command sudo
  2981. 1:49:34apt-get upgrade so it's fairly simple to
  2982. 1:49:36understand what happens so i can just
  2983. 1:49:38type in update and that will update my
  2984. 1:49:40packages and then i can type in upgrade
  2985. 1:49:43and that will upgrade my packages
  2986. 1:49:44instead of typing the commands over and
  2987. 1:49:46over again so that is what
  2988. 1:49:48you know the command aliases are and how
  2989. 1:49:50to specify them so again it's very
  2990. 1:49:52simple in regards to configuring it
  2991. 1:49:57in this video i'm going to be showing
  2992. 1:49:59you uh how to enumerate intermission in
  2993. 1:50:01regards to your current disk usage and
  2994. 1:50:03in information you know in regards to
  2995. 1:50:05how much storage your system is
  2996. 1:50:06consuming how much you have left the
  2997. 1:50:08various disks attached to your system
  2998. 1:50:10etc stuff like that
  2999. 1:50:12all right so as i said in the previous
  3000. 1:50:13videos in regards to enumerating you
  3001. 1:50:15know information about your system it's
  3002. 1:50:17very important to know uh the state of
  3003. 1:50:20view system and that you know could
  3004. 1:50:21include the current ram usage uh what
  3005. 1:50:24you the temperature of your processes
  3006. 1:50:26are you know so again it's very
  3007. 1:50:27important to know as a system
  3008. 1:50:28administrator or someone who is going to
  3009. 1:50:30be you know using linux uh you know more
  3010. 1:50:34and more every day uh how to enumerate
  3011. 1:50:37information and useful information like
  3012. 1:50:39your current disk usage
  3013. 1:50:41and the various drives that you have
  3014. 1:50:43installed on your system so let's talk
  3015. 1:50:45about disk usage first which is quite
  3016. 1:50:47important right because when working
  3017. 1:50:49with the terminal you have no gui you
  3018. 1:50:51know programs
  3019. 1:50:53that can actually you know visualize
  3020. 1:50:54this for you so it's very important that
  3021. 1:50:56you understand how to do this extremely
  3022. 1:50:58important so the tool we're going to be
  3023. 1:51:00using is a tool called du right and
  3024. 1:51:02again it's fairly straightforward what
  3025. 1:51:04that means that means disk usage so i
  3026. 1:51:07can just say what is what is du and i
  3027. 1:51:09can hit enter and as you can see it
  3028. 1:51:10tells you this allows you to estimate
  3029. 1:51:12file space usage right
  3030. 1:51:15now du is a very simple tool to use and
  3031. 1:51:18you can take a look at the man pages or
  3032. 1:51:19in regards to how how to use it
  3033. 1:51:22um so let's actually just run a simple
  3034. 1:51:25command within this current directory
  3035. 1:51:26and i'll show you what i mean so if i if
  3036. 1:51:28i hit du
  3037. 1:51:30uh you can see that
  3038. 1:51:32this is um there's something weird
  3039. 1:51:34happening here right so it's displaying
  3040. 1:51:37a lot of files and uh when i say that it
  3041. 1:51:40really is displaying it's displaying all
  3042. 1:51:43the sizes of all the files within this
  3043. 1:51:45directory recursively all right now you
  3044. 1:51:48might be saying well what does that mean
  3045. 1:51:50exactly
  3046. 1:51:51well it means that it's actually showing
  3047. 1:51:53you the size of all the files within a
  3048. 1:51:56current working directory all right
  3049. 1:51:58that's essentially what it means now
  3050. 1:51:59what current directory am i working in
  3051. 1:52:01i'm working in my home directory so we
  3052. 1:52:03need to make this a little bit more
  3053. 1:52:05human readable and the way we do this is
  3054. 1:52:07by typing du and then we specify some
  3055. 1:52:10arguments the first thing we want to do
  3056. 1:52:12is we want to summarize
  3057. 1:52:14all of these results into a uh into a
  3058. 1:52:16format that we can understand right so
  3059. 1:52:19instead of displaying recursively all
  3060. 1:52:21the files here show us the top level
  3061. 1:52:23directories and the total sizes of those
  3062. 1:52:26directories and then we can go
  3063. 1:52:27recursively within those particular
  3064. 1:52:29directories if we wanted to all right so
  3065. 1:52:32the s command is going to summarize
  3066. 1:52:34everything up and then we want to use
  3067. 1:52:35the h command the human readable format
  3068. 1:52:38within this current working directory
  3069. 1:52:40and i'm going to hit enter
  3070. 1:52:42and as you can see right over here tells
  3071. 1:52:45you it gives you a beautiful list of all
  3072. 1:52:47the directories you have in this
  3073. 1:52:49particular directory and on the left
  3074. 1:52:51hand side you have their sizes in human
  3075. 1:52:53readable format which means they have uh
  3076. 1:52:56they have that they have size uh they
  3077. 1:52:59have uni their various units in
  3078. 1:53:00megabytes and in gigabytes
  3079. 1:53:02and you know so far the the only file
  3080. 1:53:05that's crossed at the threshold of one
  3081. 1:53:07gigabyte is my virtualbox folder so
  3082. 1:53:09again you can use a tool like trep to if
  3083. 1:53:12you're going through tons of files on a
  3084. 1:53:14system i'm just using simple examples
  3085. 1:53:16here so you know i can say grep and you
  3086. 1:53:18know i can say one uh one gig and we can
  3087. 1:53:21hit enter and again that can be used to
  3088. 1:53:23enumerate all of these all of this type
  3089. 1:53:25of information or i can just say g
  3090. 1:53:28g would be much better and there you are
  3091. 1:53:30so again that's how to use grep in
  3092. 1:53:32conjunction with all of these commands
  3093. 1:53:34so that's how to use the disk usage tool
  3094. 1:53:36now again i can go on to my um let me
  3095. 1:53:40just go uh
  3096. 1:53:41actually let's let's just go into the
  3097. 1:53:43linux file system itself and say sudo uh
  3098. 1:53:46eush and we'll run the same command and
  3099. 1:53:48again we can hit enter and again that
  3100. 1:53:50starts to enumerate the sizes of all of
  3101. 1:53:52these directories now mind you it has to
  3102. 1:53:54go through all of these directories and
  3103. 1:53:56the subdirectories uh directories
  3104. 1:53:58recursively to get this size so again
  3105. 1:54:01for some particular files
  3106. 1:54:02you will not have the adequate
  3107. 1:54:04permissions to actually access so again
  3108. 1:54:06there you are it gives you uh all the
  3109. 1:54:08information you're looking for here and
  3110. 1:54:09we can you know we can grab it to we're
  3111. 1:54:12looking for the the big g for a gigabyte
  3112. 1:54:15so the home directory has quite a
  3113. 1:54:17few files the media directory uh the
  3114. 1:54:20snap swap file user var etc etc
  3115. 1:54:24um so let's take a look at one command
  3116. 1:54:26i'll just go back into my home directory
  3117. 1:54:27and i'll say man eu and we'll hit enter
  3118. 1:54:33let's look for one
  3119. 1:54:35one more command that yes the c command
  3120. 1:54:38which will produce a grand total which i
  3121. 1:54:40wanted to explain so i can say to you
  3122. 1:54:42shc and hit enter and again that gives
  3123. 1:54:45you a total of um
  3124. 1:54:48it gives you a total of all of these
  3125. 1:54:49files
  3126. 1:54:50uh it gives you a total of all of the
  3127. 1:54:52files and directories in this current
  3128. 1:54:54working directory all right so that's
  3129. 1:54:55pretty much how to use the disk usage
  3130. 1:54:57tool
  3131. 1:54:58uh to analyze the current disk usage
  3132. 1:55:00within a particular directory now let's
  3133. 1:55:02talk about the df tool so i can type in
  3134. 1:55:04what is the fn8 enter and this is going
  3135. 1:55:07to report file system disk space usage
  3136. 1:55:10so we were talking about disk usage in a
  3137. 1:55:12particular directory right but now we
  3138. 1:55:14want to know our disk usage in relation
  3139. 1:55:17to the total amount available right so
  3140. 1:55:19we want to know how much we've consumed
  3141. 1:55:21uh
  3142. 1:55:22in our current uh disk where we have our
  3143. 1:55:24home directory or just on all our drives
  3144. 1:55:27right and to do this we type in df so
  3145. 1:55:29again let me just open up the man pages
  3146. 1:55:31so df
  3147. 1:55:33um you can go through all the other
  3148. 1:55:35arguments you want and we'll just quit
  3149. 1:55:38and we'll say df for example
  3150. 1:55:40all right so
  3151. 1:55:41that displays a lot of information here
  3152. 1:55:44that we we really don't need
  3153. 1:55:46we're pretty much looking for our our
  3154. 1:55:48system disks uh only
  3155. 1:55:50and uh we can sort of narrow this down
  3156. 1:55:52first of all by typing in so we can say
  3157. 1:55:54df h is going to be for human readable
  3158. 1:55:57format so again we can say man df and we
  3159. 1:55:59say grep
  3160. 1:56:01we're looking for h
  3161. 1:56:03like so
  3162. 1:56:04and uh
  3163. 1:56:05sorry let me just uh we're looking for h
  3164. 1:56:08here
  3165. 1:56:09so again h is for human readable format
  3166. 1:56:12all right so we can then say dfh
  3167. 1:56:15and we can pretty much hit enter all
  3168. 1:56:18right and what this does now is it's
  3169. 1:56:20going to display
  3170. 1:56:21all of all of your drives for you here
  3171. 1:56:24and you then have the various so for
  3172. 1:56:26example storage device c is the current
  3173. 1:56:28uh file uh the current drive that i have
  3174. 1:56:31my system installed on so it gives you
  3175. 1:56:33uh it sorts it out into the file system
  3176. 1:56:35size and a human readable format so
  3177. 1:56:37gigabyte megabyte etc uh the amount used
  3178. 1:56:40the amount available the usage
  3179. 1:56:42percentage and where it's mounted so
  3180. 1:56:44uh you can see that dev sd storage
  3181. 1:56:47device c1 is mounted is the actual linux
  3182. 1:56:50file system directory i then have
  3183. 1:56:52various other
  3184. 1:56:54external right so let's say i just
  3185. 1:56:56wanted to display the storage devices
  3186. 1:56:58right so i can you then utilize the grep
  3187. 1:57:01tool i can say
  3188. 1:57:02uh i can say grip uh sd and hit enter
  3189. 1:57:06and there we are so it tells me all
  3190. 1:57:07right so um you have sd sdc one and sdd1
  3191. 1:57:12so sdc1
  3192. 1:57:14has a total space of 117 gigabytes um
  3193. 1:57:18and again we can what we can do here is
  3194. 1:57:20uh we yeah
  3195. 1:57:22that's perfectly fine so you have the um
  3196. 1:57:24you have the current usage percentage
  3197. 1:57:26which is 16 percent uh the amount point
  3198. 1:57:28and then for my external drive
  3199. 1:57:30you can see uh this is the total amount
  3200. 1:57:32available uh the amount used the amount
  3201. 1:57:35remaining and the usage percentage and
  3202. 1:57:38where it's mounted on which is the media
  3203. 1:57:40because it's an external drive
  3204. 1:57:42all right so
  3205. 1:57:43that is essentially how to use the df
  3206. 1:57:46tool now we can specify
  3207. 1:57:48additional options to uh to to actually
  3208. 1:57:51only display
  3209. 1:57:52results that we're looking for in
  3210. 1:57:53regards to um to actually file file
  3211. 1:57:56system formats so if you're looking for
  3212. 1:57:58xt for ntfs what we can do is we can say
  3213. 1:58:02uh we can say df h t right so t will
  3214. 1:58:05specify the the file system for format
  3215. 1:58:08so again we can say xt4 and we hit enter
  3216. 1:58:10and that's going to only it's going to
  3217. 1:58:12it's only going to display linux file
  3218. 1:58:14systems and i'm going to enter and you
  3219. 1:58:15can see it tells us sdc1
  3220. 1:58:17and it gives us all the relevant
  3221. 1:58:19information regarding the the size used
  3222. 1:58:22uh used uh data the amount available and
  3223. 1:58:24the usage percentage which is currently
  3224. 1:58:26at 16
  3225. 1:58:27so again that is how to analyze your
  3226. 1:58:29disks uh your disk usage on linux and uh
  3227. 1:58:32how to you know actually deduce how much
  3228. 1:58:35disk space you're using how much is left
  3229. 1:58:37the usage amount of where your various
  3230. 1:58:39disks are mounted on etc etc
  3231. 1:58:45uh in this video going to be talking
  3232. 1:58:46about creating archives so you know
  3233. 1:58:48creating tar files dart or gzip files
  3234. 1:58:51and then extracting them so just how to
  3235. 1:58:53manage and maintain the various archives
  3236. 1:58:55you will be creating now there are many
  3237. 1:58:57reasons to create archives on linux of
  3238. 1:58:58course one of the reasons is it saves
  3239. 1:59:01space uh you can if you're taking
  3240. 1:59:03backups of particular directories uh
  3241. 1:59:05it's great to have an autumn an
  3242. 1:59:07automated script to to actually automate
  3243. 1:59:10the process of archiving the files uh
  3244. 1:59:12that's something that you can take a
  3245. 1:59:13look at with my shell scripting series
  3246. 1:59:16uh the link to that will be in the
  3247. 1:59:17description section if you're interested
  3248. 1:59:19in learning some shell scripting
  3249. 1:59:21uh but let's get started with this video
  3250. 1:59:23so uh the tool we're gonna be using is
  3251. 1:59:25the tar tool now tar is an archiving
  3252. 1:59:27utility as you can see here and again if
  3253. 1:59:30we if we take a look at the man pages
  3254. 1:59:32for this particular tool uh it gives you
  3255. 1:59:34the various options that you can use you
  3256. 1:59:36know in regards to creating uh archives
  3257. 1:59:38comparing them deleting them etc so
  3258. 1:59:41there's a lot of stuff in here
  3259. 1:59:42the purpose of this video is to show you
  3260. 1:59:44uh or to and to explain to you how to
  3261. 1:59:46create uh how to create archives uh how
  3262. 1:59:49they differ in terms of the extension
  3263. 1:59:51and of course how to extract the various
  3264. 1:59:53archives that i
  3265. 1:59:54that you'll come across
  3266. 1:59:56all right so uh on my desktop what i've
  3267. 1:59:59done is um i've created a simple
  3268. 2:00:02directory here uh let me just uh remove
  3269. 2:00:04this uh
  3270. 2:00:06this directory right over here um there
  3271. 2:00:09we are and um so i created a directory
  3272. 2:00:12called file
  3273. 2:00:13and within this directory uh you can see
  3274. 2:00:16that i've created a
  3275. 2:00:18a test.txt file that contains uh the
  3276. 2:00:21contents of the password file so just a
  3277. 2:00:23random file that you know you may want
  3278. 2:00:25to uh you may want to archive or random
  3279. 2:00:28directory that you you may want to
  3280. 2:00:29archive so if i wanted to create a tar
  3281. 2:00:32archive of this file directory what i
  3282. 2:00:34would do is i would say tar and then i
  3283. 2:00:36would specify
  3284. 2:00:38you know some arguments here
  3285. 2:00:40in in regards to what i want star to do
  3286. 2:00:43so first of all i would want dart to
  3287. 2:00:44compress the file
  3288. 2:00:46um and then of course i want uh i wanted
  3289. 2:00:49to compress
  3290. 2:00:50this file so we're specifying the file
  3291. 2:00:52um now after this we specify the name of
  3292. 2:00:55the archive that we want to give it so
  3293. 2:00:57we'll just call it file dot dar this is
  3294. 2:01:00different than a dar.gz
  3295. 2:01:02archive and i'll explain how that
  3296. 2:01:04differs shortly so then we specify the
  3297. 2:01:08the directory that we want to actually
  3298. 2:01:10archive and we hit enter
  3299. 2:01:12and there you are so you can see it
  3300. 2:01:14created uh the tar file for us and of
  3301. 2:01:16course if we type in um file and
  3302. 2:01:19file.tar you can see it tells you that
  3303. 2:01:21this is a tar archive gnut or archive
  3304. 2:01:24here so that means it was it worked
  3305. 2:01:26correctly now um
  3306. 2:01:28let me remove this uh the star archive
  3307. 2:01:30here and if we run the same command that
  3308. 2:01:33we did
  3309. 2:01:34sorry about that let me just um let me
  3310. 2:01:36let's do it one more time so you can say
  3311. 2:01:38tar
  3312. 2:01:39we can also use the uh the v command and
  3313. 2:01:42that will give us some verbose output in
  3314. 2:01:44regards to what files are currently
  3315. 2:01:46being processed uh you know in the
  3316. 2:01:48overall archiving uh process so again we
  3317. 2:01:51can say tar cvf
  3318. 2:01:53and then we say dar we can just say
  3319. 2:01:55file.um
  3320. 2:01:58file.tar and then we specify the
  3321. 2:02:00directory and we hit enter and you can
  3322. 2:02:02see it then gives you a the post output
  3323. 2:02:05and we get the dar the file.tar archive
  3324. 2:02:07here so
  3325. 2:02:09if we want to extract a tar archive
  3326. 2:02:12that's a very very simple thing to do
  3327. 2:02:14all we need to do is we say tar
  3328. 2:02:17guitar
  3329. 2:02:19and now that we want to extract it we
  3330. 2:02:21use the x command uh by the way you can
  3331. 2:02:23you can negate or not use the iphone
  3332. 2:02:26here but i personally like using the
  3333. 2:02:28iphone just so that i understand where
  3334. 2:02:30my syntax is going so i can say extract
  3335. 2:02:33and we can verbose you know we can have
  3336. 2:02:35some verbose output
  3337. 2:02:37and we say extract
  3338. 2:02:39the file and then we specify the file so
  3339. 2:02:42we say file.tar and then we can provide
  3340. 2:02:46an output for it or you can just hit
  3341. 2:02:47enter and it you know it extracts it for
  3342. 2:02:50us and because we already have the file
  3343. 2:02:52here uh it will essentially overwrite
  3344. 2:02:54the
  3345. 2:02:55uh the newer files if the if there are
  3346. 2:02:57any new changes etc so we can uh
  3347. 2:03:00we can remove this directory and do that
  3348. 2:03:02one more time here so we can say star
  3349. 2:03:06xvf
  3350. 2:03:07file dot r and we hit enter now if we
  3351. 2:03:10list this you can see that we have the
  3352. 2:03:12file directory here all right excellent
  3353. 2:03:15so that's uh working with star files and
  3354. 2:03:17that's you know a standard tar
  3355. 2:03:20a guitar file here uh now let's talk
  3356. 2:03:22about gzip files so if i say what is
  3357. 2:03:26gzip and uh you can do this with star
  3358. 2:03:28again uh it's a very very simple you
  3359. 2:03:31that's the preferred way of doing it so
  3360. 2:03:33uh let's take the um
  3361. 2:03:36the same or we can just remove the file
  3362. 2:03:38dot our here so let's take the same
  3363. 2:03:41file directory here and if we want to
  3364. 2:03:44now use the or compress it
  3365. 2:03:47into a third or gzip file
  3366. 2:03:50using gzip of course then we would say
  3367. 2:03:53tar
  3368. 2:03:55uh now we are compressing it so we say c
  3369. 2:03:57z uh f or c z c v z f or c z v f
  3370. 2:04:02whatever you want to use in our case we
  3371. 2:04:04we don't want to work or we want to
  3372. 2:04:06display uh you know some the verbose
  3373. 2:04:09output so we can just use the czf
  3374. 2:04:12and then we specify um
  3375. 2:04:14we specify the name so we're going to
  3376. 2:04:16say file.tar
  3377. 2:04:18register and then we specify the
  3378. 2:04:20directory that we want to archive or
  3379. 2:04:22compress and we hit enter
  3380. 2:04:24and you can now see that we created the
  3381. 2:04:27gz file here so if we type in file and
  3382. 2:04:29then you know just to find out what
  3383. 2:04:31we're dealing with the ui tells you
  3384. 2:04:33we're dealing with a gzip compressed
  3385. 2:04:35data
  3386. 2:04:37so again we can extract it really simply
  3387. 2:04:39by saying dar
  3388. 2:04:41um dar x z f
  3389. 2:04:44x z f and then we say file
  3390. 2:04:46dot r g z but uh before we do this uh
  3391. 2:04:49let's remove uh let's remove the actual
  3392. 2:04:54file directory here so we say term
  3393. 2:04:57x zf and then we say
  3394. 2:04:59file.gz and we hit enter and it'll then
  3395. 2:05:03give us the file directory which is
  3396. 2:05:05right over here so again we can cut the
  3397. 2:05:06contents just to show you that it's
  3398. 2:05:08worked just fine
  3399. 2:05:10um
  3400. 2:05:11you can see that it's the entire content
  3401. 2:05:13of the password file so that's pretty
  3402. 2:05:15much how to work with archives i'm not
  3403. 2:05:17going to be covering the various other
  3404. 2:05:18utilities that you can use so for
  3405. 2:05:20example bc2 which is again very simple
  3406. 2:05:23use uh in regards to using bzip2 for
  3407. 2:05:26compression i wanted to show you how to
  3408. 2:05:28use the tar uh guitar utility for
  3409. 2:05:31archiving files archiving them and then
  3410. 2:05:33of course extracting them so it's the
  3411. 2:05:34most reliable and consistent way of
  3412. 2:05:37working with archives on linux and it's
  3413. 2:05:39great for you know taking backups and
  3414. 2:05:41with the help of a shell script you can
  3415. 2:05:43easily automate the process
  3416. 2:05:48in this video i'm going to be talking
  3417. 2:05:50about uh you know adding managing users
  3418. 2:05:52and groups and then in the follow up
  3419. 2:05:54videos we'll be talking about user
  3420. 2:05:56security and sort of securing the
  3421. 2:05:58authentication uh section or area of of
  3422. 2:06:01linux so let's get started now i just
  3423. 2:06:03want to give you a bit of a premise
  3424. 2:06:05i'm currently running a um currently
  3425. 2:06:07logged in by ssh onto one of my uh linux
  3426. 2:06:10servers and the reason being is as we
  3427. 2:06:12move on into this series to to the end
  3428. 2:06:14or to the completion uh i'll be covering
  3429. 2:06:16security uh you know various security
  3430. 2:06:19aspects that we will require a lot of
  3431. 2:06:20testing so again uh that's primarily the
  3432. 2:06:22reason so let's get started now by
  3433. 2:06:24default
  3434. 2:06:25uh you can see that i've created another
  3435. 2:06:27user called admin
  3436. 2:06:29and i'm currently running ubuntu server
  3437. 2:06:31so
  3438. 2:06:32what's going to happen is uh it is
  3439. 2:06:34recommended never to only be using the
  3440. 2:06:36root user and that you need to have
  3441. 2:06:38another user in which you can then uh
  3442. 2:06:40start you know applying various
  3443. 2:06:42permissions to so by default on ubuntu
  3444. 2:06:45uh when working with users again is a
  3445. 2:06:48very very simple syntax in regards to
  3446. 2:06:50adding them so what we're going to do is
  3447. 2:06:51we're just going to create a user here
  3448. 2:06:53we're just going to say user add and you
  3449. 2:06:55can take a look at all the uh the
  3450. 2:06:57various options you can use when
  3451. 2:06:59specifying a user
  3452. 2:07:00so if i just say uh user add and i hit
  3453. 2:07:04enter you can see it doesn't give me any
  3454. 2:07:06prompt but if i say user add alexis and
  3455. 2:07:09i hit enter it will give me
  3456. 2:07:11an error with the um
  3457. 2:07:13it will give me an error with with a
  3458. 2:07:15lack of permissions now i did this uh
  3459. 2:07:17you know deliberately so that i can
  3460. 2:07:19demonstrate uh how to use groups before
  3461. 2:07:21we actually take a look at that so i'll
  3462. 2:07:23just switch i'll just switch into the
  3463. 2:07:25root user here
  3464. 2:07:26and we'll go into my home directory and
  3465. 2:07:28we'll just say v sudo here uh so we'll
  3466. 2:07:31say v sudo and
  3467. 2:07:33what we want to do now
  3468. 2:07:35is we have the user admin uh but we want
  3469. 2:07:38to
  3470. 2:07:39we want to actually have this user
  3471. 2:07:42[Music]
  3472. 2:07:43we want to add this user admin into the
  3473. 2:07:45sudo group which will essentially allow
  3474. 2:07:48members of the group to execute any
  3475. 2:07:49command now i can do that or i can also
  3476. 2:07:51add them to the admin to the admin group
  3477. 2:07:54which which would be better
  3478. 2:07:56um so again we can sort of customize the
  3479. 2:07:59various uh the various commands that we
  3480. 2:08:01can specify and i'll get to this in a
  3481. 2:08:02second so
  3482. 2:08:03uh what we want to do now is i'll just
  3483. 2:08:06exit and i'll say user mod
  3484. 2:08:08and i'll say user mod a
  3485. 2:08:11g
  3486. 2:08:12ad group and then we say
  3487. 2:08:14admin and the user admin and we hit
  3488. 2:08:17enter and that's going to add the user
  3489. 2:08:19admin into the group admin so you
  3490. 2:08:21specify the group first and then the
  3491. 2:08:22user there that might might seem a bit
  3492. 2:08:25confusing but if i just say groups uh
  3493. 2:08:27groups admin you can see that it tells
  3494. 2:08:30me that the user admin is in the group
  3495. 2:08:32admin all right so if we go back into
  3496. 2:08:33the user admin here
  3497. 2:08:35you can see it tells you to run a
  3498. 2:08:36command as administrator use
  3499. 2:08:39user root use the sudo command so again
  3500. 2:08:41we now have permissions to do whatever
  3501. 2:08:42we want so if we go back here
  3502. 2:08:45we can say sudo user add
  3503. 2:08:48user add and
  3504. 2:08:49again that will give us the same option
  3505. 2:08:51so if we say user ad alexis
  3506. 2:08:53uh it's going to add the user now the
  3507. 2:08:55problem with this if i display the
  3508. 2:08:57password file
  3509. 2:08:58you can see that the user alexis by
  3510. 2:09:00default will be given a home directory
  3511. 2:09:02that's perfectly fine and the diff the
  3512. 2:09:04default shell will be set to the bond
  3513. 2:09:06shell so what i want to do is let me
  3514. 2:09:08show you how to remove a user so to
  3515. 2:09:10remove a user we say user dell and then
  3516. 2:09:12if we want to remove their home
  3517. 2:09:13directory
  3518. 2:09:14we say uh r or we use the recursive
  3519. 2:09:17command and then we specify the user so
  3520. 2:09:19we can say alexis
  3521. 2:09:20and again we need to use um
  3522. 2:09:24the
  3523. 2:09:24we need to use the sudo command here
  3524. 2:09:26because we require root privileges so
  3525. 2:09:28it's going to remove
  3526. 2:09:31it's going to remove the user so if we
  3527. 2:09:32just display the
  3528. 2:09:34uh the contents of the home directory we
  3529. 2:09:36can see that the only user directories
  3530. 2:09:37we have are for the user admin all right
  3531. 2:09:39so now that i've explained that let me
  3532. 2:09:40show you the correct syntax for adding a
  3533. 2:09:43user here so again i can just say user
  3534. 2:09:45ad now
  3535. 2:09:47uh in regards to the actual commands you
  3536. 2:09:49can use you can take a look at the man
  3537. 2:09:51pages uh sorry um
  3538. 2:09:53user ad and you can take a look at all
  3539. 2:09:56of these options and there's a quite
  3540. 2:09:58extensive options you can use in regards
  3541. 2:10:00to creating user but in our case we want
  3542. 2:10:03to say user ad and um
  3543. 2:10:05the first thing we want to do is we want
  3544. 2:10:07to make sure that this user has a home
  3545. 2:10:09directory with its username appended so
  3546. 2:10:12we can say m
  3547. 2:10:13and then we can add a comment so again
  3548. 2:10:15this can describe uh you know something
  3549. 2:10:17about the account and what it's used for
  3550. 2:10:19we can just say alexis and we can then
  3551. 2:10:21specify the shell this is very important
  3552. 2:10:23if you want a uh
  3553. 2:10:25if you want the user account to to use a
  3554. 2:10:27custom shell
  3555. 2:10:29in our case we'll just say bin bash and
  3556. 2:10:31then we specify the name of the user
  3557. 2:10:33account or the username and we hit enter
  3558. 2:10:35all right so again it tells us we need
  3559. 2:10:36sudo privileges so let's add that and
  3560. 2:10:39i'll just hit enter and the the user is
  3561. 2:10:41added now this user doesn't have a
  3562. 2:10:43password yet so to add a password for a
  3563. 2:10:46user we can say we can use the password
  3564. 2:10:48command all right and again it requires
  3565. 2:10:50root
  3566. 2:10:50privileges
  3567. 2:10:52so if i wanted to change the password
  3568. 2:10:54for the admin account or for the current
  3569. 2:10:56account that i'm using i simply type in
  3570. 2:10:57password and it'll say changing password
  3571. 2:11:00for admin and it'll ask me for my
  3572. 2:11:01current password
  3573. 2:11:02i'll enter a new password here
  3574. 2:11:05and the password isn't changed so i just
  3575. 2:11:07wanted to demonstrate this so again i
  3576. 2:11:09can just say let me just change the
  3577. 2:11:11password here
  3578. 2:11:12and i'll just change it to something
  3579. 2:11:15different and there we are so the
  3580. 2:11:16password for the admin user has been
  3581. 2:11:18updated successfully
  3582. 2:11:20if i wanted to change the password for
  3583. 2:11:22another user i would say password alexis
  3584. 2:11:24and hit enter
  3585. 2:11:26so again we we can use the sudo
  3586. 2:11:28privileges because we're now modifying
  3587. 2:11:34and
  3588. 2:11:36sorry about this let's just add um
  3589. 2:11:40and there we are so now we've added the
  3590. 2:11:42password for the user lexis so i can
  3591. 2:11:44directly switch uh into this user
  3592. 2:11:47account and i'll show you something
  3593. 2:11:49interesting here so i can say sudo
  3594. 2:11:51alexis
  3595. 2:11:52um and i switch into it and um
  3596. 2:11:56there we are so now if i try and do
  3597. 2:11:57something like sudo apt update here
  3598. 2:12:00uh it'll ask me for the user for the
  3599. 2:12:02password and um well i think i entered
  3600. 2:12:04the correct the incorrect password here
  3601. 2:12:06so if i enter the correct password you
  3602. 2:12:08can see it's going to tell us that
  3603. 2:12:09alexis is not in the sudoes file this
  3604. 2:12:11incident will be reported all right so
  3605. 2:12:14that's um that's essentially telling us
  3606. 2:12:16we don't have adequate adequate
  3607. 2:12:18permission so if we go back into the
  3608. 2:12:19admin account
  3609. 2:12:20um
  3610. 2:12:22we can now play around with the sudoers
  3611. 2:12:25file so again we'll say sudo vsudo and
  3612. 2:12:28we'll hit enter and let's talk about now
  3613. 2:12:30adding permissions and before we
  3614. 2:12:32actually take a look at groups
  3615. 2:12:34right so typically with ubuntu uh you
  3616. 2:12:37can see that it gives you all of these
  3617. 2:12:38various groups you know right out of the
  3618. 2:12:40bat and you you can specify specific
  3619. 2:12:43user privileges
  3620. 2:12:45under this right over here so you can
  3621. 2:12:46see for the root user um
  3622. 2:12:49it can run it from all uh sessions
  3623. 2:12:51irregardless of whether it's a tty uh or
  3624. 2:12:54a remote session
  3625. 2:12:55uh and then you know for all users in
  3626. 2:12:58all groups and it can run all commands
  3627. 2:12:59so again again just say alexis and let's
  3628. 2:13:02say all or you know i can just simply
  3629. 2:13:04say
  3630. 2:13:05uh all sorry that's always going to be
  3631. 2:13:07equal to all and so that's pretty much
  3632. 2:13:10uh all users um
  3633. 2:13:13and then in regards to the command
  3634. 2:13:15specification which you specify here so
  3635. 2:13:17this user can actually run all
  3636. 2:13:20permissions or i can limit it to you
  3637. 2:13:22know certain permissions if i want to
  3638. 2:13:24right now again
  3639. 2:13:26this will pretty much
  3640. 2:13:29this this will pretty much allow me to
  3641. 2:13:32to actually run uh specific commands so
  3642. 2:13:35for example if i wanted to only allow
  3643. 2:13:37this user to say for example user bin
  3644. 2:13:40apt
  3645. 2:13:41get
  3646. 2:13:42for example um so what i'll do is i'll
  3647. 2:13:44just save this file and we'll go back
  3648. 2:13:46into the user lexis here
  3649. 2:13:48um and we'll say
  3650. 2:13:51and then we say sudo apt get and many of
  3651. 2:13:54you might be catching on and you'll see
  3652. 2:13:56what happens here
  3653. 2:13:58so you can see that that works now and
  3654. 2:14:01we're able to run only that command with
  3655. 2:14:02root privileges
  3656. 2:14:04so we'll just wait for this to actually
  3657. 2:14:06update the repositories
  3658. 2:14:08let's try and run another command with
  3659. 2:14:10root privileges and i'll show you what
  3660. 2:14:11will happen here so
  3661. 2:14:13again my apologies my internet is
  3662. 2:14:16really not that quick um so we'll just
  3663. 2:14:18wait for this to complete
  3664. 2:14:21and um
  3665. 2:14:22so there we are
  3666. 2:14:23got the repos and you know i can pretty
  3667. 2:14:25much install software and i can use the
  3668. 2:14:28app to get a utility so if i say sudo
  3669. 2:14:31um let's say vim
  3670. 2:14:33hc
  3671. 2:14:34ssh sshd config if we open this you can
  3672. 2:14:38see we're not allowed to do this so if
  3673. 2:14:40we go back into the admin user
  3674. 2:14:42you can see now this is a great way of
  3675. 2:14:45you know specifying um specifying
  3676. 2:14:48permissions for users so
  3677. 2:14:50additionally what i can do is i can use
  3678. 2:14:52groups right now
  3679. 2:14:54i have the user alexis here and let me
  3680. 2:14:56just comment this if i say all commands
  3681. 2:14:59uh that means it can run all commands
  3682. 2:15:01here without any uh without any
  3683. 2:15:03restrictions so we then have groups
  3684. 2:15:05right now groups
  3685. 2:15:06allow
  3686. 2:15:08groups essentially allow users to allows
  3687. 2:15:10you to group users you know based on
  3688. 2:15:12their particular role or
  3689. 2:15:14responsibilities now in this case we
  3690. 2:15:15have two groups we have admin and sudo
  3691. 2:15:18and they essentially allow users to
  3692. 2:15:19execute all commands with root
  3693. 2:15:21privileges here
  3694. 2:15:23um so
  3695. 2:15:24uh what we can do is uh we can create
  3696. 2:15:27another group here so uh
  3697. 2:15:30we can just exit out of this uh well
  3698. 2:15:32actually no
  3699. 2:15:33we can just modify this one more time
  3700. 2:15:36because uh i want to actually comment
  3701. 2:15:38this in regards to the permissions here
  3702. 2:15:40so we'll just exit and let's talk about
  3703. 2:15:42groups all right so let's talk about
  3704. 2:15:44groups in linux now groups are a great
  3705. 2:15:47way of sort of collectively applying
  3706. 2:15:49permissions to you know groups of users
  3707. 2:15:52that you know you may want to have uh
  3708. 2:15:54you know the same privileges uh or
  3709. 2:15:57permissions uh and you know it's a great
  3710. 2:15:59way of
  3711. 2:16:00blanketing
  3712. 2:16:01various permissions on different users
  3713. 2:16:03and a great way of of course segregating
  3714. 2:16:05roles and duties within a system so it's
  3715. 2:16:08a great way of actually actively
  3716. 2:16:11uh
  3717. 2:16:12actively approaching uh the whole idea
  3718. 2:16:15of segregation of roles and duties so
  3719. 2:16:18let's talk about uh creating groups uh
  3720. 2:16:20deleting groups and of course working
  3721. 2:16:22with permissions with groups so we're
  3722. 2:16:24going to follow this the same scenario
  3723. 2:16:26we have the admin user uh and of course
  3724. 2:16:29we then have the user alexis here so the
  3725. 2:16:31user lexis currently is not part of any
  3726. 2:16:34any any particular group so again it's a
  3727. 2:16:36standard user account that doesn't have
  3728. 2:16:38root privileges and is simply just
  3729. 2:16:40allowed to operate within those
  3730. 2:16:42constraints now if i wanted to add a
  3731. 2:16:44group here i would say group add right
  3732. 2:16:47and then i'll specify the name of the
  3733. 2:16:48group so let's say we want to add the
  3734. 2:16:51the user alexis to a group called
  3735. 2:16:54developers
  3736. 2:16:55right so we're going to say group add
  3737. 2:16:57developers let me just prepend this with
  3738. 2:16:59sudo because we do need root privileges
  3739. 2:17:02to create new groups and we're going to
  3740. 2:17:03hit enter all right so now we have the
  3741. 2:17:06group created so if we want to display
  3742. 2:17:08groups for a particular user or the
  3743. 2:17:10groups that a user is in again we use
  3744. 2:17:12groups and then the name of the user
  3745. 2:17:15and you it tells you that alexis
  3746. 2:17:16currently is is in its own group we can
  3747. 2:17:19view all the groups on the system by
  3748. 2:17:21visiting the or cutting or displaying
  3749. 2:17:24the contents of the group a file if we
  3750. 2:17:27hit enter you can see that we have the
  3751. 2:17:29various groups and you can see we have
  3752. 2:17:31all the system accounts as well as
  3753. 2:17:33pretty much they're going to be in their
  3754. 2:17:34own group unless
  3755. 2:17:36uh specified otherwise
  3756. 2:17:40um so let's uh let what we're gonna do
  3757. 2:17:43is we're going to add the user alexis
  3758. 2:17:46into this developers group and then i'll
  3759. 2:17:47show you how permissions can sort of be
  3760. 2:17:50uh be manipulated that way so we're
  3761. 2:17:52gonna say user mod and we're gonna say
  3762. 2:17:54we're gonna append append
  3763. 2:17:56the user lexis and we're going to say
  3764. 2:17:58the group by the way you can use a
  3765. 2:18:00lowercase g here the lowercase g
  3766. 2:18:02primarily means you need to specify the
  3767. 2:18:04group ids in our case we'll just use the
  3768. 2:18:07capital g because we know the names of
  3769. 2:18:09head
  3770. 2:18:10so we'll say developers and we want to
  3771. 2:18:12add the user alexis to the group
  3772. 2:18:14developers
  3773. 2:18:16i believe we need root privileges for
  3774. 2:18:18this so i'm going to enter and that
  3775. 2:18:20should do it all right so now if i say
  3776. 2:18:21groups alexis you can see that alex is
  3777. 2:18:24going to be part of its own group and
  3778. 2:18:26uh
  3779. 2:18:27and the developers group now when we
  3780. 2:18:29talk about having its own group that
  3781. 2:18:31simply refers to you know user specific
  3782. 2:18:33privilege specifications so again if we
  3783. 2:18:35visit the uh the v sudo uh utility uh to
  3784. 2:18:39modify the sudoes file
  3785. 2:18:42you can see that we talked about user
  3786. 2:18:44user privilege specification and we had
  3787. 2:18:46actually added a uh you know some
  3788. 2:18:49privileged specifications for the user
  3789. 2:18:52alexis where
  3790. 2:18:54you know we can access it from all hosts
  3791. 2:18:56and we've specified all users however
  3792. 2:18:58not all groups so this essentially will
  3793. 2:19:01restrict
  3794. 2:19:03uh this will restrict
  3795. 2:19:05the user alexis uh
  3796. 2:19:07and it will essentially allow him to run
  3797. 2:19:09uh you know the apt-get utility with
  3798. 2:19:12root privileges here
  3799. 2:19:14however
  3800. 2:19:16that's one way of doing it so if if i
  3801. 2:19:18use this if i use this this same syntax
  3802. 2:19:22uh then i can also you know allow it to
  3803. 2:19:24run all commands
  3804. 2:19:26and you know i can also specify the uh
  3805. 2:19:28the exp explicitly to refuse
  3806. 2:19:32to refuse it to use the root uh to
  3807. 2:19:35actually have pseudo privileges so it
  3808. 2:19:37will only run this command
  3809. 2:19:39uh and and you know so on and so forth
  3810. 2:19:41so i can do that actively if i wanted to
  3811. 2:19:43however i don't want to so what we'll do
  3812. 2:19:45is let's just test this out to see that
  3813. 2:19:47it works and of course you can change
  3814. 2:19:49this to whatever
  3815. 2:19:50whatever command that will require you
  3816. 2:19:52know root privileges so we can just use
  3817. 2:19:54app to get here and i'll save this now v
  3818. 2:19:57sudo when saving and exec
  3819. 2:19:59and exiting if you do have a syntax
  3820. 2:20:01error it will tell you so again if we go
  3821. 2:20:03here and we say
  3822. 2:20:05let's uh let let's actually mess around
  3823. 2:20:07with the syntax here so again i can just
  3824. 2:20:09say add a few uh commas there you can
  3825. 2:20:13see that it tells us uh in the etsy
  3826. 2:20:15pseudo as well as syntax error near line
  3827. 2:20:1721 and we can use the e command to edit
  3828. 2:20:20it so again that's a great uh that's the
  3829. 2:20:22great uh reason for using these the uh
  3830. 2:20:26the v sudo utility it actually points
  3831. 2:20:28out logical and uh and syntax errors
  3832. 2:20:32so we'll save this now and we'll exit
  3833. 2:20:35and what we'll do is we'll now switch
  3834. 2:20:37into the user lexis and um
  3835. 2:20:40i'll go here and you can see that now if
  3836. 2:20:42i type in apt-get update you can see
  3837. 2:20:44that we can run this command but it
  3838. 2:20:46still requires administrative privileges
  3839. 2:20:48or root privileges so if we pre-pend it
  3840. 2:20:51with root or sorry sudo
  3841. 2:20:54if we say sudo and we hit up and we just
  3842. 2:20:56enter the password you can see that
  3843. 2:20:58we're able to run the command however if
  3844. 2:21:01we wanted to display the um we say cat
  3845. 2:21:04etsy shadow
  3846. 2:21:06uh
  3847. 2:21:08cat etsy shadow is going to tell you
  3848. 2:21:10these alexis is not allowed to execute
  3849. 2:21:12cat etsy shadow with you know root
  3850. 2:21:15privileges so again we can say cat
  3851. 2:21:17hc password here that works because it
  3852. 2:21:20doesn't require root privileges and we
  3853. 2:21:22are pretty much allowed to view the
  3854. 2:21:24contents of this file
  3855. 2:21:26all right so that's how to apply
  3856. 2:21:27permissions based on a user all right
  3857. 2:21:30now i can also change this up and we can
  3858. 2:21:32use the the example of the group here so
  3859. 2:21:35we can just go back into the user admin
  3860. 2:21:38and
  3861. 2:21:38just enter the password here and again
  3862. 2:21:40we'll say sudo
  3863. 2:21:42vsudo and we'll get into this so we'll
  3864. 2:21:45comment this uh you know user privilege
  3865. 2:21:47specification entry and we can enter our
  3866. 2:21:49group anywhere here we can just add a
  3867. 2:21:51comment if we wanted to
  3868. 2:21:56specification
  3869. 2:21:58um developer group
  3870. 2:22:00we can just say developer group and then
  3871. 2:22:02we say
  3872. 2:22:03when adding a group we prepend it with
  3873. 2:22:05the the modulus sign and then we say we
  3874. 2:22:09specify the name of the group so we say
  3875. 2:22:11developers and then after this we
  3876. 2:22:13specify the permissions here so again we
  3877. 2:22:15can say all
  3878. 2:22:16all hosts and then we'll say all users
  3879. 2:22:20of all groups that's because we need a
  3880. 2:22:23sudo that's very important we need the
  3881. 2:22:26ability to access all the groups so
  3882. 2:22:28again we can all we can always limit it
  3883. 2:22:30to
  3884. 2:22:31uh all users and then the admin group if
  3885. 2:22:34we wanted to but again we say all
  3886. 2:22:38and then instead of all commands we say
  3887. 2:22:40user bin
  3888. 2:22:43we can say apt user pin
  3889. 2:22:46sorry user bin apt get update uh sorry
  3890. 2:22:49apt-get sorry not update
  3891. 2:22:52um so we can save this and if we exit
  3892. 2:22:54you can see we have no syntax errors so
  3893. 2:22:56again back to alexis here
  3894. 2:22:59and i will enter the password
  3895. 2:23:01and uh yeah so now we can say sudo apt
  3896. 2:23:05uh
  3897. 2:23:06get update and that works fine uh for
  3898. 2:23:09some reason
  3899. 2:23:11uh not allowed to execute uh let me just
  3900. 2:23:14check this right now uh yeah it's part
  3901. 2:23:16of the developers group uh let me just
  3902. 2:23:19go back into the admin group here oh
  3903. 2:23:21sorry into the admin user
  3904. 2:23:23and uh let's see what the issue is
  3905. 2:23:26what's the issue is with the
  3906. 2:23:27specification of uh
  3907. 2:23:30of permissions here um
  3908. 2:23:33so
  3909. 2:23:35what i'll do is um let's see what can be
  3910. 2:23:39this shouldn't be causing any issues uh
  3911. 2:23:42let's try apt and let's just see whether
  3912. 2:23:44this works i'll just say
  3913. 2:23:54i have to update that that works fine
  3914. 2:23:57um i believe you need to add yeah you
  3915. 2:23:59need to separate the commands and it
  3916. 2:24:02would be wise to use command command
  3917. 2:24:04aliases so yeah i i simply forgot about
  3918. 2:24:06that sorry about that guys um so so that
  3919. 2:24:08will work fine so again if we say sudo
  3920. 2:24:11cat etsy shadow
  3921. 2:24:13for example
  3922. 2:24:14yeah because we wanted to view it you
  3923. 2:24:16can see it again it restricts us to
  3924. 2:24:18running uh only the apt update utility
  3925. 2:24:20or running the app utility here so that
  3926. 2:24:23is how to you know sort of segregate
  3927. 2:24:25permissions based on a user whether you
  3928. 2:24:26want to specify the permissions you know
  3929. 2:24:28on a user to use a basis
  3930. 2:24:30or how to specify the permissions on a
  3931. 2:24:32you know in in regards to adding users
  3932. 2:24:35to a group and then applying them that
  3933. 2:24:36way sort of blanketing the users that
  3934. 2:24:39way so again it's all about
  3935. 2:24:41you know what philosophy you are you
  3936. 2:24:42adapt to and if you're a system
  3937. 2:24:44administrator it'll also depend on the
  3938. 2:24:46use case and the use you usage scenario
  3939. 2:24:49in which your server is being deployed
  3940. 2:24:52in
  3941. 2:24:56we're going to be talking about
  3942. 2:24:57networking uh in the command line all
  3943. 2:24:59right so let's get started now
  3944. 2:25:01um if you pretty much watched any of my
  3945. 2:25:04older videos where we were working with
  3946. 2:25:06networking within the linux terminal you
  3947. 2:25:08know that i would typically use the
  3948. 2:25:10ifconfig utility however
  3949. 2:25:13you know the standard has changed now
  3950. 2:25:15and what we have to use or what is the
  3951. 2:25:17preferred method of getting information
  3952. 2:25:20and interacting with various network
  3953. 2:25:22interfaces is by using the ip command
  3954. 2:25:24right so the ip
  3955. 2:25:26utility allows you to you know show
  3956. 2:25:28manipulate routing network devices
  3957. 2:25:30interfaces and tunnels etc
  3958. 2:25:32all right so let's get started by first
  3959. 2:25:35of all um understanding how to display
  3960. 2:25:37your current uh routing table so again
  3961. 2:25:39we can do that by typing in ip route
  3962. 2:25:42show and that's very simple so ip route
  3963. 2:25:44show and this will show you your current
  3964. 2:25:46uh routing table so you can see this is
  3965. 2:25:48my uh this is uh this is currently my
  3966. 2:25:51router's ip address or my gateway uh
  3967. 2:25:53this is my interface name here and this
  3968. 2:25:56is the source ip which is my ip address
  3969. 2:25:58so that gives you an idea of uh of your
  3970. 2:26:00ip routing table uh currently
  3971. 2:26:03now again you can take a look at uh we
  3972. 2:26:06can grip route here and uh in the man
  3973. 2:26:09pages and you can take a look at all the
  3974. 2:26:10options you have available for you um so
  3975. 2:26:13you can pretty much change the route if
  3976. 2:26:15you want to do but of course that's
  3977. 2:26:16beyond the scope of this tutorial i'm
  3978. 2:26:18simply showing you how to find
  3979. 2:26:20information that's very useful if you
  3980. 2:26:21want to display your current ip address
  3981. 2:26:23we type in
  3982. 2:26:25ipaddr and we hit enter and this gives
  3983. 2:26:28you your two interfaces so we have local
  3984. 2:26:31this is a loop back so this is you know
  3985. 2:26:33for your local host
  3986. 2:26:35uh and you then have your ethernet in my
  3987. 2:26:37case my ethernet adapter which has the
  3988. 2:26:39interface name enp2so
  3989. 2:26:42you can see that it has an ip of
  3990. 2:26:45192.168.1.1
  3991. 2:26:48and you have the uh the entire uh
  3992. 2:26:51the entire network range there
  3993. 2:26:53um you also have your your ipv6 ip
  3994. 2:26:56address here that is required and of
  3995. 2:26:58course you have your mac address so very
  3996. 2:27:00similar to ifconfig um so if we
  3997. 2:27:03if we take a look at ifconfig which is a
  3998. 2:27:06perfectly great uh tool that you can use
  3999. 2:27:08and so you know you can use it if i type
  4000. 2:27:10in i have config
  4001. 2:27:12we can take a look at the man pages here
  4002. 2:27:14just so i can show you the flexibility
  4003. 2:27:16so again uh you can play around with all
  4004. 2:27:18the options that are available but
  4005. 2:27:20pretty much the simple way of going
  4006. 2:27:22about it would be to simply display your
  4007. 2:27:24current um so if i say ifconfig
  4008. 2:27:28and i'm only looking for my
  4009. 2:27:30i can say inets if i'm only looking for
  4010. 2:27:32my ipv4 address or my inet addresses you
  4011. 2:27:35can see that i can easily just print
  4012. 2:27:37them out and i also have my net mask so
  4013. 2:27:39a very organized way of taking a look at
  4014. 2:27:42your your interfaces and your ip
  4015. 2:27:44addresses as well
  4016. 2:27:46right now i'm still to make a video on
  4017. 2:27:48on managing services
  4018. 2:27:51and processes with linux but uh
  4019. 2:27:53essentially working with your network
  4020. 2:27:55manager we can also take a look at dhcp
  4021. 2:27:58because that would be quite important so
  4022. 2:28:00if you are running this on wi-fi or you
  4023. 2:28:02are using a wireless adapter or even an
  4024. 2:28:04ethernet where you don't have static ip
  4025. 2:28:08distribution
  4026. 2:28:10or resolution what we can do is if we
  4027. 2:28:12say what is dhclient um and we can just
  4028. 2:28:15hit enter you can see that uh if we type
  4029. 2:28:17in dh client and we hit enter you can
  4030. 2:28:19see that it doesn't give us any
  4031. 2:28:22any options here so if we take a look at
  4032. 2:28:23the options that we available to use we
  4033. 2:28:26can pretty much um
  4034. 2:28:28let's take a look at the man pages
  4035. 2:28:29because this is a bit better way of
  4036. 2:28:32actually utilizing it so again we can
  4037. 2:28:34use the dhcp v4 protocol to obtain
  4038. 2:28:38a new ipv4 address but in my case i i
  4039. 2:28:41have my ip statically uh assigned here
  4040. 2:28:43so that would not be a wise thing to do
  4041. 2:28:46but if i wanted to restart my network
  4042. 2:28:47manager uh again i'll be making a an
  4043. 2:28:50individual video on this so you don't
  4044. 2:28:52have to worry so you can use sudo
  4045. 2:28:53service
  4046. 2:28:54network
  4047. 2:28:57network manager
  4048. 2:28:58um
  4049. 2:29:00restart and i can hit enter or i can use
  4050. 2:29:02system d so i can say sudo system
  4051. 2:29:05control
  4052. 2:29:06uh we can say restart we say network
  4053. 2:29:09let me just see network we're looking
  4054. 2:29:11for the network manager here so if i let
  4055. 2:29:13me just tab and see what we have we're
  4056. 2:29:16looking for the network manager.service
  4057. 2:29:18which is right over here so i can
  4058. 2:29:20execute this and that will essentially
  4059. 2:29:21restart it now again as i said if you're
  4060. 2:29:23not familiar with processes don't worry
  4061. 2:29:25we'll be covering it in the next set of
  4062. 2:29:27videos as we wind up this series
  4063. 2:29:29but that's pretty much how to restart
  4064. 2:29:32your network adapter if you're having
  4065. 2:29:33any issues and you can sort of work with
  4066. 2:29:35that now let's talk about netstat
  4067. 2:29:38because again that's quite an important
  4068. 2:29:40tool and i haven't i have a an
  4069. 2:29:42independent video on how to use netstat
  4070. 2:29:44if you are interested in it so again we
  4071. 2:29:46can say netstat and we hit enter say
  4072. 2:29:49print network connections routing tables
  4073. 2:29:51uh et cetera et cetera so i'll just go
  4074. 2:29:53i'll just go over the most common
  4075. 2:29:55options you can use and this essentially
  4076. 2:29:56allows you to understand what uh what
  4077. 2:29:59services ports uh you have running
  4078. 2:30:01listening and are you are connected to
  4079. 2:30:03so for example
  4080. 2:30:04if i wanted to display the route i would
  4081. 2:30:06say net stat and i would say r and that
  4082. 2:30:09gives me my routing table so we have the
  4083. 2:30:11destination uh the gateway the gen mask
  4084. 2:30:14flags and the interface here
  4085. 2:30:17so in all cases we're working with my uh
  4086. 2:30:18with my ethernet interface here so you
  4087. 2:30:21can see that
  4088. 2:30:23for the default gateway uh we have it
  4089. 2:30:25right over here the destination and of
  4090. 2:30:27course the gen mask so again you can get
  4091. 2:30:29very good information from this now if
  4092. 2:30:31we wanted to take a look at all the tcp
  4093. 2:30:33connections that we have we can say net
  4094. 2:30:36stat and we use t and that gives us all
  4095. 2:30:39the tcp connections on uh that we are
  4096. 2:30:41currently connected to or listening
  4097. 2:30:43for on our system so you can see that uh
  4098. 2:30:47we have the protocol which is very
  4099. 2:30:48important this is this is uh uniquely
  4100. 2:30:51going to be tcp
  4101. 2:30:52uh the local address the foreign address
  4102. 2:30:54the port it gives you and the state
  4103. 2:30:56which i'll get to in a second
  4104. 2:30:58um so you can pretty you can also grab
  4105. 2:31:00information from this so again you can
  4106. 2:31:02say grip and if i had the ssh
  4107. 2:31:04uh port open uh i would hit i'll say
  4108. 2:31:07grep 22 for example and uh you pretty
  4109. 2:31:10much gives you results based on
  4110. 2:31:12the actual string of characters in this
  4111. 2:31:14case it's not giving us anything new but
  4112. 2:31:16if all to say
  4113. 2:31:17um let's say
  4114. 2:31:19sudo
  4115. 2:31:21sudo
  4116. 2:31:22service ssh
  4117. 2:31:24start now hit enter
  4118. 2:31:27and if we try and grip this now uh we
  4119. 2:31:29don't get anything so let's uh let's
  4120. 2:31:31take a look at how to find a listening
  4121. 2:31:33ports so or listening socket so we can
  4122. 2:31:36say netstat
  4123. 2:31:38l and we hit enter and you can see
  4124. 2:31:40there's quite a bit of listening uh of
  4125. 2:31:42stock of sockets that are currently
  4126. 2:31:44listening for
  4127. 2:31:46uh
  4128. 2:31:46for actual connection so in our case you
  4129. 2:31:49can see we have the ssh port here
  4130. 2:31:51and we can pretty much grip
  4131. 2:31:54with these particular services um and
  4132. 2:31:56you can sort of work with that if you
  4133. 2:31:58want to
  4134. 2:31:59uh talking about udp only we can again
  4135. 2:32:02that's very simple so that's that if i
  4136. 2:32:04wanted listening tcp connections i would
  4137. 2:32:07say um for example lt and hit enter and
  4138. 2:32:10that will only display the listening tcp
  4139. 2:32:12connections if i wanted listening udp
  4140. 2:32:14connections i would
  4141. 2:32:16type in lu and again that gives us all
  4142. 2:32:18the listening udp connections
  4143. 2:32:21um if we want to display the the actual
  4144. 2:32:24processor processes and the process ids
  4145. 2:32:27we can say netstat
  4146. 2:32:29p and we hit enter
  4147. 2:32:31and what we can do is we can say ltp
  4148. 2:32:34so ltp and we're looking for grip ssh
  4149. 2:32:38and we hit enter it again tells you uh
  4150. 2:32:40that we have ssh running in or you can
  4151. 2:32:42go through this all over again so let me
  4152. 2:32:44just clear this out
  4153. 2:32:46so if we display the results here um you
  4154. 2:32:48can see that
  4155. 2:32:50it gives you all the information that
  4156. 2:32:52you're looking for uh so if we get rid
  4157. 2:32:55of this and we also have p it gives you
  4158. 2:32:57the various process ids
  4159. 2:32:59uh so if we let's just take a look at
  4160. 2:33:01the table right at the top here that
  4161. 2:33:03pretty much prints it all
  4162. 2:33:05uh you can see we have the pid right
  4163. 2:33:07over here and we can sort of grip
  4164. 2:33:09through that if we wanted to
  4165. 2:33:12so that's uh using um netdiscover
  4166. 2:33:15netstat uh we're not talking about net
  4167. 2:33:17discover yet but again you can check out
  4168. 2:33:19our independent video on that and allows
  4169. 2:33:22you to check various connections that
  4170. 2:33:23you have open and you know running
  4171. 2:33:25either established or listening on your
  4172. 2:33:27system they could be for both a tcp and
  4173. 2:33:29udp
  4174. 2:33:30now let's talk about net discover now
  4175. 2:33:33net discover does not come pre-installed
  4176. 2:33:35with any linux distribution as far as
  4177. 2:33:37i'm concerned apart from the pen testing
  4178. 2:33:39uh or offensive distribution so again we
  4179. 2:33:42can simply just say what is netstat
  4180. 2:33:45and you can pretty much um well no not
  4181. 2:33:47nets that net discover
  4182. 2:33:51um i believe this is uh its cover like
  4183. 2:33:54so and we hit enter and it's an active
  4184. 2:33:56passive uh erp reconnaissance tool
  4185. 2:34:00and so what this means is it allows you
  4186. 2:34:02to essentially scan your network for uh
  4187. 2:34:04for other devices or hosts that are
  4188. 2:34:06currently connected to your network
  4189. 2:34:08whether they be uh wi-fi enabled devices
  4190. 2:34:10or connected to your uh to your network
  4191. 2:34:13via ethernet or to your switch um so
  4192. 2:34:15again to install it you can use any of
  4193. 2:34:17the package managers you're comfortable
  4194. 2:34:19with and we simply type in net discover
  4195. 2:34:22and we hit enter so do have to get
  4196. 2:34:24installed sorry
  4197. 2:34:26and we hit enter and you can see already
  4198. 2:34:28have it installed so using it requires
  4199. 2:34:30root privileges so we say sudo
  4200. 2:34:34net discover
  4201. 2:34:36and then we specify the interface that
  4202. 2:34:38we want to use so we can see enp2s0
  4203. 2:34:42and hit enter and as you can see it will
  4204. 2:34:44start scanning and it's doing this
  4205. 2:34:45through arp or the address resolution
  4206. 2:34:47protocol so arp
  4207. 2:34:50request and response packets so again
  4208. 2:34:52it's sending various arp requests
  4209. 2:34:54to you know all ips on the network and
  4210. 2:34:56then the responses give us the results
  4211. 2:34:58that uh that actually prove that whether
  4212. 2:35:01we have a device or not so you can see
  4213. 2:35:04i currently have the my router which is
  4214. 2:35:06running uh this is the default gateway
  4215. 2:35:09and then i also have another device
  4216. 2:35:11running here
  4217. 2:35:12let's see if we have any other devices
  4218. 2:35:15and we'll just wait for it to continue
  4219. 2:35:16scanning
  4220. 2:35:18so i'll just wait for this to continue
  4221. 2:35:20scanning i think i have multiple other
  4222. 2:35:22devices this is pretty much going to be
  4223. 2:35:24my windows device if i bring up
  4224. 2:35:27a mobile device here let's see if that
  4225. 2:35:29actually
  4226. 2:35:30comes up
  4227. 2:35:32and i'll try and load up a website here
  4228. 2:35:34i actually don't have my phone on me but
  4229. 2:35:36in any case this essentially gives you
  4230. 2:35:39all
  4231. 2:35:40it essentially gives you all devices on
  4232. 2:35:42your network and that's a great way of
  4233. 2:35:44monitoring your network and viewing what
  4234. 2:35:46devices you have so again it gives you
  4235. 2:35:48the ip their mac address and their mac
  4236. 2:35:50vendor so again it gives you an
  4237. 2:35:52information about what device you're
  4238. 2:35:53dealing with so in this case tp-link and
  4239. 2:35:56then hot high precision which is pretty
  4240. 2:35:58much a network adapter and once you're
  4241. 2:36:00done you just hit ctrl c and that will
  4242. 2:36:02terminate the process right over there
  4243. 2:36:05all right now to end up at or to end
  4244. 2:36:07this video
  4245. 2:36:08let's talk about a dns which a lot of
  4246. 2:36:10people actually ask me about so your dns
  4247. 2:36:12information
  4248. 2:36:14or your name servers rather are going to
  4249. 2:36:16be stored in your resolve.com file so
  4250. 2:36:18again sudo
  4251. 2:36:20uh sudo and we'll use vim etsy and we're
  4252. 2:36:24looking for the resolve uh
  4253. 2:36:26resolve dot com file and we hit enter
  4254. 2:36:29you can see that this uh this file is
  4255. 2:36:30managed uh by the system they resolved
  4256. 2:36:33uh and we can i'll actually show you how
  4257. 2:36:35to use that utility shortly um
  4258. 2:36:38so this is a dynamic result or
  4259. 2:36:40configuration file for connecting local
  4260. 2:36:42clients to the internal dns stub
  4261. 2:36:44resolver of systemd so again it tells
  4262. 2:36:46you that this is going through systemd
  4263. 2:36:48and this is more of a dynamic uh of a
  4264. 2:36:51dynamic file that is generated
  4265. 2:36:53dynamically
  4266. 2:36:54and again it is just for connecting
  4267. 2:36:56local clients to the internal dns dns
  4268. 2:36:59resolver with systemd resolved um and
  4269. 2:37:02i'll be talking about services as i said
  4270. 2:37:04later on but many people edit this which
  4271. 2:37:06will work temporarily uh however if you
  4272. 2:37:09do want to take a look at systemd
  4273. 2:37:10resolve that's extremely simple so
  4274. 2:37:13what you could do if you want to use
  4275. 2:37:14this manually is uh we would actually
  4276. 2:37:16just add another one here so i can say
  4277. 2:37:19name server and then i'll say for
  4278. 2:37:21example go the google name server eight
  4279. 2:37:23eight eight eight
  4280. 2:37:24and uh i can use that if i want to but
  4281. 2:37:26in our case we're not gonna we're not
  4282. 2:37:28gonna have any changes here so we'll
  4283. 2:37:30just exit so
  4284. 2:37:32you can actually check the status of
  4285. 2:37:34system d resolve so we can say uh system
  4286. 2:37:38b
  4287. 2:37:39uh resolve sorry resolve and we say
  4288. 2:37:42status
  4289. 2:37:43and we hit enter and again that gives
  4290. 2:37:45you uh the various dns information that
  4291. 2:37:48you're looking for so we can print out
  4292. 2:37:50so you can see the dns servers that we
  4293. 2:37:52currently have set
  4294. 2:37:54are going to be the google dns server
  4295. 2:37:56and this is going through your uh your
  4296. 2:37:58actual your router or your main gateway
  4297. 2:38:01so it would be advisable to switch uh
  4298. 2:38:04you know to any dns server that you want
  4299. 2:38:06to do or that you want to use on your
  4300. 2:38:08main router
  4301. 2:38:09so you can see that it uses the default
  4302. 2:38:12one that is your default gateway ip here
  4303. 2:38:15and the google
  4304. 2:38:17the google dns server that i have set
  4305. 2:38:19here and that was simply for the
  4306. 2:38:20demonstration purposes in this video so
  4307. 2:38:23that's how to system they resolve
  4308. 2:38:25um now when talking about your hosts
  4309. 2:38:27file this essentially allows you to
  4310. 2:38:29manage your various hosts and you can
  4311. 2:38:31use this uh you know for ad blocking
  4312. 2:38:33uh or yeah you can use it for ad
  4313. 2:38:35blocking if you want to so for example
  4314. 2:38:37uh we can say sudo
  4315. 2:38:40vim and we say etsy and we say host and
  4316. 2:38:43we hit enter and you can see uh for
  4317. 2:38:45example where we have uh defined uh the
  4318. 2:38:48local host or the loopback
  4319. 2:38:50uh you know
  4320. 2:38:52127.0.0.1 is our localhost and then the
  4321. 2:38:55current host here which is alexis
  4322. 2:38:57workstation is
  4323. 2:38:59127.0.1.1 so i could also change that to
  4324. 2:39:01any other ipa i want
  4325. 2:39:03so if you're going to block an ad what
  4326. 2:39:05you typically do is you put an invalid
  4327. 2:39:07ip address here so i could say zero zero
  4328. 2:39:09zero zero
  4329. 2:39:10uh and i could sort of block a website
  4330. 2:39:13here like for example
  4331. 2:39:15i could say google.com
  4332. 2:39:18which is not a smart thing to do but in
  4333. 2:39:20any case uh we can write those changes
  4334. 2:39:22and exit and then if i say sudo system
  4335. 2:39:25control
  4336. 2:39:26we say restart network
  4337. 2:39:29manager i believe
  4338. 2:39:31network manager dot service
  4339. 2:39:33um so we will just let me just try and
  4340. 2:39:35complete this for some reason it isn't
  4341. 2:39:38displaying this system
  4342. 2:39:41system control
  4343. 2:39:46network manager.service
  4344. 2:39:49and we want to use this so we want to
  4345. 2:39:51restart the network manager and i'll
  4346. 2:39:53actually show you this to you right now
  4347. 2:39:55um so if we try and open up a firefox
  4348. 2:39:58instance here and we say google.com and
  4349. 2:40:01we hit enter you can see
  4350. 2:40:03uh it pretty much redirects us to the
  4351. 2:40:05local host and
  4352. 2:40:07that's essentially how to use the hosts
  4353. 2:40:09file now i can change the ip to
  4354. 2:40:10something i do something else completely
  4355. 2:40:12but again many of you have been asking
  4356. 2:40:14me how to use the hosts file so that's
  4357. 2:40:16pretty much how to use it
  4358. 2:40:19and we can get rid of that right now
  4359. 2:40:21because i don't want that to be the case
  4360. 2:40:23and we can just restart the network
  4361. 2:40:24manager one more time
  4362. 2:40:26and there we are so we should be good
  4363. 2:40:28there all right so that's pretty much
  4364. 2:40:30all i wanted to cover in regards to
  4365. 2:40:31networking and all that is important as
  4366. 2:40:34i said we'll be taking a look at
  4367. 2:40:35services i will also be taking a look at
  4368. 2:40:37ssh and if you are interested in in
  4369. 2:40:40exploring tools like netstat and net
  4370. 2:40:43discover you can check my independent
  4371. 2:40:45videos
  4372. 2:40:50in this video we're going to be talking
  4373. 2:40:51about how to use store and proxy gains
  4374. 2:40:53in conjunction to anonymize your traffic
  4375. 2:40:56uh you know through the use of any tool
  4376. 2:40:57that you want so both of these tools
  4377. 2:40:59don't come pre-installed on you know
  4378. 2:41:01standard distributions but you can
  4379. 2:41:03pretty much find them on pen testing and
  4380. 2:41:05offensive distributions so again what we
  4381. 2:41:08need to do is install the tor service
  4382. 2:41:10first not the tor browser but the actual
  4383. 2:41:13tor service and then secondly we need to
  4384. 2:41:15install the proxy chains tool so again
  4385. 2:41:17to install the tour service all we need
  4386. 2:41:19to do is say sudo
  4387. 2:41:21sudo apt you can use whatever package
  4388. 2:41:22manager using sudo apt-get install and
  4389. 2:41:25it's pretty much going to be just store
  4390. 2:41:27that will be the name of the service and
  4391. 2:41:28i already have it installed so
  4392. 2:41:31again if you just want to check what it
  4393. 2:41:33is so you can say what is store and this
  4394. 2:41:34is referring to the actual
  4395. 2:41:37um due to the actual service so you can
  4396. 2:41:39see that what is a second generation
  4397. 2:41:41onion router
  4398. 2:41:43so if we say man
  4399. 2:41:44tor and we hit enter you can see that
  4400. 2:41:46door
  4401. 2:41:47uh is a connection oriented anonymizing
  4402. 2:41:49communication service users i choose a
  4403. 2:41:51source routed path through a set of
  4404. 2:41:53nodes
  4405. 2:41:54uh and negotiate a virtual circuit
  4406. 2:41:56through the to the network i think i've
  4407. 2:41:58pretty much explained this before in
  4408. 2:41:59previous video as to how the tor how tor
  4409. 2:42:02works um so we'll be using tor now uh to
  4410. 2:42:04start the tour service we can use
  4411. 2:42:07systemd or you can also use a service
  4412. 2:42:10um so we can say sudo system control and
  4413. 2:42:13we say uh we can say start and then we
  4414. 2:42:16are looking for tor uh
  4415. 2:42:19i think where it is the tor service here
  4416. 2:42:22uh i'm not too sure what it is what it's
  4417. 2:42:25called so if we say tor
  4418. 2:42:27let's check the status here
  4419. 2:42:29status store
  4420. 2:42:31and you can see that we currently have
  4421. 2:42:32it loaded and active so again the tor
  4422. 2:42:36service is an anonymizing overlay
  4423. 2:42:38network for tcp so if we use netstat
  4424. 2:42:41here so we can say netstat
  4425. 2:42:43and we can look for listening tcp
  4426. 2:42:46connections and we grip for the port
  4427. 2:42:48that the door service connects through
  4428. 2:42:49which is 1950 and we hit enter you can
  4429. 2:42:52see we now have uh you know we are
  4430. 2:42:53listening on port 9050 and this is
  4431. 2:42:56localhost so that's perfect we can use
  4432. 2:42:58this with proxychains all right so now
  4433. 2:43:00let's talk about proxychain so again uh
  4434. 2:43:02installing proxychains is very simple so
  4435. 2:43:04you do upgrade install proxychains uh
  4436. 2:43:07sorry um
  4437. 2:43:09proxy chains and we enter and i already
  4438. 2:43:11have it installed uh before we actually
  4439. 2:43:13use it we now need to uh we need to play
  4440. 2:43:16around with the configuration file so
  4441. 2:43:18that we can tweak the the configuration
  4442. 2:43:20to what we want it to be and how we want
  4443. 2:43:22it to work so we can say sudo vim hc
  4444. 2:43:26proxychains.conf and we hit enter
  4445. 2:43:29so again
  4446. 2:43:30pretty much i'll go through the settings
  4447. 2:43:32that i use so again
  4448. 2:43:34we can use http x4 sox5
  4449. 2:43:37uh and again we this allows you to
  4450. 2:43:39tunnel um or proxy you can you can
  4451. 2:43:42essentially tunnel your connections
  4452. 2:43:43through a series of proxies and in our
  4453. 2:43:46case the proxies are going to be is
  4454. 2:43:47going to be tor so with dns that's the
  4455. 2:43:50great thing so
  4456. 2:43:51uh the options below identify how the
  4457. 2:43:54proxy list is treated only one option
  4458. 2:43:56should be common uncommented at a time
  4459. 2:43:58so
  4460. 2:43:59dynamic chains where each connection
  4461. 2:44:02will be done via chained proxies all
  4462. 2:44:03proxy chained in order as they appear in
  4463. 2:44:05the list at least one proxy must be
  4464. 2:44:07online to play in the chain i i pretty
  4465. 2:44:09much like using the random chain
  4466. 2:44:12so you can see that each connection will
  4467. 2:44:14be done via random proxy or proxy chain
  4468. 2:44:17from the list this option is good to
  4469. 2:44:18test your intrusion detection system
  4470. 2:44:20because it's constantly changing uh you
  4471. 2:44:23know through random proxies but if again
  4472. 2:44:25if you want a dynamic chain that's
  4473. 2:44:26perfect
  4474. 2:44:27uh you can also use the strict chain
  4475. 2:44:29this will ensure that uh all connection
  4476. 2:44:32are going to be done through a chain
  4477. 2:44:33proxy or all proxies will be chained in
  4478. 2:44:35the order as they appear in the list so
  4479. 2:44:38i like using a random chain so you want
  4480. 2:44:40to uncomment this or it will be
  4481. 2:44:42commented here so
  4482. 2:44:44if i just hit insert here and it'll
  4483. 2:44:46pretty much be commented like so and you
  4484. 2:44:48want to uncomment this
  4485. 2:44:50we then want to take a look at the proxy
  4486. 2:44:52dns request so again this will prevent
  4487. 2:44:55no leak for dns data this is very
  4488. 2:44:57important you want to make sure that's
  4489. 2:44:59uncommented and then we want to take a
  4490. 2:45:02look at the proxy list format so this
  4491. 2:45:03gives you an idea of how to use your
  4492. 2:45:05proxy list if you are interested in
  4493. 2:45:07using other proxies apart from tor
  4494. 2:45:10you can see that we have socks 5 http
  4495. 2:45:12sox4 you know in our case the defaults
  4496. 2:45:15will be set to door and we want to add
  4497. 2:45:17socks 5 as well here so we say socks 5
  4498. 2:45:20and we can we remember it's running on
  4499. 2:45:22our local host uh sorry 127.0.0.1
  4500. 2:45:26uh 1950 and that's of course going to be
  4501. 2:45:28um that's going to be socks 5 all right
  4502. 2:45:31so we can add any of the other proxies
  4503. 2:45:33we want here so again if you're not keen
  4504. 2:45:35on using tor you can change this and
  4505. 2:45:37we'll write changes and quit from here
  4506. 2:45:40so now when using proxy chains you want
  4507. 2:45:42to ensure that you have the toss service
  4508. 2:45:43started and it's currently running and
  4509. 2:45:45then i use the syntax is very simple so
  4510. 2:45:47we say proxy chains
  4511. 2:45:50and then we specify the tool that we
  4512. 2:45:52want to use um so for example
  4513. 2:45:55i can say proxy chains are firefox uh or
  4514. 2:45:58i can use another tool like ssh or
  4515. 2:46:01telnet
  4516. 2:46:02or i could use a tool uh maybe let's try
  4517. 2:46:05firefox because it's the easiest way to
  4518. 2:46:07test this so i say firefox
  4519. 2:46:09and then i open this website dns
  4520. 2:46:11leaktest.com
  4521. 2:46:13and we hit enter and that's going to
  4522. 2:46:15start proxy chains for us now given that
  4523. 2:46:17it's using door the connection is going
  4524. 2:46:19to be much slower than you know a
  4525. 2:46:21standard proxy uh of course depending on
  4526. 2:46:23what proxy you end up using so we'll
  4527. 2:46:25just wait for this to load up and the
  4528. 2:46:26dns lictest.com
  4529. 2:46:28will tell us what our ip is and secondly
  4530. 2:46:31it will tell us
  4531. 2:46:33what our dns is so you can see
  4532. 2:46:36it gives us information regarding our ip
  4533. 2:46:38um for some reason isn't telling us what
  4534. 2:46:40country it is so again we can just hit a
  4535. 2:46:42standard test this will test our dns to
  4536. 2:46:44see if we
  4537. 2:46:45are leaking any dns information and of
  4538. 2:46:48course dns information is very important
  4539. 2:46:49as it can leak your geographical
  4540. 2:46:51information so again you can just go
  4541. 2:46:54through the test and this will display
  4542. 2:46:56whether or not what dns servers you're
  4543. 2:46:58currently been using so let's wait for
  4544. 2:47:01this and see what results we get there's
  4545. 2:47:03a progress bar right over here so you
  4546. 2:47:05can see that all are going through um
  4547. 2:47:08dns servers in germany and of course you
  4548. 2:47:11have their host names and their various
  4549. 2:47:13ips so again that's a great because it
  4550. 2:47:15was a we were we didn't leak any of our
  4551. 2:47:18personal dns information that or the dns
  4552. 2:47:20servers we went through but of course
  4553. 2:47:22that is also dependent on on you know
  4554. 2:47:25dns security something that's out of the
  4555. 2:47:26scope of this video
  4556. 2:47:32in this video we're going to be talking
  4557. 2:47:33about uh process and service management
  4558. 2:47:36uh so we're going to be talking about
  4559. 2:47:37lots of tools that you can use to uh to
  4560. 2:47:39manage processes
  4561. 2:47:41and also manage services right so these
  4562. 2:47:44this is a very important video pretty
  4563. 2:47:45much i think one of the most important
  4564. 2:47:47videos in this series because of of the
  4565. 2:47:50power that that comes with it so uh
  4566. 2:47:52first of all let's let's take a look at
  4567. 2:47:55some of the utilities that you can use
  4568. 2:47:57uh to to manage system resources and to
  4569. 2:48:00view the current processes and you know
  4570. 2:48:02just view resource consumption in
  4571. 2:48:04regards to the processes that are
  4572. 2:48:06consuming the most and consuming the
  4573. 2:48:07least
  4574. 2:48:08now by default all linux systems come
  4575. 2:48:10with a utility called top right and you
  4576. 2:48:13can pretty much get some information
  4577. 2:48:15about it by using uh the what is command
  4578. 2:48:17so again it tells us that top displays
  4579. 2:48:19linux processes so you can hit top and
  4580. 2:48:21again as you can see this gives you
  4581. 2:48:23information regarding uh your your
  4582. 2:48:25system resources the consumption and the
  4583. 2:48:28various processes that are running the
  4584. 2:48:30the owner of the processes in terms of
  4585. 2:48:32the user so you have your process id
  4586. 2:48:34very important there that can be used to
  4587. 2:48:36manage the process either to kill it
  4588. 2:48:38uh or to stop it you then have the user
  4589. 2:48:41here that it belongs to
  4590. 2:48:43you then have the cpu and memory
  4591. 2:48:45consumption
  4592. 2:48:46uh the time
  4593. 2:48:47and the command itself so again you can
  4594. 2:48:50essentially use this to manage all your
  4595. 2:48:52processes however the a better utility
  4596. 2:48:55custom utility that you can install by
  4597. 2:48:57with with whatever the package manager
  4598. 2:48:59using
  4599. 2:49:00and that is the h-top utility so again
  4600. 2:49:02we can install it we can install it here
  4601. 2:49:04i already have it installed so again we
  4602. 2:49:07can clear this and say what is h-top you
  4603. 2:49:09can see that this is an interactive
  4604. 2:49:11process viewer so if we open up htop uh
  4605. 2:49:14you can see that first of all it gives
  4606. 2:49:15you your processor usage
  4607. 2:49:17in regards to how many cores you have so
  4608. 2:49:19i have six scores here and it gives you
  4609. 2:49:21the utilization in terms of percentage
  4610. 2:49:24you then have your memory usage so it
  4611. 2:49:25gives you a total usage i have about 16
  4612. 2:49:28gigs here and i'm currently using six
  4613. 2:49:30gig
  4614. 2:49:30uh it also tells you your swap usage uh
  4615. 2:49:33so i have a swap uh set to about two
  4616. 2:49:36gigs uh don't get angry at me and a lot
  4617. 2:49:37of people are against swap nowadays
  4618. 2:49:40it gives you the amount of tasks
  4619. 2:49:43the amount running the load average and
  4620. 2:49:45the uptime of your system so very useful
  4621. 2:49:47information it also sorts it out it
  4622. 2:49:50sorts the information out uh you know
  4623. 2:49:52similar to what we add so we have the
  4624. 2:49:53process id and you can sort that out uh
  4625. 2:49:56chronologically so you can say you can
  4626. 2:49:58just click on it and it loads it up from
  4627. 2:49:59the first process with the process id of
  4628. 2:50:02one you then have the user so you can
  4629. 2:50:04again switch from all the user uh the
  4630. 2:50:06user accounts that uh that these
  4631. 2:50:08processes are running under
  4632. 2:50:11you then have your cpu usage so if i
  4633. 2:50:12click on cpu that displays uh the the
  4634. 2:50:15process that is currently using the most
  4635. 2:50:18uh cpu usage uh again i can click on
  4636. 2:50:20memory and it tells us that google
  4637. 2:50:22chrome is using the most memory that's
  4638. 2:50:24that's not a surprise
  4639. 2:50:26and of course we can just go back to cpu
  4640. 2:50:28usage and you can see that obs is
  4641. 2:50:30currently running right now which makes
  4642. 2:50:31sense as that is using the most cpu
  4643. 2:50:34right so uh this is a utility that you
  4644. 2:50:37can use to pretty much manage your
  4645. 2:50:39processes now before we take a look at
  4646. 2:50:40how to use it because this simplifies
  4647. 2:50:42the process
  4648. 2:50:43let's take a look at uh you know how you
  4649. 2:50:46would actually view these uh the
  4650. 2:50:48resource consumption like ram usage for
  4651. 2:50:50example to v ram ram usage we would
  4652. 2:50:53simply type in free
  4653. 2:50:54and that again tells you uh if we that
  4654. 2:50:57you know we just use the man pages here
  4655. 2:50:59you can see that free uh displays
  4656. 2:51:02the amount of free and used memory in
  4657. 2:51:04the system so again you can display this
  4658. 2:51:06uh in regards to uh to to to the output
  4659. 2:51:09you want so if we say three h that
  4660. 2:51:11prints it out in human uh readable
  4661. 2:51:14format so you can see we have total used
  4662. 2:51:16free shared
  4663. 2:51:17the cash and available and of course
  4664. 2:51:19also for your swap so that's uh one of
  4665. 2:51:21the quick ways you can view how much ram
  4666. 2:51:23you're using
  4667. 2:51:24now let's talk about processes right so
  4668. 2:51:26processes uh need to be understood as
  4669. 2:51:29you need to separate them between you
  4670. 2:51:31need to separate processes and services
  4671. 2:51:33right so processes
  4672. 2:51:35uh are viewed with the ps tool so again
  4673. 2:51:38uh ps uh gives you a report uh it gives
  4674. 2:51:40you a report of this uh or it
  4675. 2:51:42essentially gives you a snapshot of your
  4676. 2:51:43current processes that you have running
  4677. 2:51:46all right so if i just say ps
  4678. 2:51:48this is weird because many users
  4679. 2:51:50actually i've pointed this out so why
  4680. 2:51:53does it only give you two processes well
  4681. 2:51:55you haven't specified any arguments in
  4682. 2:51:57regards to what processes you want to
  4683. 2:51:58see so what it's going to give you is
  4684. 2:52:00it's simply going to display processes
  4685. 2:52:02that are in your current shell and you
  4686. 2:52:04can see that the tool that it has is the
  4687. 2:52:06bash
  4688. 2:52:07and the the actual command that you run
  4689. 2:52:09so that makes sense now if we want to
  4690. 2:52:11display all processes we would simply
  4691. 2:52:13say psa ux
  4692. 2:52:15and you can view all of this syntax
  4693. 2:52:18from the man page which is actually
  4694. 2:52:20recommended here i'm using the psd style
  4695. 2:52:22or the bsd syntax so again
  4696. 2:52:25to see every process on the system using
  4697. 2:52:28standard syntax you can use that i'm
  4698. 2:52:29using as you can see right over here bst
  4699. 2:52:32syntax so i'll continue with that so i
  4700. 2:52:34can say ps aux
  4701. 2:52:36and i can hit enter alright so this is a
  4702. 2:52:38lot of information here this is
  4703. 2:52:40essentially giving you a snapshot of all
  4704. 2:52:42the processes that you have running on
  4705. 2:52:44your system so we can scroll all the way
  4706. 2:52:46to the top and again the it's sorted out
  4707. 2:52:48into a table with various columns so
  4708. 2:52:50again you have the user the process id
  4709. 2:52:52and it starts chronologically
  4710. 2:52:54but the great thing about tools like
  4711. 2:52:55h-stop is it gives you a dynamic view of
  4712. 2:52:58of the processors how much they're
  4713. 2:53:00consuming on a second by second basis uh
  4714. 2:53:03cpu usage memory etc but this is a
  4715. 2:53:05snapshot remember so again this can give
  4716. 2:53:07you an idea of all the processes that
  4717. 2:53:09are currently active however if you want
  4718. 2:53:11a dynamic idea of the current system
  4719. 2:53:14resource consumption use a utility like
  4720. 2:53:16top or h-top this just gives you a
  4721. 2:53:18snapshot all right the key thing we're
  4722. 2:53:20looking for here is the pid because we
  4723. 2:53:23won't talk about managing processes
  4724. 2:53:25right so
  4725. 2:53:26let's say um i want to start a service
  4726. 2:53:29here
  4727. 2:53:30so i say sudo system
  4728. 2:53:32control
  4729. 2:53:35system control i'm going to say start
  4730. 2:53:38and i'll say tor i want to start the tor
  4731. 2:53:40service here and then i say ps aux i can
  4732. 2:53:42also grab the output here and i can say
  4733. 2:53:44i'm looking for tor uh so give me all
  4734. 2:53:47processes with door right now of course
  4735. 2:53:49it's going to give us you know various
  4736. 2:53:51other false positives with the the
  4737. 2:53:53string of characters t o r and you can
  4738. 2:53:56see the inclusion of that within storage
  4739. 2:53:58but if we just go to the bottom here uh
  4740. 2:54:00you can see we have um
  4741. 2:54:03we have the user bin tour uh binary
  4742. 2:54:06being used here so that looks
  4743. 2:54:07interesting
  4744. 2:54:08and yeah so if we take a look at the
  4745. 2:54:10process id we can see it has a process
  4746. 2:54:12id of 7604 so if we say uh sudo
  4747. 2:54:16system
  4748. 2:54:17control we say status status store and
  4749. 2:54:21we enter um sorry about this guy system
  4750. 2:54:25control and we hit we take a look at the
  4751. 2:54:27status of the
  4752. 2:54:28of the service you can see that it's
  4753. 2:54:30active it's loaded and active so if we
  4754. 2:54:32want to kill this process all we need to
  4755. 2:54:34do is get the process id in this case
  4756. 2:54:36it's going to be 7604
  4757. 2:54:39and all we need to do is say
  4758. 2:54:41we just say kill
  4759. 2:54:43and you may want to prepend this with
  4760. 2:54:45root privileges or the pseudo command so
  4761. 2:54:47we say sudo kill
  4762. 2:54:48uh seven six zero four seven six zero
  4763. 2:54:51four and we enter and now if we take a
  4764. 2:54:53look at the the the tour service you can
  4765. 2:54:55see it's still running now the reason i
  4766. 2:54:57did this is because you need to
  4767. 2:54:59differentiate between a service and a
  4768. 2:55:02process because the service will re
  4769. 2:55:04reinitiate or re-initialize itself right
  4770. 2:55:07so let's take a look at
  4771. 2:55:09the let's take a look at all the
  4772. 2:55:11processes here and we can take a look at
  4773. 2:55:12more realistic options available to us
  4774. 2:55:15right so i'll give you an example here
  4775. 2:55:17um so let's grip for ssh and we'll say
  4776. 2:55:22grep ssh
  4777. 2:55:24let's see we have the ssh daemon here
  4778. 2:55:27[Music]
  4779. 2:55:29which is running as a process id
  4780. 2:55:32of
  4781. 2:55:345687 right and
  4782. 2:55:36we also have the uh yeah that's pretty
  4783. 2:55:39much the one we're looking for we also
  4784. 2:55:40have the ssh agent here
  4785. 2:55:42so what we can do is we can say um
  4786. 2:55:45pseudo here
  4787. 2:55:46one nine six nine
  4788. 2:55:48and we can also say pseudo kill 56 87
  4789. 2:55:51right so we can say 56 87 you kill that
  4790. 2:55:55and then we say system
  4791. 2:55:57system
  4792. 2:55:58control and say
  4793. 2:56:00status ssh and we hit enter you can see
  4794. 2:56:03that ssh
  4795. 2:56:05is currently loaded but inactive dead
  4796. 2:56:08right so that's just a simple way of
  4797. 2:56:10managing processes now we can do the
  4798. 2:56:11same thing
  4799. 2:56:12uh with h-stop and i'll show you how to
  4800. 2:56:14do this many people actually skip this
  4801. 2:56:16but each stop is has a much easier way
  4802. 2:56:18of doing this so when you launch h-stop
  4803. 2:56:21uh you can pretty much filter through
  4804. 2:56:22the results but a great way of searching
  4805. 2:56:24for services by their name instead of
  4806. 2:56:25using grep is by using the f3 key
  4807. 2:56:28after which it will bring up this little
  4808. 2:56:30search bar and i can search for things
  4809. 2:56:31like door
  4810. 2:56:32uh and if i use a space
  4811. 2:56:34it pretty much should give me all the
  4812. 2:56:36results so let me just do that one more
  4813. 2:56:38time so i say tor
  4814. 2:56:40and
  4815. 2:56:41we can see that the process was closed
  4816. 2:56:44but the the service is still running so
  4817. 2:56:46let's try another another process here
  4818. 2:56:49let's see if we have um
  4819. 2:56:52let's see let's actually work with
  4820. 2:56:53h-stop i just want to show you this so
  4821. 2:56:54if we click on h-stop and it's
  4822. 2:56:56highlighted yellow we can actually kill
  4823. 2:56:58it by using f9 so if we hit f9 we can
  4824. 2:57:01send various signals to this process so
  4825. 2:57:04we can say signal quit signal kill so if
  4826. 2:57:06we say signal kill that's option nine
  4827. 2:57:09and we hit enter
  4828. 2:57:10you can see that that will pretty much
  4829. 2:57:12kill the process and you can see that it
  4830. 2:57:15actually points that up right over here
  4831. 2:57:17and
  4832. 2:57:17you can see that the output is messed up
  4833. 2:57:19and i shouldn't have probably done that
  4834. 2:57:21but i wanted to demonstrate the power of
  4835. 2:57:22h stop here so if i go into h stop one
  4836. 2:57:25more time and now again it's giving us
  4837. 2:57:27our dynamic results so we can pretty
  4838. 2:57:29much use that same
  4839. 2:57:30syntax to manage our services really
  4840. 2:57:32easy and many people go over this it's
  4841. 2:57:34not just a system resource uh
  4842. 2:57:37usage
  4843. 2:57:38utility to actually display how much uh
  4844. 2:57:40you know resources you're consuming it
  4845. 2:57:42can actually allow you to interact with
  4846. 2:57:44your services or your processors quite
  4847. 2:57:46well so
  4848. 2:57:48again i can search for any process right
  4849. 2:57:50over here with name or i can
  4850. 2:57:52again i can work with the the resource
  4851. 2:57:55consumption so again i can highlight
  4852. 2:57:56resource consumption here uh memory
  4853. 2:57:58consumption et cetera et cetera right
  4854. 2:58:00now let's talk about service management
  4855. 2:58:02with system d right because i also want
  4856. 2:58:05to cover uh system v as well system v
  4857. 2:58:07service management but
  4858. 2:58:09now the norm is increasingly becoming
  4859. 2:58:12system d so it's great to to actually
  4860. 2:58:14know how to use this so
  4861. 2:58:16if we say man system
  4862. 2:58:18control this is the utility that allows
  4863. 2:58:20us to control um
  4864. 2:58:22so you can see control the systemd
  4865. 2:58:24system and service manager so i'll show
  4866. 2:58:26you how to use it so if we want to list
  4867. 2:58:28all the active services which are going
  4868. 2:58:30to be a lot we can say system
  4869. 2:58:32uh control and we hit enter and you can
  4870. 2:58:35see that we can you know we can move
  4871. 2:58:36down with the uh your your directional
  4872. 2:58:39keys
  4873. 2:58:40and this gives you an idea of all the
  4874. 2:58:41services that you have running and once
  4875. 2:58:43you have once you're done we have about
  4876. 2:58:45uh 230 lines here and they keep on going
  4877. 2:58:47as as the more you you actually go down
  4878. 2:58:50so uh 269 loaded units um it gives you
  4879. 2:58:54all information regards to all the
  4880. 2:58:55services you have running so if we quit
  4881. 2:58:58we can also prep so if we grep here we
  4882. 2:59:01say grab
  4883. 2:59:02ssh and we hit enter so we have no ssh
  4884. 2:59:05service running so if we if we want to
  4885. 2:59:08start a service like the ssh service
  4886. 2:59:09what i can do is i can say
  4887. 2:59:11system control
  4888. 2:59:13system control i say start and then i
  4889. 2:59:17i can you know then play around with
  4890. 2:59:19with what i want to do so i can say
  4891. 2:59:21um i can say
  4892. 2:59:24start and then the name of the service
  4893. 2:59:25so i can say ssh and then i can use the
  4894. 2:59:27tab auto completion here so again you
  4895. 2:59:29can see that we have the ssh socket and
  4896. 2:59:31the ssh service so if i wanted to start
  4897. 2:59:34the ssh service uh just give it a few
  4898. 2:59:36seconds it does take a while to load
  4899. 2:59:37this if i use tab auto completion too
  4900. 2:59:39much so if i say
  4901. 2:59:41system control uh start ssh service and
  4902. 2:59:43i hit enter it's gonna ask me for my uh
  4903. 2:59:45for my password and it's gonna this
  4904. 2:59:47because it requires root privileges
  4905. 2:59:49so uh that has started the ssh service
  4906. 2:59:51now we can again uh confirm this uh with
  4907. 2:59:54you know we can say uh lt here and uh
  4908. 2:59:57you can see we have ssh running
  4909. 2:59:59right over here so again we can check
  4910. 3:00:01the status of the pros of this actual
  4911. 3:00:03service by running uh sudo system
  4912. 3:00:06control and we can say status
  4913. 3:00:09ssh dot service here and we enter
  4914. 3:00:12and there we are so you can see it tells
  4915. 3:00:14us that the ssh service this is using
  4916. 3:00:16open ssh so it tells us it's loaded and
  4917. 3:00:18active which means it you can actually
  4918. 3:00:20use it and it gives you information
  4919. 3:00:22about it so the log of events so again
  4920. 3:00:25started uh ssh listening on port 22
  4921. 3:00:29listening on localhost port 22 starting
  4922. 3:00:31the openssh openbsd secure shell server
  4923. 3:00:35and it gives you the various timestamps
  4924. 3:00:37right so
  4925. 3:00:38that's how to pretty much interact uh to
  4926. 3:00:41how to start and monitor the status of a
  4927. 3:00:43service if you're having issues with it
  4928. 3:00:45right now if i wanted to disable it or
  4929. 3:00:47to stop it i could say um i could just
  4930. 3:00:51i can say stop
  4931. 3:00:53uh and i can say ssh dot service and i
  4932. 3:00:57hit enter and that will stop the
  4933. 3:00:59sorry let me just enter my password here
  4934. 3:01:01that will stop the service
  4935. 3:01:03if i check the status you can see that
  4936. 3:01:05it's loaded but inactive and dead now a
  4937. 3:01:07lot of people ask me how do i run
  4938. 3:01:10particular services on system startup
  4939. 3:01:12and you can easily do that with systemd
  4940. 3:01:15so i can say sudo system let's say i
  4941. 3:01:18wanted to enable the ssh service every
  4942. 3:01:19time i boot up which is useful
  4943. 3:01:22so i can say system control
  4944. 3:01:25[Music]
  4945. 3:01:26and then i would say enable but first i
  4946. 3:01:28need to check if it's already enabled so
  4947. 3:01:30i can say is enabled
  4948. 3:01:32and then say ssh dot service and that
  4949. 3:01:35will tell me if uh it is currently
  4950. 3:01:37enabled to
  4951. 3:01:38do to be run on system startup you can
  4952. 3:01:40see tells us that it's currently
  4953. 3:01:41disabled which is great
  4954. 3:01:43uh if i check the synergy service i just
  4955. 3:01:46want to give you an example a robust
  4956. 3:01:47example or hit enter you can see that on
  4957. 3:01:50startup yes this service is enabled
  4958. 3:01:52that's because i use the synergy service
  4959. 3:01:54to you know for my mouse sharing my
  4960. 3:01:56mouse and keyboard sharing
  4961. 3:01:58system so again that tells me that okay
  4962. 3:02:00that's enabled so if we want to enable
  4963. 3:02:02ssh what we would say is a pseudosystem
  4964. 3:02:05control and we would say enable and say
  4965. 3:02:07ssh.service
  4966. 3:02:10all right and i hit enter and you can
  4967. 3:02:12see it's created the sim link
  4968. 3:02:14for us uh in the system d uh directory
  4969. 3:02:17here so
  4970. 3:02:19uh if you're using um
  4971. 3:02:22if you're using system v then you nee
  4972. 3:02:24you need to play around with the initial
  4973. 3:02:26uh the init scripts uh
  4974. 3:02:28and you then need to create a sim link
  4975. 3:02:30but this does it automatically for you
  4976. 3:02:31so now if we check the uh is enabled if
  4977. 3:02:34we check if it's enabled you can see
  4978. 3:02:35that now it's enabled if i want to
  4979. 3:02:37disable it from running on startup i
  4980. 3:02:39would simply say disable
  4981. 3:02:42because i don't want ssh running this is
  4982. 3:02:44not a server so
  4983. 3:02:45i can check it now and we can see it's
  4984. 3:02:47disabled all right so
  4985. 3:02:49that's pretty much how to manage uh you
  4986. 3:02:51know services with system d so that's
  4987. 3:02:54how to start stop uh if i want to
  4988. 3:02:55restart a service again i can simply say
  4989. 3:02:58restart so let me do that right now so
  4990. 3:03:00if i say sudo system control i say tor
  4991. 3:03:03sorry start
  4992. 3:03:04tor i can hit enter that will start the
  4993. 3:03:06tour services i want to reload it i can
  4994. 3:03:08say reload
  4995. 3:03:10all right now i can also um
  4996. 3:03:14i can also reload will reload the uh the
  4997. 3:03:17configuration if i say restart that will
  4998. 3:03:19simply restart the service with the
  4999. 3:03:21current configuration so that's a quick
  5000. 3:03:23tidbit for you if you you can use reload
  5001. 3:03:25here then that will essentially restart
  5002. 3:03:28it with the newer configuration so in
  5003. 3:03:30case you're wondering so i'll just stop
  5004. 3:03:31this service
  5005. 3:03:32and i'll just hit enter
  5006. 3:03:34and there we are all right so
  5007. 3:03:36that is how to manage services now if
  5008. 3:03:38you want to uh if we want to reload the
  5009. 3:03:41entire the system d daemon what we can
  5010. 3:03:43say is sudo system control
  5011. 3:03:46uh we're looking for the daemon and we
  5012. 3:03:49can say reload and we just hit enter and
  5013. 3:03:51that will reload the daemon completely
  5014. 3:03:53that's if you're having any issues and
  5015. 3:03:55you wanted to reconfigure particular
  5016. 3:03:56services
  5017. 3:03:58all right
  5018. 3:03:59now
  5019. 3:04:00let's talk about system v service
  5020. 3:04:02management which many of you are
  5021. 3:04:03familiar with a system v is essentially
  5022. 3:04:05where you say service
  5023. 3:04:07the name of the service which could be
  5024. 3:04:08door and then we say start
  5025. 3:04:10we can say stop
  5026. 3:04:12and we can say restart right very very
  5027. 3:04:14simple and we can also check the status
  5028. 3:04:16so again say service store start
  5029. 3:04:18that will ask you know ask me for my
  5030. 3:04:21administrator privileges i can say
  5031. 3:04:23service store
  5032. 3:04:25status hit enter you can see it tells us
  5033. 3:04:27active loaded
  5034. 3:04:29um and then we can say system a service
  5035. 3:04:32store we can say stop and we can hit
  5036. 3:04:34enter and that will stop these the door
  5037. 3:04:36service and we can also
  5038. 3:04:38say restart and again that will simply
  5039. 3:04:40restart the tour service there and we
  5040. 3:04:42can then stop it one more time so that's
  5041. 3:04:44how to use system v very very simple but
  5042. 3:04:46in my opinion system d
  5043. 3:04:48uh is is the much better alternative to
  5044. 3:04:51learn now and it's extremely robust and
  5045. 3:04:53very very powerful tool to actually
  5046. 3:04:56learn how to use or do low utility
  5047. 3:05:02in this video we're going to be talking
  5048. 3:05:03about ssh uh how to configure it
  5049. 3:05:05securely
  5050. 3:05:06uh and then of course we'll talk about
  5051. 3:05:08you know how to uh how to securely
  5052. 3:05:10transfer files with ssh so let's get
  5053. 3:05:12started um first of all with
  5054. 3:05:14establishing what ssh client and server
  5055. 3:05:17we're going to be using so in our case
  5056. 3:05:19we want to be uh we want to be using
  5057. 3:05:21openssh which is pretty much the go to
  5058. 3:05:23uh the the go to ssh client in server
  5059. 3:05:26solution it's completely open source and
  5060. 3:05:28it's uh it's one of these uh you know
  5061. 3:05:30great services so again that was uh
  5062. 3:05:32developed by the bsd team
  5063. 3:05:34so um again uh we must first of all
  5064. 3:05:38understand the uh the connection type or
  5065. 3:05:40the connection model uh with ssh so ssh
  5066. 3:05:43is primarily a client server connection
  5067. 3:05:46model so that means you need the client
  5068. 3:05:48software to
  5069. 3:05:49connect to the to the server software in
  5070. 3:05:51our case we need to install the openssh
  5071. 3:05:54client service or the client package
  5072. 3:05:57on our client and of course the openssh
  5073. 3:05:59server package on r7 i'll show you that
  5074. 3:06:01right now so i'm currently on my client
  5075. 3:06:02here which is going to be ubuntu our
  5076. 3:06:04remote server is going to be one of my
  5077. 3:06:05ubuntu servers uh running on my
  5078. 3:06:07virtualization server so
  5079. 3:06:09what i'll do is i'll say sudo apt
  5080. 3:06:13get install and we say open ssh and we
  5081. 3:06:16we're looking for the openssh if we
  5082. 3:06:18double tap we can see we're looking for
  5083. 3:06:19the openssh client right so i'm gonna
  5084. 3:06:21hit enter and uh i already have this
  5085. 3:06:24installed right now the openssh client
  5086. 3:06:27configuration file is found so if i say
  5087. 3:06:29cat hc ssh sorry ssh and this is found
  5088. 3:06:33under
  5089. 3:06:33it is the ssh config the sshd config
  5090. 3:06:36file is for the open ssh server
  5091. 3:06:39so you can see i also have my uh my my
  5092. 3:06:42public and private keys here as well but
  5093. 3:06:44i'll get into that in a second they we
  5094. 3:06:46don't need to complicate this right now
  5095. 3:06:47so if i take a look at me at my config
  5096. 3:06:50file here this is the client config
  5097. 3:06:53you can see that um
  5098. 3:06:55the options are quite uh straightforward
  5099. 3:06:58in regards to what you can enable and
  5100. 3:06:59disable so you can specify the port
  5101. 3:07:02uh the protocol um
  5102. 3:07:04and uh various other bits of
  5103. 3:07:06you know configurations here but that's
  5104. 3:07:08not the the in within the scope of the
  5105. 3:07:11video but i just wanted to get to that
  5106. 3:07:13so
  5107. 3:07:13uh my remote server is running on um
  5108. 3:07:16it's currently running on an ip of
  5109. 3:07:20192.168.1.113 so
  5110. 3:07:22we already have an admin user on that
  5111. 3:07:23system so we'll just say admin and we'll
  5112. 3:07:25say 192.168.1.113
  5113. 3:07:28all right and i will just enter the
  5114. 3:07:31password here for the admin user and
  5115. 3:07:33there we are so you can see i'm
  5116. 3:07:34currently logged in as the admin user so
  5117. 3:07:38the first thing we want to do is we need
  5118. 3:07:39to install uh the openssh server so you
  5119. 3:07:42say oh apt-get install open ssh
  5120. 3:07:44server and the reason i'm doing this
  5121. 3:07:46even though i have it installed already
  5122. 3:07:48just to show you how one would go about
  5123. 3:07:49doing it right
  5124. 3:07:51um so hit install already installed
  5125. 3:07:53there excellent all right all right all
  5126. 3:07:55right now that we have this uh both the
  5127. 3:07:57pieces of software installed on the
  5128. 3:07:59client and the server
  5129. 3:08:00we can talk about uh configuring uh you
  5130. 3:08:03know ssh right so pretty much when
  5131. 3:08:06dealing with the remote server and
  5132. 3:08:08remote authentication the first thing
  5133. 3:08:10you need to do is you need to disable
  5134. 3:08:12root logins
  5135. 3:08:14uh because the root the root user
  5136. 3:08:16account is extremely powerful because it
  5137. 3:08:18really has no restrictions in regards to
  5138. 3:08:19what it can do so that's our first order
  5139. 3:08:21of business here and this can be done by
  5140. 3:08:24modifying
  5141. 3:08:25this can be done by modifying the
  5142. 3:08:26openssh
  5143. 3:08:28the openssh
  5144. 3:08:30configuration file the opensh server
  5145. 3:08:32configuration file so if i say sudo vim
  5146. 3:08:35hc ssh and we're looking for sshd
  5147. 3:08:39uh sshd and we say
  5148. 3:08:42sshdconfig and we hit enter so you can
  5149. 3:08:44see this is the openbsd openssh
  5150. 3:08:46sshdconfig file
  5151. 3:08:48and it does you it tells you here this
  5152. 3:08:50is a sshd server systemwide
  5153. 3:08:53configuration file so the first thing we
  5154. 3:08:54want to do is we let's take a look at
  5155. 3:08:56some of the various uh configurations
  5156. 3:08:58you can set here so you can change the
  5157. 3:09:00default port this is great for those of
  5158. 3:09:02you who are who want to set up a
  5159. 3:09:03honeypot on that exact port like por 22
  5160. 3:09:06and then have ssh run on another port
  5161. 3:09:08like 2 2 2 0
  5162. 3:09:10you can do that as well
  5163. 3:09:12you can also change the listen address
  5164. 3:09:14if you want to uh the host key names uh
  5165. 3:09:17let's talk about uh let's just go down
  5166. 3:09:20into logging you can play around with
  5167. 3:09:22logging here
  5168. 3:09:23uh and i'll talk about logs probably in
  5169. 3:09:25another video and here we are we have uh
  5170. 3:09:28we have authentication all right so
  5171. 3:09:29within authentication you can see we
  5172. 3:09:31have an option called permit root login
  5173. 3:09:34right and we want to change this to no
  5174. 3:09:36right so from yes to no
  5175. 3:09:39uh and we we can also play around with
  5176. 3:09:41the grace the login grace time so we can
  5177. 3:09:44increase this or decrease it based on
  5178. 3:09:46the on the time you want to provide
  5179. 3:09:48uh we can keep strict modes to yes uh in
  5180. 3:09:52regards to the max authentication tries
  5181. 3:09:55we can change this to four although i'll
  5182. 3:09:57be making a separate video where i'll be
  5183. 3:09:59showing you how to set up ssh brute
  5184. 3:10:01force protection the max sessions i want
  5185. 3:10:04are going to be three public key
  5186. 3:10:06authentication
  5187. 3:10:08uh yes uh let's go all the way down now
  5188. 3:10:11um
  5189. 3:10:12and we are primarily looking for
  5190. 3:10:14password authentication so we'll talk
  5191. 3:10:16about this when we're going to be
  5192. 3:10:17setting up ssh keys so for now we've
  5193. 3:10:20we've essentially disabled uh where
  5194. 3:10:22we've disabled the root logins so if i
  5195. 3:10:24just save the the files here now when
  5196. 3:10:27whenever you've made changes to the uh
  5197. 3:10:29to the open sh server configuration file
  5198. 3:10:32we need to restart uh the open ssh
  5199. 3:10:35server so to do this again we'll use
  5200. 3:10:37systemd so say system
  5201. 3:10:40and we say
  5202. 3:10:42restart
  5203. 3:10:44sshd sshd service remember this is the
  5204. 3:10:47sshd daemon or the openssh server and we
  5205. 3:10:49hit enter
  5206. 3:10:50all right so now pretty much if we just
  5207. 3:10:53open up a new tab on my client and i try
  5208. 3:10:55and log into the root user account i
  5209. 3:10:57would say ssh root and i would say 192
  5210. 3:11:00168.1.113
  5211. 3:11:03and hit enter right and i enter the
  5212. 3:11:04password for the root user
  5213. 3:11:07and
  5214. 3:11:08you'll see pretty much that we will not
  5215. 3:11:10be able to do it so
  5216. 3:11:12uh that is pretty much uh going to block
  5217. 3:11:14any logins to this uh to this particular
  5218. 3:11:17account now the other thing we we want
  5219. 3:11:19to do is we want to disable or we want
  5220. 3:11:21to lock
  5221. 3:11:22the password for the
  5222. 3:11:25we want to lock the password for the
  5223. 3:11:26root account this will ensure that
  5224. 3:11:28even though
  5225. 3:11:30a person or an attacker may have
  5226. 3:11:33the password the legitimate password
  5227. 3:11:35they can get through it through another
  5228. 3:11:36user account because remember remember
  5229. 3:11:39if if a user gets access to the admin
  5230. 3:11:42account via ssh they can easily switch
  5231. 3:11:45to the root user account so we also have
  5232. 3:11:47to disable you know the password login
  5233. 3:11:50here and this will pretty much lock the
  5234. 3:11:52account unless we have the privileges to
  5235. 3:11:54actually change the password manually
  5236. 3:11:56and to unlock it but it's a great way of
  5237. 3:11:58of you know
  5238. 3:12:00protecting yourself from script kiddies
  5239. 3:12:01so
  5240. 3:12:02what we can do is we can say um we can
  5241. 3:12:05use the password command and say
  5242. 3:12:06password uh l and we specify the account
  5243. 3:12:09we or
  5244. 3:12:10the the account whose password we want
  5245. 3:12:11to lock and we hit enter uh we need uh
  5246. 3:12:14pseudo privileges here so you say sudo
  5247. 3:12:16hit enter and the password expiry
  5248. 3:12:18information has changed so you can say
  5249. 3:12:19sudo
  5250. 3:12:20password and then status
  5251. 3:12:23i believe it's status what options can
  5252. 3:12:25we specify here
  5253. 3:12:27root uh
  5254. 3:12:28wait enter no we do not want to enter a
  5255. 3:12:30new password so we can just do this one
  5256. 3:12:33more time here so you can see that i can
  5257. 3:12:34actually change the password but let me
  5258. 3:12:36lock it
  5259. 3:12:37um
  5260. 3:12:39root where is the status how do we check
  5261. 3:12:42the status oh yeah there is a capital s
  5262. 3:12:44so if we hit enter you can see that the
  5263. 3:12:46password is now going to be locked now
  5264. 3:12:48uh the second step would be to disable
  5265. 3:12:51password authentication and to use ssh
  5266. 3:12:54keys which is exactly what i'm going to
  5267. 3:12:56show you right now
  5268. 3:12:57so that will pretty much ensure that
  5269. 3:13:00you're protected from brute force
  5270. 3:13:01attacks because you're pretty much
  5271. 3:13:03ensuring that you cannot log into this
  5272. 3:13:05ssh server
  5273. 3:13:06without an ssh key right so
  5274. 3:13:10uh what we'll do is we will create a new
  5275. 3:13:12ssh key here and this is very this is
  5276. 3:13:15very easy to do so uh first of all uh we
  5277. 3:13:18need to uh we need to establish
  5278. 3:13:21uh what user account we're going to be
  5279. 3:13:24you know pretty much be using we've
  5280. 3:13:26already locked out the root account
  5281. 3:13:28and once we set up the ssh keys we'll be
  5282. 3:13:30pretty much logging into the admin user
  5283. 3:13:32account and the asset the ssh keys
  5284. 3:13:35or the ssh key based authentication will
  5285. 3:13:37only allow us to to access the admin
  5286. 3:13:39account
  5287. 3:13:40after which we will we will modify the
  5288. 3:13:43uh the openssh server configuration file
  5289. 3:13:45to disable
  5290. 3:13:46uh password authentication so what we'll
  5291. 3:13:48do is we'll say um
  5292. 3:13:51ssh keygen
  5293. 3:13:53um
  5294. 3:13:54there we are t rsa and we hit enter and
  5295. 3:13:57it's going to ask us for
  5296. 3:14:00uh it's going to say generating public
  5297. 3:14:02private
  5298. 3:14:03rsa key pair enter the file in which to
  5299. 3:14:06save the key so we'll say
  5300. 3:14:09home oil just leave it in this directory
  5301. 3:14:10hit enter we can enter a passphrase
  5302. 3:14:12that's always recommended i'll enter
  5303. 3:14:14password is here that will also add an
  5304. 3:14:16additional level of security to your ssh
  5305. 3:14:18key because remember the ssh private key
  5306. 3:14:21has to be kept secret so
  5307. 3:14:23we can see that the keys have been
  5308. 3:14:25copied into a home alexis and ssh
  5309. 3:14:27directory here so
  5310. 3:14:29pretty much what we can do now
  5311. 3:14:31is uh if we change our directory into
  5312. 3:14:33the ssh directory here you can see that
  5313. 3:14:36we have the public and private keys
  5314. 3:14:38right over here so what we need to do
  5315. 3:14:40now is we need to copy the uh the public
  5316. 3:14:43key onto the server so let me just
  5317. 3:14:44explain how ssh works really quickly how
  5318. 3:14:47the authentication works
  5319. 3:14:48so you store your public key on your on
  5320. 3:14:51the server and you have your private key
  5321. 3:14:53uh with you and the private key is the
  5322. 3:14:55most important as it's the
  5323. 3:14:57it's pretty much the key that will allow
  5324. 3:14:59you to authenticate successfully with
  5325. 3:15:01the server so you need to keep it secure
  5326. 3:15:03and backed up in the event you lose it
  5327. 3:15:05you lose access to the server that's
  5328. 3:15:07very important right
  5329. 3:15:08so essentially what what's going to
  5330. 3:15:10happen here
  5331. 3:15:12is your private key is used for
  5332. 3:15:13encryption right so your server the ssh
  5333. 3:15:15server will use your it will send a
  5334. 3:15:18random string of data to you the ssh
  5335. 3:15:20client uh after which the ssh client
  5336. 3:15:23will encrypt that a random string of
  5337. 3:15:25data with the private key and send the
  5338. 3:15:27encrypted data
  5339. 3:15:28uh to the server the server will then
  5340. 3:15:30use your public key to decrypt it and if
  5341. 3:15:33it then matches and you know so on and
  5342. 3:15:35so forth i'll explain that in a second
  5343. 3:15:37so
  5344. 3:15:37what we can do now is we need to copy
  5345. 3:15:39this uh so we say ssh
  5346. 3:15:41copy
  5347. 3:15:42id and we specify uh the the server so
  5348. 3:15:46we say
  5349. 3:15:48192.168.1.113 and we hit enter
  5350. 3:15:50it's going to ask you you can see it's
  5351. 3:15:52asking for the user alexis but we don't
  5352. 3:15:55want to do this remember because we want
  5353. 3:15:57to use the uh the user admin so we're
  5354. 3:15:59going to say admin and we're gonna hit
  5355. 3:16:01enter it's gonna ask for admins password
  5356. 3:16:04like so and uh
  5357. 3:16:06you can see after we've entered the
  5358. 3:16:07password it's gonna ask us for the it's
  5359. 3:16:09gonna tell us the number of keys added
  5360. 3:16:10is one
  5361. 3:16:11and we can now try try login to the
  5362. 3:16:13machine with ssh admin and we will
  5363. 3:16:16essentially not have uh we will not need
  5364. 3:16:18to use passwords but before we do that
  5365. 3:16:21we need to disable password
  5366. 3:16:22authentication with ssh so to do this
  5367. 3:16:24again we say sudo vim and i'm back on
  5368. 3:16:26the server now ssh
  5369. 3:16:29and we say sshd config and we hit enter
  5370. 3:16:32and
  5371. 3:16:33we'll go all the way to the bottom here
  5372. 3:16:36uh am i in the right configuration file
  5373. 3:16:38i believe so
  5374. 3:16:41yes we are i believe uh your possible
  5375. 3:16:44authentication right over here
  5376. 3:16:46and we will change this to no so this
  5377. 3:16:49will
  5378. 3:16:49essentially disable the ability for you
  5379. 3:16:52to log in to this or to this remote
  5380. 3:16:55server via ssh with passwords so the
  5381. 3:16:57only way you can login
  5382. 3:16:59is going to be through ssh keys so now i
  5383. 3:17:02can
  5384. 3:17:03write changes and exits here and we'll
  5385. 3:17:06restart the
  5386. 3:17:07ssh server
  5387. 3:17:09service or the sshd service we enter and
  5388. 3:17:12that's going to restart it for us orange
  5389. 3:17:14so now if we exit
  5390. 3:17:16we can essentially say ssh
  5391. 3:17:18admin
  5392. 3:17:20at 182
  5393. 3:17:23168.1.113.8 enter and it's going to ask
  5394. 3:17:25me for the passphrase for the for the
  5395. 3:17:27private key and we're going to unlock
  5396. 3:17:29and there we are we now have access
  5397. 3:17:31right now some of you might be saying
  5398. 3:17:33well uh you have the private key what if
  5399. 3:17:36the location is different so let me just
  5400. 3:17:37show you this right now so i'll go into
  5401. 3:17:39my ssh directory here
  5402. 3:17:42and uh
  5403. 3:17:44just list all the files and i'll say
  5404. 3:17:46i'll move the um
  5405. 3:17:48this is sorry sorry about that let me
  5406. 3:17:50just go to my local directory here or i
  5407. 3:17:51can actually just log out
  5408. 3:17:53so cd ssh
  5409. 3:17:55and what i'll do is i'll move the
  5410. 3:17:57private key so i'll say move id
  5411. 3:18:00rsa to uh
  5412. 3:18:02sorry to my desktop and i'll hit enter
  5413. 3:18:05and now if i try and log in so i say ssh
  5414. 3:18:08uh admin
  5415. 3:18:10sorry uh
  5416. 3:18:12states
  5417. 3:18:14enter you can see it logs in just fine
  5418. 3:18:16however if if i didn't know the location
  5419. 3:18:18what i would say is for example let me
  5420. 3:18:21just exit i would say for example if i
  5421. 3:18:23was logged in on another computer
  5422. 3:18:25i would then say uh so again let me just
  5423. 3:18:28go on to my desktop here
  5424. 3:18:31if i wanted to specify a private key for
  5425. 3:18:33logging in i would say ssh i and then i
  5426. 3:18:36would say id rsa and then i say admin at
  5427. 3:18:42192.168.1.1138 enter and typically what
  5428. 3:18:45you want to do is you want to ensure
  5429. 3:18:46that your private key has permissions
  5430. 3:18:49you want to ensure that it can only be
  5431. 3:18:51read
  5432. 3:18:52by the current user and not by the group
  5433. 3:18:54or all other users on the system so a
  5434. 3:18:57great precaution or a great way of doing
  5435. 3:18:59this is saying chmod 400
  5436. 3:19:02id rsa and that will essentially protect
  5437. 3:19:04your private key right so that is
  5438. 3:19:07essentially how to you know set up ssh
  5439. 3:19:10uh and how to copy your how to set up
  5440. 3:19:13key based authentication how to copy
  5441. 3:19:15your ssh keys onto the server
  5442. 3:19:17and we cannot talk about you know
  5443. 3:19:19copying remote files or copying you know
  5444. 3:19:21files remotely with ssh so again to do
  5445. 3:19:24this is very simple what i'll do is i'll
  5446. 3:19:26just create a file let's say touch test
  5447. 3:19:28dot ext and i'll cat fc uh password into
  5448. 3:19:34the test.txt file here and what let's
  5449. 3:19:37say i wanted to copy this test.txt file
  5450. 3:19:40into the ssh server uh what i would do
  5451. 3:19:43is i would use the scp utility so the
  5452. 3:19:45scp is again secure copy so i would say
  5453. 3:19:48scp and then i would specify the file so
  5454. 3:19:51i'll say touch
  5455. 3:19:52uh sorry test test.txt and then i would
  5456. 3:19:55spare out specify the credentials so it
  5457. 3:19:57say admin 192.168.1.11
  5458. 3:20:00and then i'll specify the location i
  5459. 3:20:02want to save it in so i say home admin
  5460. 3:20:05uh this is on the remote server by the
  5461. 3:20:07way so home uh i can't seem to write
  5462. 3:20:09admin today for some reason and i'll
  5463. 3:20:12essentially hit enter and you can see
  5464. 3:20:14that it actually copied quite quickly so
  5465. 3:20:17now if we try and log in so we say ssh
  5466. 3:20:23one one three uh
  5467. 3:20:24three and eight enter and we list the
  5468. 3:20:27files within the home directory for
  5469. 3:20:28admin you can see that we have the
  5470. 3:20:30test.txt file and if i catch the content
  5471. 3:20:33here it's the
  5472. 3:20:34it's the password information for the uh
  5473. 3:20:37for my client uh right over here which
  5474. 3:20:39is running ubuntu and you can see my
  5475. 3:20:41user accounts
  5476. 3:20:42there so that is pretty much how to use
  5477. 3:20:45ssh how to set it up how to set up
  5478. 3:20:47authentication how to protect uh your
  5479. 3:20:49root user account how to copy files
  5480. 3:20:51securely how to set up key based
  5481. 3:20:53authentication so i hope that was
  5482. 3:20:54comprehensive enough
  5483. 3:21:00so this video is going to be focused on
  5484. 3:21:01essentially getting you to fully learn
  5485. 3:21:04and of course utilize curl to its
  5486. 3:21:07maximum potential and i'm going to be
  5487. 3:21:09covering as many commands as i possibly
  5488. 3:21:10can now that being said curl has a lot
  5489. 3:21:13of functionality that you need to
  5490. 3:21:15explore on your own as well but i'll be
  5491. 3:21:17covering some of the most important bits
  5492. 3:21:19of functionality that it does offer to a
  5493. 3:21:21normal user or a power user as well
  5494. 3:21:24so uh without any further ado let's get
  5495. 3:21:26started so for those of you who have
  5496. 3:21:28never heard of curl curl is essentially
  5497. 3:21:30a utility that allows you to transfer
  5498. 3:21:32data to or from a network server using
  5499. 3:21:35one of the supported protocols now the
  5500. 3:21:37protocols that it does support are http
  5501. 3:21:40https ftp
  5502. 3:21:42ftps you also have your sftp you have
  5503. 3:21:46tftp telnet et cetera et cetera now
  5504. 3:21:48there are various other
  5505. 3:21:49protocols that it does support in
  5506. 3:21:51addition to the ones i've just mentioned
  5507. 3:21:53uh but i will get into that later
  5508. 3:21:55now the great thing about curl is that
  5509. 3:21:57it is a multi-platform tool which means
  5510. 3:22:00uh it works on linux uh mac os and
  5511. 3:22:02windows now i'm gonna be covering how to
  5512. 3:22:04use it on linux but of course the
  5513. 3:22:06commands are pretty much the same now in
  5514. 3:22:08regards to installing uh installing curl
  5515. 3:22:10it as far as i know it comes
  5516. 3:22:12pre-installed with most akia linux
  5517. 3:22:14distributions uh but if you want to
  5518. 3:22:16install it whether or not using the
  5519. 3:22:18aptitude package manager you can use the
  5520. 3:22:20sudo apt-get install curl command and if
  5521. 3:22:23you are if you're using an archbase
  5522. 3:22:25distribution you can use the pacman s
  5523. 3:22:28command to install it and the the name
  5524. 3:22:30of the package is curl all right if you
  5525. 3:22:32are using a mac os installation or mac
  5526. 3:22:35os as your operating system you can use
  5527. 3:22:37the brew install command so that is brew
  5528. 3:22:40install and curl all right and that's
  5529. 3:22:43pretty much uh simple right over there
  5530. 3:22:44with windows you need to download an
  5531. 3:22:46executable or a bin file if i'm not
  5532. 3:22:48wrong and you need to save it in your
  5533. 3:22:49windows directory and of course from
  5534. 3:22:51that you can directly launch it from
  5535. 3:22:53your command prompt
  5536. 3:22:55that being said let's get started now
  5537. 3:22:57curl as i mentioned comes pre-installed
  5538. 3:22:59with most linux distributions so let me
  5539. 3:23:01just clear the terminal here and i'll
  5540. 3:23:03maximize it so we can see what's going
  5541. 3:23:05on
  5542. 3:23:06all right so the basic syntax is as
  5543. 3:23:08follows but before we do that let's open
  5544. 3:23:10up the help menu you can explore the
  5545. 3:23:12help menu if you are if you're really
  5546. 3:23:14looking for a bit more functionality or
  5547. 3:23:16you're looking for specific functions as
  5548. 3:23:19you can see it's a very comprehensive
  5549. 3:23:20tool and i'm primarily going to be
  5550. 3:23:22covering uh the basic commands that you
  5551. 3:23:24that allow you to utilize it quite well
  5552. 3:23:27uh that being said many people ask me
  5553. 3:23:29how i personally learn about a command
  5554. 3:23:31that or a tool that i'm not familiar
  5555. 3:23:33with i personally use the man or the
  5556. 3:23:36manual for each of these tools so the
  5557. 3:23:38manual contains a very very good
  5558. 3:23:40description of of all the bits of
  5559. 3:23:42functionality in regards to a tool uh
  5560. 3:23:45and all linux tools pretty much uh come
  5561. 3:23:47with a manual and the manual is
  5562. 3:23:49extremely useful so if you you want to
  5563. 3:23:51check them out go ahead and do it i
  5564. 3:23:53really really recommend it when learning
  5565. 3:23:55how to uh how to use a tool
  5566. 3:23:57all right so let's talk about the basic
  5567. 3:23:59queries you can perform with curl all
  5568. 3:24:01right so when i talk about interacting
  5569. 3:24:02with the various protocols this
  5570. 3:24:04particular video is going to be focused
  5571. 3:24:06on http and https i know there is
  5572. 3:24:09ftp functionality but i'm not going to
  5573. 3:24:11be getting into that because that's more
  5574. 3:24:13that's where things sort of get a bit
  5575. 3:24:15different but for now let's focus on
  5576. 3:24:17those two protocols all right so when
  5577. 3:24:19performing a basic query of a url uh you
  5578. 3:24:22essentially type in curl and then the
  5579. 3:24:24url so for example if i type in
  5580. 3:24:27hsploit.com here
  5581. 3:24:29and hit enter what will happen is this
  5582. 3:24:31will essentially fetch the content of
  5583. 3:24:33the specified url so for example i've
  5584. 3:24:36hit curl https hsplugged.com and it will
  5585. 3:24:38essentially return to me the content of
  5586. 3:24:41the entire web page now you might be
  5587. 3:24:42wondering well how can we verify this
  5588. 3:24:45and that's where we get into essentially
  5589. 3:24:47saving your output into a file or
  5590. 3:24:49downloading files so i can say for
  5591. 3:24:51example curl and if i want to output the
  5592. 3:24:54uh the output of this command or the
  5593. 3:24:55contents of this query i can say i can
  5594. 3:24:57use the lowercase o and i can then say i
  5595. 3:25:00specify the directory i want to save it
  5596. 3:25:02in so home alexis desktop
  5597. 3:25:04and i'll just uh sorry that is desk that
  5598. 3:25:07is desktop and i'll just call it uh
  5599. 3:25:09hsploit
  5600. 3:25:12dot html and after that i'll type in
  5601. 3:25:14hsflight.com
  5602. 3:25:16right over here that is the url now it's
  5603. 3:25:18very important to specify
  5604. 3:25:20uh the protocol that you're using so for
  5605. 3:25:22example if a website is http you won't
  5606. 3:25:24need to specify to get it if it is using
  5607. 3:25:27the https protocol it is very important
  5608. 3:25:29but i'll get into redirection in a
  5609. 3:25:31second so
  5610. 3:25:33https.com and we hit enter and it's
  5611. 3:25:35going to give you this little status
  5612. 3:25:37right over here essentially giving you
  5613. 3:25:39an update as to what is the current
  5614. 3:25:41status of the entire process here now
  5615. 3:25:43for some reason it's taking quite a
  5616. 3:25:44while now
  5617. 3:25:45but we'll wait for it to complete and
  5618. 3:25:47there we are so
  5619. 3:25:48let me explain a bit of the uh the the
  5620. 3:25:51structure of this little status menu or
  5621. 3:25:54table here so for example you have the
  5622. 3:25:55total amount to be downloaded uh the
  5623. 3:25:58amount received the average download
  5624. 3:26:00speed the upload speed the the total
  5625. 3:26:03time are the time spent and the time
  5626. 3:26:05left and uh right now if we cat
  5627. 3:26:07uh the the hs flight dot um well
  5628. 3:26:10actually if we need to go into our
  5629. 3:26:12desktop here uh so if we capped
  5630. 3:26:14hsploit.html here you can see the entire
  5631. 3:26:16contents now if we open that up here if
  5632. 3:26:19i open that up with uh with chrome for
  5633. 3:26:21example let me just open this up where
  5634. 3:26:23is google chrome
  5635. 3:26:24um
  5636. 3:26:26where is google chrome here there we are
  5637. 3:26:28google chrome if i just open that up
  5638. 3:26:30here in a web page you can see that
  5639. 3:26:31pretty much it has all the content of my
  5640. 3:26:34website so each exploit.com and it's
  5641. 3:26:36pretty cool that it does save the entire
  5642. 3:26:38contents of the html file here now of
  5643. 3:26:40course this is going to um this is going
  5644. 3:26:42to leave out
  5645. 3:26:44extra bits of files in regards to the
  5646. 3:26:46the web page but this is a great way of
  5647. 3:26:48saving the contents of a query now that
  5648. 3:26:50could be for any other protocol it not
  5649. 3:26:52it does not necessarily need to be for
  5650. 3:26:54the http or the https protocols all
  5651. 3:26:57right now when we talk about downloading
  5652. 3:26:59files
  5653. 3:27:00that is pretty much how it goes for a
  5654. 3:27:02web page or for a query so let me just
  5655. 3:27:05remove the hsp.html mind you i could
  5656. 3:27:07have saved it as a txt file i simply i'm
  5657. 3:27:10saving it so that i can use it at a
  5658. 3:27:12later time now you can also use curl to
  5659. 3:27:15download files from the web which is
  5660. 3:27:17really really awesome and that's
  5661. 3:27:18primarily why i have the ubuntu page
  5662. 3:27:20open here because i want an example to
  5663. 3:27:22use so for example if i wanted to
  5664. 3:27:23download the ubuntu iso
  5665. 3:27:26i go to the download page and i select
  5666. 3:27:27the air version 18.4
  5667. 3:27:2918.04 lts
  5668. 3:27:32and it's going to start the download so
  5669. 3:27:33if i just going to show all downloads
  5670. 3:27:35here and let me just copy the link here
  5671. 3:27:37the download link so i can go into curl
  5672. 3:27:40and i can say for example
  5673. 3:27:42i can give the file name a new name or i
  5674. 3:27:44can just download it directly so let me
  5675. 3:27:46explain the two ways of doing it so for
  5676. 3:27:48example i can say curl
  5677. 3:27:50i can output the uh i cannot i can say
  5678. 3:27:53download this file as ubuntu
  5679. 3:27:56iso
  5680. 3:27:57dot iso sorry iso and then i i paste in
  5681. 3:28:01the the download link and what that is
  5682. 3:28:03going to do is that it's going to
  5683. 3:28:04download the file and save it as ubuntu
  5684. 3:28:07iso dot iso now the extension is very
  5685. 3:28:09important because if you get that wrong
  5686. 3:28:11it's going to save it as a different
  5687. 3:28:12file type all right so if i enter you
  5688. 3:28:14can see it's going to start the download
  5689. 3:28:16and there we are we can see that the
  5690. 3:28:18total amount to be downloaded is one uh
  5691. 3:28:19194 megabytes which is about 1.9
  5692. 3:28:22gigabytes and you have the received the
  5693. 3:28:24download speed the average download
  5694. 3:28:26speed and the current download speed
  5695. 3:28:27right over here the time left etc etc
  5696. 3:28:30now you can see that my internet speed
  5697. 3:28:32is pretty bad right now but that's
  5698. 3:28:33primarily because i am updating one of
  5699. 3:28:35my systems so i do apologize for that so
  5700. 3:28:38if we check the desktop you can see we
  5701. 3:28:39have the ubuntu iso over here which does
  5702. 3:28:42prove that it does work all right now
  5703. 3:28:44the other way of doing it
  5704. 3:28:46let me just remove the ubuntu iso.iso
  5705. 3:28:48file there the other way of doing it is
  5706. 3:28:50by downloading it with its original file
  5707. 3:28:52name which is specified on the on the
  5708. 3:28:54web server so
  5709. 3:28:56to do that i simply type in curl and i
  5710. 3:28:58use the capital o and i paste in the
  5711. 3:29:00download link and hit enter and that is
  5712. 3:29:03going to download the file with its
  5713. 3:29:04original download name so you can see
  5714. 3:29:06ubuntu 18.04.2
  5715. 3:29:08uh desktop amd 64-bit dot iso or md64
  5716. 3:29:13dot iso all right so that is
  5717. 3:29:15pretty much how to download files and
  5718. 3:29:17now that i've explained that
  5719. 3:29:19we cannot talk about redirects because
  5720. 3:29:20redirects are extremely important so
  5721. 3:29:23if i just get rid of ubuntu here so if a
  5722. 3:29:26website is redirecting to another url
  5723. 3:29:29it's very important that you know how to
  5724. 3:29:31specify this to curl and why is that
  5725. 3:29:33important so in many cases redirects may
  5726. 3:29:36be set up and of course that is
  5727. 3:29:37specified by the http
  5728. 3:29:39300 request or the it could be any 300
  5729. 3:29:42requests mostly theo one or three or
  5730. 3:29:44three
  5731. 3:29:44and it's very important that you know
  5732. 3:29:47how to specify this with call now the hd
  5733. 3:29:49the http protocol syntax is very
  5734. 3:29:51important in curl and you can do this by
  5735. 3:29:53using the l command or the capital l
  5736. 3:29:55command sorry so for example
  5737. 3:29:58if my website was uh if the
  5738. 3:30:00urlhsflight.com
  5739. 3:30:02was uh so if i say
  5740. 3:30:04hsplug.com
  5741. 3:30:06was redirecting to another url to
  5742. 3:30:09another url and i wanted to specify this
  5743. 3:30:11to curl i would use the l command now i
  5744. 3:30:13know that my website is not and a great
  5745. 3:30:16way of demonstrating this is by using uh
  5746. 3:30:18the so for example if i say curl
  5747. 3:30:21http
  5748. 3:30:23hslight.com
  5749. 3:30:26right over here and hit enter and we'll
  5750. 3:30:28give that a few seconds here and i'll
  5751. 3:30:30explain what's happening in a second so
  5752. 3:30:32that you can see the importance of
  5753. 3:30:33specifying uh the l parameter if there
  5754. 3:30:36is a redirect so you can see i got no
  5755. 3:30:38result and that's because curl is going
  5756. 3:30:40to http and that's the importance of
  5757. 3:30:43protocols with curl you need to specify
  5758. 3:30:44the correct protocol irregardless of
  5759. 3:30:46whether or not you're using ftp
  5760. 3:30:48http https so my website is https now my
  5761. 3:30:53website by default will redirect however
  5762. 3:30:55you need to specify that with curl i do
  5763. 3:30:57apologize for that and let me just clear
  5764. 3:30:59the notifications here
  5765. 3:31:01so again i i as i mentioned you need to
  5766. 3:31:03specify this with girls so i can say
  5767. 3:31:05curl and i use the l command over here
  5768. 3:31:08and then i specify http
  5769. 3:31:11uh and then i say hsplight.com here
  5770. 3:31:13right over here and hit enter
  5771. 3:31:15and that will essentially redirect me to
  5772. 3:31:17the appropriate webpage and
  5773. 3:31:19as you can see right over here we get
  5774. 3:31:21the entire contents of the
  5775. 3:31:23hsp.com website or html file rather so
  5776. 3:31:26that is how to do essentially how to
  5777. 3:31:29work around um how to work around
  5778. 3:31:31redirects
  5779. 3:31:32all right now another bit of important
  5780. 3:31:35another important command sorry is the
  5781. 3:31:37querying response headers so you can
  5782. 3:31:39also view and analyze the response
  5783. 3:31:42headers being sent by a particular web
  5784. 3:31:43server
  5785. 3:31:44and this can help in web assessment so
  5786. 3:31:46for example if i wanted to query the
  5787. 3:31:48response uh the response headers i'm
  5788. 3:31:49being sent back by the web server i can
  5789. 3:31:52say curl
  5790. 3:31:53capital i and i can say
  5791. 3:31:55https
  5792. 3:31:58hs plate.com
  5793. 3:32:01and i can just hit enter and what's
  5794. 3:32:03going to happen here is it will give it
  5795. 3:32:05a few seconds this is going to depend on
  5796. 3:32:07uh varyingly depending on your on your
  5797. 3:32:10particular web server so you can see it
  5798. 3:32:11gives us the protocol we have cookies
  5799. 3:32:13here uh we have the php version so we're
  5800. 3:32:16getting important information now uh
  5801. 3:32:18looks like we have some wordpress json
  5802. 3:32:21files here if i delivered by the cdn or
  5803. 3:32:23the content delivery network
  5804. 3:32:25uh let's look at some important cookies
  5805. 3:32:28here that might give us a bit of
  5806. 3:32:29information in regards to the website so
  5807. 3:32:30an important bit of information here and
  5808. 3:32:32of course i'm using this as an example
  5809. 3:32:35is the dwqa
  5810. 3:32:37and this is my question and answer
  5811. 3:32:39plugin that i use and you can see that
  5812. 3:32:41it has an anonymous cookie that's being
  5813. 3:32:42set here and that can give you
  5814. 3:32:44information as to a bit more of how the
  5815. 3:32:46web application is working so that is
  5816. 3:32:48how to query the response that is being
  5817. 3:32:50sent by the server and of course you can
  5818. 3:32:51see right over here this is a cloudflare
  5819. 3:32:53server and we have the cfra which is the
  5820. 3:32:56cloudflare array
  5821. 3:32:57that essentially uh uh
  5822. 3:32:59is telling cloudflare uh what uh it's
  5823. 3:33:02giving information to cloudflare about
  5824. 3:33:04the particular client that is accessing
  5825. 3:33:06the web server all right now that is
  5826. 3:33:08very interesting however it really gets
  5827. 3:33:10interesting because girl can also do a
  5828. 3:33:12really cool thing it can also allow you
  5829. 3:33:14to view the request headers and the
  5830. 3:33:16connection details so you can view the
  5831. 3:33:17tls handshake et cetera et cetera so if
  5832. 3:33:20i say curl
  5833. 3:33:21v and i say curl v
  5834. 3:33:24https
  5835. 3:33:25and they say exploit.com here and hit
  5836. 3:33:27enter you can see that we can view the
  5837. 3:33:29entire tls and shake which is really
  5838. 3:33:32really unique and awesome so
  5839. 3:33:34let me just see if i can figure uh which
  5840. 3:33:37is wait which is right over here so
  5841. 3:33:39there we are we can see the the initial
  5842. 3:33:40connection here
  5843. 3:33:42uh we i'm particularly looking for the
  5844. 3:33:44tls uncheck and right over here we can
  5845. 3:33:46see the tls handshake taking place so
  5846. 3:33:48you can see that it is successful and
  5847. 3:33:50this is a great way of identifying um
  5848. 3:33:53problems with the tls uncheck if the
  5849. 3:33:54certificate has an issue so for example
  5850. 3:33:57we have the client hello the server
  5851. 3:33:58hello we then have the encrypted
  5852. 3:34:00extensions being exchanged the
  5853. 3:34:02certificate is being exchanged and then
  5854. 3:34:04verified and then finally the tls
  5855. 3:34:06uncheck is completed you can see that we
  5856. 3:34:08have the version tls version 1.3 and the
  5857. 3:34:11ciphers that are being used or the
  5858. 3:34:13encryption being used
  5859. 3:34:14all right so you also have information
  5860. 3:34:15about these certificates uh expiry date
  5861. 3:34:18uh when it was actually registered uh
  5862. 3:34:20the issuer all that good stuff so if you
  5863. 3:34:22do want to view
  5864. 3:34:24uh if you do want to view the connection
  5865. 3:34:26details and a bit of an advanced
  5866. 3:34:28information or additional information in
  5867. 3:34:30regards to the connection you can go
  5868. 3:34:32ahead and use the uh the v command
  5869. 3:34:35now the last thing that i want to cover
  5870. 3:34:37in regards to the http and http hts
  5871. 3:34:40protocols is the fact that you can cross
  5872. 3:34:42post requests and many people have seen
  5873. 3:34:44me using this in ctfs particularly when
  5874. 3:34:47i'm essentially brute forcing um
  5875. 3:34:50login pages so
  5876. 3:34:52uh i can give you an example so if i
  5877. 3:34:54wanted to essentially test credentials
  5878. 3:34:56on a website and this can really be in
  5879. 3:34:58any uh i can be using any parameters i
  5880. 3:35:01could be spoofing various cookies all
  5881. 3:35:03that good stuff so for example i can say
  5882. 3:35:05if i wanted to log in to wordpress site
  5883. 3:35:08and i wanted to essentially test various
  5884. 3:35:10credentials i can say for example
  5885. 3:35:12curl
  5886. 3:35:13data and that is the sorry the data that
  5887. 3:35:16we're specifying and then in here i
  5888. 3:35:17would specify log and this is the
  5889. 3:35:19particular syntax for wordpress and the
  5890. 3:35:21password would be equal to i can say
  5891. 3:35:24password here and then i close the uh
  5892. 3:35:27the uh the quotation marks and then i
  5893. 3:35:29specify uh the wordpress page here so i
  5894. 3:35:31can say
  5895. 3:35:33https and you can say
  5896. 3:35:36wordpress.com and i can say wordpress
  5897. 3:35:39login dot php and that is the login page
  5898. 3:35:43right over here and if i hit enter
  5899. 3:35:45and i know this you can see that admin
  5900. 3:35:47is not a valid username or wordpress.com
  5901. 3:35:49etc you get the response so this is a
  5902. 3:35:50great way of testing various pieces of
  5903. 3:35:52data so you can also play around with
  5904. 3:35:54cookies all that good stuff and in this
  5905. 3:35:56case we're simply playing around with
  5906. 3:35:57the login and the password parameters
  5907. 3:35:59here and we specified our own values
  5908. 3:36:02now if you do need to to encode the
  5909. 3:36:04particular parameters you can also use
  5910. 3:36:06burp suite for that so for example
  5911. 3:36:09um let's see if i wanted to go um let me
  5912. 3:36:12just uh turn intercept on here
  5913. 3:36:15if i just went into hsploy.com here so i
  5914. 3:36:18just say it it's exploit.com and it's a
  5915. 3:36:20wordpress login.php
  5916. 3:36:24sorry.php here and i just hit enter and
  5917. 3:36:27uh for some reason we're getting stack
  5918. 3:36:29uh stack
  5919. 3:36:30we're just getting a stack protect here
  5920. 3:36:32in any case uh the what i was getting to
  5921. 3:36:34if you do want to encrypt your url or
  5922. 3:36:36any other parameters you can use the
  5923. 3:36:38control plus u key
  5924. 3:36:43in this video we're going to be looking
  5925. 3:36:45at how to use the uncomplicated firewall
  5926. 3:36:48or as it is commonly known as ufw on
  5927. 3:36:51linux alright so you might be asking
  5928. 3:36:53what exactly is ufw or what is the
  5929. 3:36:56uncomplicated firewall if it isn't
  5930. 3:36:58already self-explanatory well
  5931. 3:37:01ufw or the uncomplicated firewall acts
  5932. 3:37:04as an interface to ip tables and is
  5933. 3:37:06designed to simplify the process of
  5934. 3:37:09configuring a firewall now you also
  5935. 3:37:11might be asking well what exactly is
  5936. 3:37:13iptables well iptables is an extremely
  5937. 3:37:16flexible firewall utility that was built
  5938. 3:37:19for linux operating systems now you also
  5939. 3:37:21might be asking well why aren't we using
  5940. 3:37:24ip tables why are we using ufw as
  5941. 3:37:26opposed to ip tables well iptables is a
  5942. 3:37:29great tool that offers great
  5943. 3:37:30functionality when it comes down to
  5944. 3:37:32configuring firewalls however it can be
  5945. 3:37:34difficult for beginners to learn how to
  5946. 3:37:36use it properly when configuring a
  5947. 3:37:38firewall as a result ufw is well suited
  5948. 3:37:42for beginners and as a result they can
  5949. 3:37:44use they can learn how to use a firewall
  5950. 3:37:46or to configure a firewall really really
  5951. 3:37:48easily and they can learn about rules
  5952. 3:37:50etc they get the the general idea behind
  5953. 3:37:53a firewall all right so ufw is a is a
  5954. 3:37:57great firewall that is designed to be
  5955. 3:37:59run on hosts or servers uh but it's only
  5956. 3:38:02doubtful in the extent is in the extent
  5957. 3:38:04uh it offers in in terms or in regards
  5958. 3:38:07to functionality what i mean by this it
  5959. 3:38:10it only goes so far as uh
  5960. 3:38:13as allowing you to block or allow
  5961. 3:38:15connections to and from uh to and from
  5962. 3:38:17the server so incoming and outgoing and
  5963. 3:38:19you can also block ip addresses ports
  5964. 3:38:21etc and entire an entire subnet
  5965. 3:38:24which i'll get into in a second
  5966. 3:38:26all right
  5967. 3:38:28so the purpose of this video the purpose
  5968. 3:38:30of this video is to teach you how to use
  5969. 3:38:31ufw and all the comments that you need
  5970. 3:38:33to know to get started and to fully
  5971. 3:38:35utilize it to its uh due to your
  5972. 3:38:38advantage really so this will include
  5973. 3:38:39commands such as allowing and blocking
  5974. 3:38:41various services by port uh and their
  5975. 3:38:44source ip addresses and this video
  5976. 3:38:46should be used as a reference so if this
  5977. 3:38:48is your first time with ufw you can
  5978. 3:38:50definitely find something that you
  5979. 3:38:51haven't you that you didn't know in this
  5980. 3:38:53video if this is your if you're already
  5981. 3:38:55an experienced use of ufw hopefully you
  5982. 3:38:57can find something in this video that
  5983. 3:38:59you didn't know already alright so
  5984. 3:39:01without any further ado let's get
  5985. 3:39:03started
  5986. 3:39:04so
  5987. 3:39:05uh installing ufw is very very simple
  5988. 3:39:08now if you are using an ubuntu server or
  5989. 3:39:10you're running ubuntu ufw should be
  5990. 3:39:12pre-installed on it if it isn't getting
  5991. 3:39:14installed on any other distribution is
  5992. 3:39:16very very simple use your aptitude
  5993. 3:39:18package manager so sudo apt-get install
  5994. 3:39:22ufw i already have mine installed so
  5995. 3:39:24it'll check for an update if there isn't
  5996. 3:39:26an update it's not going to update it
  5997. 3:39:28and it's going to give me the results
  5998. 3:39:29here all right so once it is installed
  5999. 3:39:31we are ready to begin
  6000. 3:39:33now the important bits of using ufw are
  6001. 3:39:36always knowing its state or its status
  6002. 3:39:38all right so currently i have ufw
  6003. 3:39:41disabled it is not running and if i
  6004. 3:39:43wanted to know that i would simply type
  6005. 3:39:45in
  6006. 3:39:46sudo
  6007. 3:39:47ufw status now it is very important to
  6008. 3:39:50precede the ufw command with sudo if
  6009. 3:39:53you're not using a root user in my case
  6010. 3:39:55i'm using the root user so i don't need
  6011. 3:39:58to use the sudo command but in any case
  6012. 3:40:00i will use it so that it becomes a good
  6013. 3:40:02practice with you and i don't recommend
  6014. 3:40:05running efw from the root user but this
  6015. 3:40:07is a simple video for demonstration all
  6016. 3:40:10right so i'm going to hit enter it's
  6017. 3:40:11going to tell you the status of the ufw
  6018. 3:40:14or the uncomplicated firewall is
  6019. 3:40:16inactive which is great all right now i
  6020. 3:40:19can also check an additional i can get
  6021. 3:40:21more information from the status command
  6022. 3:40:23by typing in verbose which will give me
  6023. 3:40:25more information in regards to the rules
  6024. 3:40:27that are currently active now as you
  6025. 3:40:29guessed it will not display anything
  6026. 3:40:31because we haven't set any particular
  6027. 3:40:33rules and the if the firewall is
  6028. 3:40:35currently not active so nothing really
  6029. 3:40:38special there and the last status
  6030. 3:40:40command that is very very popular is to
  6031. 3:40:42is to show the status the numbered
  6032. 3:40:44status so that you have an idea of what
  6033. 3:40:46uh what rules are currently running and
  6034. 3:40:48their number so that you can terminate
  6035. 3:40:50or delete them all right so that's what
  6036. 3:40:52what it's there for now of course these
  6037. 3:40:54don't make any sense right now because
  6038. 3:40:56the the current status of the firewall
  6039. 3:40:58is inactive once we activate it or once
  6040. 3:41:01it is active we will be able to get a
  6041. 3:41:03whole lot more information from them all
  6042. 3:41:05right so i'm going to enter again you'll
  6043. 3:41:06see it's going to tell you that it is
  6044. 3:41:08inactive and that is fine
  6045. 3:41:10all right
  6046. 3:41:11so let's talk about enabling disabling
  6047. 3:41:14and resetting ufw so enabling ufw is
  6048. 3:41:16very simple sudo ufw and enable and that
  6049. 3:41:20will enable the firewall and it'll give
  6050. 3:41:22you the little status over here the
  6051. 3:41:24firewall is active and is enabled on
  6052. 3:41:27system startup which is excellent so
  6053. 3:41:28that it is always active and if you are
  6054. 3:41:30running a server that is huge for you
  6055. 3:41:33all right so disabling it is very very
  6056. 3:41:35simple we simply type in
  6057. 3:41:37disable and we hit enter
  6058. 3:41:40all right and that will tell you that
  6059. 3:41:41the firewall is stopped and disabled on
  6060. 3:41:43on system startup
  6061. 3:41:45now when i talk about resetting the the
  6062. 3:41:47ufw or the uncomplicated firewall this
  6063. 3:41:50is in regards to the rules that you
  6064. 3:41:51might have set now please do use caution
  6065. 3:41:54with the reset command the reset command
  6066. 3:41:56is there to to help you out if you have
  6067. 3:41:58made a mistake in configuring your
  6068. 3:42:00firewall now if you already have a
  6069. 3:42:01working firewall and you only want to
  6070. 3:42:03delete a particular rule do not use the
  6071. 3:42:05reset command because that will reset
  6072. 3:42:08your firewall to the default uh to the
  6073. 3:42:10default configuration that it came with
  6074. 3:42:12pre-installed or installed or the the
  6075. 3:42:14configuration it came with installed all
  6076. 3:42:16right so if i type in sudo ufw
  6077. 3:42:20uh ufw reset that will reset it and
  6078. 3:42:22it'll tell you that which is very good
  6079. 3:42:24resetting all the rules to the installed
  6080. 3:42:26defaults proceed with operation
  6081. 3:42:29y or n for yes or no hit yes to reset it
  6082. 3:42:33and there you are so there is a small
  6083. 3:42:35fyi if in case you wanted to know that
  6084. 3:42:37and you've messed up
  6085. 3:42:38in this video and you want to reset it
  6086. 3:42:40there you are
  6087. 3:42:41all right so what we're going to do is
  6088. 3:42:42we're going to start off we
  6089. 3:42:44understanding the default policies uh
  6090. 3:42:46for the ufw or the uncomplicated
  6091. 3:42:49firewall
  6092. 3:42:50all right so
  6093. 3:42:52uh the default policies uh for ufw are
  6094. 3:42:56as follows uh now before we do that let
  6095. 3:42:59me explain something so ufw
  6096. 3:43:01uh by default will it will deny all
  6097. 3:43:04incoming connections but will allow all
  6098. 3:43:06outgoing connections so what is
  6099. 3:43:08happening here is sudo ufw
  6100. 3:43:11and you can you can always use this to
  6101. 3:43:13to restore it to its default policies so
  6102. 3:43:16sudo ufw
  6103. 3:43:18default
  6104. 3:43:20deny
  6105. 3:43:21incoming
  6106. 3:43:23all right so that is the default uh that
  6107. 3:43:25is the default connection for incoming
  6108. 3:43:27or the default connection status for all
  6109. 3:43:29incoming connections so by default ufw
  6110. 3:43:32will deny all incoming connections and
  6111. 3:43:34it will
  6112. 3:43:35it will allow
  6113. 3:43:37all outgoing connections
  6114. 3:43:41so it will allow all default outgoing
  6115. 3:43:43connections and of course you can change
  6116. 3:43:45this to whatever you want if you want
  6117. 3:43:47incoming connections to be allowed while
  6118. 3:43:49the firewall is active then you can also
  6119. 3:43:51do that as well so i can say default
  6120. 3:43:53allow
  6121. 3:43:54incoming all right which is not the
  6122. 3:43:57smartest thing to do if you're running
  6123. 3:43:58this on a server you want to manage what
  6124. 3:44:01connections are incoming
  6125. 3:44:02in case your your server is being
  6126. 3:44:04attacked but that is a very very
  6127. 3:44:05different story and hopefully i'll make
  6128. 3:44:08a video on that later on in configuring
  6129. 3:44:10a server for security
  6130. 3:44:12in this case we'll just leave them to
  6131. 3:44:14its defaults all right which are are
  6132. 3:44:16going to be set by default you don't
  6133. 3:44:17need to set them i'm simply explaining
  6134. 3:44:19to you how to do it and how to change
  6135. 3:44:21them if you want to change them all
  6136. 3:44:22right so this gate is great for normal
  6137. 3:44:24systems uh but when it comes down to
  6138. 3:44:27servers it becomes a little bit
  6139. 3:44:28different and you want to be able to
  6140. 3:44:30manage the incoming connections in
  6141. 3:44:33regards to services and ports and the ip
  6142. 3:44:35addresses that are going to be allowed
  6143. 3:44:37to connect to your computer or your
  6144. 3:44:39server
  6145. 3:44:40all right
  6146. 3:44:41so what i want to do is
  6147. 3:44:43the first thing i want to do is i'm
  6148. 3:44:44going to talk to talk about services and
  6149. 3:44:46ips all right so if i want to allow an
  6150. 3:44:49incoming ssh connection uh how do i do
  6151. 3:44:52that well it's very simple so sudo ufw
  6152. 3:44:56allow ssh all right and this is going to
  6153. 3:44:58allow all ssh connections it's going to
  6154. 3:45:00allow in incoming ssh connections all
  6155. 3:45:03right which is okay if
  6156. 3:45:05as long as you have a private key and
  6157. 3:45:07you've properly secured the ssh
  6158. 3:45:09connection and and the authentication
  6159. 3:45:12all right so i'm going to hit enter it's
  6160. 3:45:13going to tell me rule is updated
  6161. 3:45:15fantastic you can also do this by typing
  6162. 3:45:17in the port so i can say sudo ufw allow
  6163. 3:45:2122 and it's going to update uh the rules
  6164. 3:45:24accordingly now if i want to if i want
  6165. 3:45:26to disable you ssh incoming ssh i can
  6166. 3:45:29say sudo ufw deny
  6167. 3:45:32ssh all right and i'm going to hit enter
  6168. 3:45:34it's going to tell me the rule is
  6169. 3:45:35updated which is which is also very very
  6170. 3:45:37good and of course you can do that
  6171. 3:45:39with the port as well but with services
  6172. 3:45:42these are the particular services the
  6173. 3:45:44services by the name in which they are
  6174. 3:45:46sorted so ssh is going to be known as
  6175. 3:45:48ssh and it knows that ssh uses port 22.
  6176. 3:45:52all right let's talk about uh working
  6177. 3:45:53with port 80 or http connections
  6178. 3:45:56so that is what uh unencrypted web
  6179. 3:45:59servers use and the connections can be
  6180. 3:46:01allowed with the following command so
  6181. 3:46:03you can type in sudo ufw
  6182. 3:46:05uh allow
  6183. 3:46:07allow http and we hit enter it's going
  6184. 3:46:10to update the rules and you can also do
  6185. 3:46:12it with using uh you can also do it
  6186. 3:46:14using the port which is port 80 hit
  6187. 3:46:16enter and there you are in my case i'm
  6188. 3:46:18going to deny this so i'm going to say
  6189. 3:46:20deny http hit enter and we're good again
  6190. 3:46:23all right so what i'm going to do is
  6191. 3:46:26before we actually continue i'm going to
  6192. 3:46:27leave some services running so that when
  6193. 3:46:29i enable the firewall you'll be able to
  6194. 3:46:31see them when i when i essentially check
  6195. 3:46:33the status
  6196. 3:46:34all right so i'm going to say
  6197. 3:46:37ufw
  6198. 3:46:38enable or sorry allow
  6199. 3:46:41allow ssh because i want to allow ssh
  6200. 3:46:44connections
  6201. 3:46:45sorry about that my typing is pretty bad
  6202. 3:46:47right now allow ssh there we are
  6203. 3:46:49fantastic and we can move on to the next
  6204. 3:46:51protocols and services
  6205. 3:46:53now talking about https or port 443 that
  6206. 3:46:56is again uh what encrypted web servers
  6207. 3:46:58use and can be allowed with the
  6208. 3:46:59following command so you can type in
  6209. 3:47:01sudo
  6210. 3:47:03allow https and hit enter and that's
  6211. 3:47:06going to allow https connections again
  6212. 3:47:08that can be replicated or duplicated
  6213. 3:47:10with the port 443 in this case i'm just
  6214. 3:47:13going to deny the connection so i'm just
  6215. 3:47:16going to https and there we are so the
  6216. 3:47:18rules are going to be updated
  6217. 3:47:19successfully for ipv4 and ipv6 as well
  6218. 3:47:22that is why you have rules updated for
  6219. 3:47:24both the protocols over here
  6220. 3:47:26all right now if you want to allow both
  6221. 3:47:28uh http and https you can do that in
  6222. 3:47:32you can do it in one command and that is
  6223. 3:47:33done by typing sudo ufw allow and you
  6224. 3:47:37can also deny it as well so proto the
  6225. 3:47:39protocol is going to be tcp
  6226. 3:47:42proto is tcp you can also change that
  6227. 3:47:44depending on what protocol you're using
  6228. 3:47:45so from any
  6229. 3:47:47from any target or you can also use the
  6230. 3:47:50ip so from this particular target but
  6231. 3:47:53i'll get to that in a second so we're
  6232. 3:47:54going to say from any any computer we
  6233. 3:47:56are simply going to allow the connection
  6234. 3:47:59from any
  6235. 3:48:00to any
  6236. 3:48:02port
  6237. 3:48:03uh to any port and we specify the port
  6238. 3:48:06support 80 and 443 hit enter the rules
  6239. 3:48:09updated so we can also deny it as well
  6240. 3:48:11which is what i'm gonna do because i
  6241. 3:48:12don't want that running so deny and
  6242. 3:48:15voila all right so that is how to run it
  6243. 3:48:17in one command and the the key words
  6244. 3:48:19here are going to be the allow and deny
  6245. 3:48:22that is the most important bit here all
  6246. 3:48:24right if you're talking about ftp that
  6247. 3:48:26is again uftp uh sorry um
  6248. 3:48:28uh ufw nor am i talking ufw
  6249. 3:48:32uh ufw allow ftp or port 21
  6250. 3:48:36and that can also be denoted by port 21
  6251. 3:48:39tcp hit enter and it's going to uh
  6252. 3:48:42because it already exists we can then
  6253. 3:48:44say deny
  6254. 3:48:46and you need to specify with ftp that
  6255. 3:48:48we're using it in tcp so deny rules
  6256. 3:48:51updated successfully and that is how to
  6257. 3:48:53configure or enable and disable ftp
  6258. 3:48:55connections
  6259. 3:48:56all right now let's move on to ip
  6260. 3:48:58addresses now before we actually move on
  6261. 3:49:01to ip addresses four services this is
  6262. 3:49:03all done through the port and also
  6263. 3:49:05through the name so if you're running
  6264. 3:49:06pop3 a pop3 mail server you can also do
  6265. 3:49:09it as well if you're running mysql i can
  6266. 3:49:11say ufw
  6267. 3:49:12allow
  6268. 3:49:143306 that is a mysql a database and i'm
  6269. 3:49:17just going to deny it or i'll leave that
  6270. 3:49:19running so that we can also check the
  6271. 3:49:20status i don't have a mysql server
  6272. 3:49:23running on this computer but that's how
  6273. 3:49:25you one would do it so uh in most cases
  6274. 3:49:27you want to deny connections to your ad
  6275. 3:49:30to your
  6276. 3:49:31to your mysql database so in this case
  6277. 3:49:33i'm going to say 3306 deny any
  6278. 3:49:35connections to that particular port and
  6279. 3:49:37of course i can specify the eyepiece
  6280. 3:49:39with my previous command that i showed
  6281. 3:49:41you right over here so i can say ufw
  6282. 3:49:43deny protocol tcp
  6283. 3:49:45from any to uh
  6284. 3:49:47from any to any port and then specify
  6285. 3:49:493306 here hit enter the rules are going
  6286. 3:49:52to be updated so we can deny all
  6287. 3:49:54connections to our sql database which is
  6288. 3:49:57hugely important that's why you have
  6289. 3:49:59open databases running and available to
  6290. 3:50:01be accessed publicly on show then they
  6291. 3:50:04can simply be exposed so this is one of
  6292. 3:50:05the things you must do on your firewall
  6293. 3:50:08all right so getting back to ip
  6294. 3:50:10addresses again it's very very simple so
  6295. 3:50:12if i want to allow incoming connections
  6296. 3:50:13from a particular ip address i can
  6297. 3:50:15simply type in ufw
  6298. 3:50:17allow and i type in uh the ips so allow
  6299. 3:50:20from
  6300. 3:50:22192.168.1.1 which is my gateway or
  6301. 3:50:24access point iep address which is
  6302. 3:50:26important because if i don't allow
  6303. 3:50:27incoming connections from it
  6304. 3:50:30i essentially won't be able to to get
  6305. 3:50:32any internet access so i'm going to hit
  6306. 3:50:33allow which is important
  6307. 3:50:37and and that's very very important as i
  6308. 3:50:39mentioned when your firewall is active
  6309. 3:50:41because if you want to allow incoming
  6310. 3:50:42connections you need to specify what ip
  6311. 3:50:44or what ip subnet they may belonging to
  6312. 3:50:47so uh what an example i can give you
  6313. 3:50:50here is if you want to specify a
  6314. 3:50:51particular port uh for a particular ip
  6315. 3:50:54address for example i i only want the ip
  6316. 3:50:58address
  6317. 3:50:59192.168.1.103 to access ssh i can type
  6318. 3:51:02in the following so i say sudo ufw
  6319. 3:51:06allow from 192.168.1.103
  6320. 3:51:10to any port
  6321. 3:51:12to any port 22. so this will only allow
  6322. 3:51:15uh this particular ip address to access
  6323. 3:51:18the as this the ssh service i'm going to
  6324. 3:51:20enter it's going to say rules are
  6325. 3:51:22updated now if you're wondering what uh
  6326. 3:51:24the ip address 192.168.1.103
  6327. 3:51:27is my windows operating system and i
  6328. 3:51:30usually connect to my cali operating
  6329. 3:51:31system to it remotely via uh via putty
  6330. 3:51:35all right so that is a good rule to have
  6331. 3:51:38uh when talking about subnets it's very
  6332. 3:51:39very simple again so sudo ufw uh allow
  6333. 3:51:44from and we specify the subnet range
  6334. 3:51:46here 182.968.1.1
  6335. 3:51:49uh and 24 but i don't want to do that
  6336. 3:51:51because i only want particular ip
  6337. 3:51:53addresses
  6338. 3:51:54uh to essentially uh to be allowed in
  6339. 3:51:57regards to incoming connections so i'm
  6340. 3:51:58gonna i'm not gonna hit enter but that
  6341. 3:52:00is how to specify a particular subnet
  6342. 3:52:03you can also disable or deny a
  6343. 3:52:05particular connections
  6344. 3:52:06all right so
  6345. 3:52:08we have already talked about denying uh
  6346. 3:52:10access and again it is all in regards to
  6347. 3:52:13what you want to do in regards to the ip
  6348. 3:52:15so what i can say for example if i
  6349. 3:52:17wanted to allow a particular subnet
  6350. 3:52:19to access the mysql database i can say
  6351. 3:52:22for example
  6352. 3:52:24sudo
  6353. 3:52:25ufw
  6354. 3:52:26allow
  6355. 3:52:28from
  6356. 3:52:29192.68.1.1.1
  6357. 3:52:33and 24 and to any
  6358. 3:52:37any port
  6359. 3:52:39i can say any port
  6360. 3:52:413306 of course that is a very stupid
  6361. 3:52:44thing to do so i'll just keep it to port
  6362. 3:52:4622 with this which is ssh so all of my
  6363. 3:52:48computers in my subnet should be able to
  6364. 3:52:50access this computer via the ssh port
  6365. 3:52:53only i'm going to hit enter and it's
  6366. 3:52:55going to tell me rule change after
  6367. 3:52:56normalization because we already had it
  6368. 3:52:58active so it is changed and updated the
  6369. 3:53:01rule
  6370. 3:53:02all right so let's talk about deleting
  6371. 3:53:03rules because that is essentially as far
  6372. 3:53:05as it will go in regards to allowing in
  6373. 3:53:07denying rules to uh incoming and
  6374. 3:53:10outgoing connections
  6375. 3:53:11to and from your firewall so we've
  6376. 3:53:13looked at allowing and denying ports
  6377. 3:53:15services and ip addresses let's talk
  6378. 3:53:17about deleting particular rules so now
  6379. 3:53:19that we've set our rules we can
  6380. 3:53:21essentially enable the firewall now so
  6381. 3:53:23i'm going to say sudo
  6382. 3:53:25sorry about that sudo
  6383. 3:53:28sudo enable and we type in uh sudo ufw
  6384. 3:53:32enable sorry about that
  6385. 3:53:33ufw enable i was getting a bit confused
  6386. 3:53:36there with ip tables you have w enable
  6387. 3:53:38and that's going to enable the firewall
  6388. 3:53:41excellent so now we can check the status
  6389. 3:53:43all right so the status as i mentioned
  6390. 3:53:44is very very simple to check uh which by
  6391. 3:53:47the way is going to include the number
  6392. 3:53:48status so the default status is sudo ufw
  6393. 3:53:53status
  6394. 3:53:54gonna hit enter and it's gonna give you
  6395. 3:53:56the current status of the firewall all
  6396. 3:53:58right so
  6397. 3:53:59tcp
  6398. 3:54:00is going to be allowed which is port 22
  6399. 3:54:02which is as it is going to be allowed
  6400. 3:54:05which is incoming
  6401. 3:54:07it's going to allow
  6402. 3:54:08tcp our weight we have port 80 deny
  6403. 3:54:11allow for for it again so incoming
  6404. 3:54:14outgoing uh the same goes for what we
  6405. 3:54:17had set for um
  6406. 3:54:20the rule set for both
  6407. 3:54:22uh http and https we had set our ftp
  6408. 3:54:25rule set here we'd set our mysql
  6409. 3:54:28database rule set here to deny
  6410. 3:54:31again we had set it
  6411. 3:54:33via tcp remember it's very important to
  6412. 3:54:35specify the protocol
  6413. 3:54:37uh we then have again we set the rules
  6414. 3:54:39to now a particular iep address remember
  6415. 3:54:42from here they were all from anywhere or
  6416. 3:54:44any particular source
  6417. 3:54:45so allow all connections coming from
  6418. 3:54:48my access point uh allow all ssh
  6419. 3:54:51connections in coming from this
  6420. 3:54:53particular ip
  6421. 3:54:54allow any incoming ssh connections from
  6422. 3:54:57any particular ip in this subnet which i
  6423. 3:54:59set incorrectly it should have been one
  6424. 3:55:01not zero that's my primary
  6425. 3:55:03uh access point that is sitting outside
  6426. 3:55:05of my office
  6427. 3:55:07and then we have all the all these
  6428. 3:55:09settings for uh for the ipv
  6429. 3:55:12ipv6 protocol so that is how to check
  6430. 3:55:14the status now you want to display a bit
  6431. 3:55:16more information we use the verbose
  6432. 3:55:17command
  6433. 3:55:18verbose over here and i'll give you a
  6434. 3:55:20bit more information and this is
  6435. 3:55:22primarily what i like using
  6436. 3:55:24so this is the status that i like using
  6437. 3:55:27the verbose status because it tells you
  6438. 3:55:29the status is active logging is on on
  6439. 3:55:31low
  6440. 3:55:32the default policies are to deny
  6441. 3:55:34incoming and allow outgoing as i
  6442. 3:55:36mentioned
  6443. 3:55:37and now we have for
  6444. 3:55:39for port 22 under the protocol tcp we
  6445. 3:55:42want to allow incoming connections we
  6446. 3:55:44want to allow incoming connections there
  6447. 3:55:46which we is not clever but anyway we had
  6448. 3:55:49set it to any computer on this subnet so
  6449. 3:55:51that makes sense
  6450. 3:55:52we want to deny incoming http
  6451. 3:55:54connections we want to allow then
  6452. 3:55:56incoming http connection and that's
  6453. 3:55:58because i was actually showing you that
  6454. 3:55:59we can actually disable it so
  6455. 3:56:01i can say ufw
  6456. 3:56:04we can say d9
  6457. 3:56:06for 80
  6458. 3:56:07and it's going to update it and we hit
  6459. 3:56:09enter and there we are so now it's it's
  6460. 3:56:11where we're simply denying the rules
  6461. 3:56:12here which is great all right so deny
  6462. 3:56:15deny for both port 80 which is http uh
  6463. 3:56:18for https we are also denying and that's
  6464. 3:56:21simply giving you the the action so
  6465. 3:56:23we're denying or allowing in connections
  6466. 3:56:26and the only ones being allowed inside
  6467. 3:56:28are going to be for the ssh port right
  6468. 3:56:31over here and right over here which are
  6469. 3:56:34going to simply be allowing particular
  6470. 3:56:36ip addresses
  6471. 3:56:38and the entire subnet and all ip
  6472. 3:56:40addresses from the connection now you
  6473. 3:56:41might want to change this if you want to
  6474. 3:56:43only specify a particular subnet
  6475. 3:56:46but that's simply how to check the
  6476. 3:56:48verbose status now if you want to look
  6477. 3:56:50at the numbered status which is
  6478. 3:56:51important because you might want to
  6479. 3:56:52delete a particular rule you do that by
  6480. 3:56:55typing sudo ufw status numbered
  6481. 3:56:57[Applause]
  6482. 3:56:59status numbered
  6483. 3:57:01like so and we hit enter and that is
  6484. 3:57:03going to number all of the rules that
  6485. 3:57:05you had set which is very important if
  6486. 3:57:06you want to delete a particular rule all
  6487. 3:57:08right so let's take a look at how to
  6488. 3:57:10delete a particular rule so if i wanted
  6489. 3:57:12to delete um
  6490. 3:57:14i want to delete
  6491. 3:57:16rule 1 and 2 i can do that so i can type
  6492. 3:57:18in sudo ufw delete
  6493. 3:57:22and i simply type in one for example and
  6494. 3:57:24that is going to ask me do i want to
  6495. 3:57:25delete this particular rule i'm going to
  6496. 3:57:27hit yes and then i'm going to i want to
  6497. 3:57:29delete rule 2 as well and yes and if we
  6498. 3:57:32check the these these status the verbose
  6499. 3:57:35status here we can see yes now we are
  6500. 3:57:38talking now we have uh we we have
  6501. 3:57:40correctly set up our our firewall here
  6502. 3:57:42so it's going to allow
  6503. 3:57:44uh allow in connections we can also get
  6504. 3:57:46rid of that one as well so we're going
  6505. 3:57:48to simply display the status here the
  6506. 3:57:50number status so let's get rid of 1 as
  6507. 3:57:52well
  6508. 3:57:541 here yes we want to get rid of that
  6509. 3:57:57and we showed the status once more
  6510. 3:58:00we can see that yes we are denying all
  6511. 3:58:02connections all http connections all
  6512. 3:58:05https connections and we also set this
  6513. 3:58:08rule which is a duplicate rule of both
  6514. 3:58:09these two so i'm showing you how to do
  6515. 3:58:11it really shortly uh we are denying ftp
  6516. 3:58:13we are denying uh mysql access
  6517. 3:58:17via tcp and also the the port whether it
  6518. 3:58:19be on tcp or udp irregardless the only
  6519. 3:58:22ones we're allowing inside are going to
  6520. 3:58:24be connections coming from this
  6521. 3:58:26particular ip which is the access point
  6522. 3:58:29and this particular ip which is my
  6523. 3:58:30windows operating system and that is
  6524. 3:58:32going to be going to be allowed on port
  6525. 3:58:3322
  6526. 3:58:35uh and the entire subnet is going to be
  6527. 3:58:37allowed on port 22 which is really
  6528. 3:58:39redundant because i should have just
  6529. 3:58:40gotten rid of this one right over here
  6530. 3:58:42but regardless that is how to delete uh
  6531. 3:58:45the particular rules and if you want to
  6532. 3:58:46reset it again resetting it is very very
  6533. 3:58:48simple to take it back to the defaults
  6534. 3:58:50that if is if you have messed up your
  6535. 3:58:53rule set and you want to just start over
  6536. 3:58:55fresh so sudo
  6537. 3:58:57ufw
  6538. 3:58:59reset and we hit enter it's going to ask
  6539. 3:59:01you yes
  6540. 3:59:02and remember the firewall is still
  6541. 3:59:04active so if i just check the status
  6542. 3:59:06it's going to tell us that it is
  6543. 3:59:08inactive that's because we reset it so
  6544. 3:59:10uh if we we uh we enable it so ufw
  6545. 3:59:14enable
  6546. 3:59:16and uh we'll then check the status right
  6547. 3:59:19now we have or we don't have any rule
  6548. 3:59:21set so that is how to use ufw or the
  6549. 3:59:24uncomplicated firewall to allow incoming
  6550. 3:59:26and outgoing connections to ports
  6551. 3:59:29from ip addresses particular ip
  6552. 3:59:30addresses their services how to delete
  6553. 3:59:33particular rules and how to monitor the
  6554. 3:59:35current rules that you have set up so
  6555. 3:59:37that is pretty much all you need to know
  6556. 3:59:38in regards to getting started and and
  6557. 3:59:40fully utilizing ufw you know in in
  6558. 3:59:43regards to configuring a particular
  6559. 3:59:44operating system or a server if that's
  6560. 3:59:46what you're working with so
  6561. 3:59:52in this video i'll be showing you how to
  6562. 3:59:53clear your tracks on linux operating
  6563. 3:59:55systems with a variety of tools all
  6564. 3:59:58right so why is this important now if
  6565. 4:00:00you're a penetration tester you probably
  6566. 4:00:02already know why this is important well
  6567. 4:00:04covering tracks or clearing your tracks
  6568. 4:00:06is the final stage of penetration of the
  6569. 4:00:08penetration testing process so just
  6570. 4:00:10before you start report writing and that
  6571. 4:00:12video is on its way by the way so do
  6572. 4:00:15stay tuned for that so clearing your
  6573. 4:00:17tracks essentially involves clearing or
  6574. 4:00:19wiping all the activity of an attacker
  6575. 4:00:21or you being the attacker that is so as
  6576. 4:00:24to avoid any detection by incident
  6577. 4:00:26response teams or forensic teams all
  6578. 4:00:29right so it is vitally important in the
  6579. 4:00:31penetration testing life cycle
  6580. 4:00:33and of course if you look at it from a
  6581. 4:00:35defensive point of view it can really
  6582. 4:00:37test incident handlers and the blue team
  6583. 4:00:39in their ability to discover an attacker
  6584. 4:00:42in in the system whether they do have an
  6585. 4:00:45intrusion detection detection system or
  6586. 4:00:47not and of course from the perspective
  6587. 4:00:49of the forensics teams it can also test
  6588. 4:00:52them in uh sort of analyzing their skill
  6589. 4:00:54and finding what the attack the attacker
  6590. 4:00:56may have left behind in regards to logs
  6591. 4:00:59uh files or backdoors that they may have
  6592. 4:01:01left running any user accounts that they
  6593. 4:01:03were using etc so this is usually or
  6594. 4:01:06commonly the biggest mistake vector that
  6595. 4:01:08an attacker makes all right or that is
  6596. 4:01:10associated with with attackers and it's
  6597. 4:01:12something that has been ignored over the
  6598. 4:01:14years which is really really weird
  6599. 4:01:15because if you read or pick up any
  6600. 4:01:16penetration testing book
  6601. 4:01:18when they essentially explain the
  6602. 4:01:20penetration testing
  6603. 4:01:22cycle or the stages of penetration
  6604. 4:01:24testing uh clearing your tracks is one
  6605. 4:01:26of them just before you actually write
  6606. 4:01:28up your report and of course if you're
  6607. 4:01:30an attacker this is the final stage of
  6608. 4:01:33uh of your attack and of course leaving
  6609. 4:01:34some persistence behind but that's
  6610. 4:01:36another video for another time
  6611. 4:01:39so
  6612. 4:01:39it's it's very very sad to see that this
  6613. 4:01:41is not taken into consideration i'm not
  6614. 4:01:43talking about this from an attacker's
  6615. 4:01:45perspective but also from a blue team
  6616. 4:01:47perspective where uh this is something
  6617. 4:01:49that is very easy for them because
  6618. 4:01:51attackers are very very sloppy they they
  6619. 4:01:53haven't taken it into consideration so
  6620. 4:01:56it's really good to essentially
  6621. 4:01:57understand how this is done and how it
  6622. 4:01:59can be
  6623. 4:02:00and how it can be analyzed from both
  6624. 4:02:02perspectives from a red team and a blue
  6625. 4:02:04team perspective so
  6626. 4:02:05uh this is usually as i've said the
  6627. 4:02:07biggest mistake of an attacker and this
  6628. 4:02:09is where the professional attackers are
  6629. 4:02:11sorted out from the amateurs so if you
  6630. 4:02:13take a look at most of the biggest hacks
  6631. 4:02:15in the world over the last two years
  6632. 4:02:17most of the the detection has been made
  6633. 4:02:19really really easily from the malware
  6634. 4:02:21that they have left behind which they
  6635. 4:02:23didn't clear they should have cleared
  6636. 4:02:24but of course they were setting it up
  6637. 4:02:26for persistence as i said that's a video
  6638. 4:02:29for another time but again also masking
  6639. 4:02:31malware or backdoors is also a vital or
  6640. 4:02:34an important piece of uh of the forensic
  6641. 4:02:37or well not the forensic the post
  6642. 4:02:38exploitation
  6643. 4:02:40all right now when we talk about uh the
  6644. 4:02:42attacker's perspective uh he or she
  6645. 4:02:45usually needs to
  6646. 4:02:46evade detection if there is an intrusion
  6647. 4:02:48detection system therefore preventing
  6648. 4:02:50any incident response and then he or she
  6649. 4:02:53needs to clear the logs or back doors
  6650. 4:02:55that can be discovered by the forensics
  6651. 4:02:57team all right so what an attacker is
  6652. 4:02:59looking to do and should do is first of
  6653. 4:03:02all clear logs modify registries or
  6654. 4:03:05clear any of the registries that they
  6655. 4:03:07did create and lastly remove any files
  6656. 4:03:10or user accounts that they might have
  6657. 4:03:11been using all right now as i've said
  6658. 4:03:14for this particular video we'll be
  6659. 4:03:15focusing on linux i also want to make an
  6660. 4:03:17independent video for windows because it
  6661. 4:03:19is vitally important to understand how
  6662. 4:03:21to do so on both these operating systems
  6663. 4:03:24and also probably take a look at mac os
  6664. 4:03:27as that is also getting quite uh quite
  6665. 4:03:29popular especially for penetration
  6666. 4:03:31testers
  6667. 4:03:32so i'm going to be covering the
  6668. 4:03:33fundamentals and you can do a lot of
  6669. 4:03:35your own research i'll be covering the
  6670. 4:03:36tools that i've personally used before
  6671. 4:03:40and
  6672. 4:03:41really uh the last piece that i want to
  6673. 4:03:43actually tell you is clearing your
  6674. 4:03:44tracks will also depend on the
  6675. 4:03:46privileges that you have on the system
  6676. 4:03:49and whether or not you're remotely
  6677. 4:03:50attacking the system but for linux it is
  6678. 4:03:52quite universal
  6679. 4:03:54all right now i also have a little or a
  6680. 4:03:56quick tool that i'll be sharing with you
  6681. 4:03:57at the end of the video that is an a
  6682. 4:03:59forensics tool or an anti-forensics tool
  6683. 4:04:01for windows so you can definitely check
  6684. 4:04:03that out
  6685. 4:04:04i'll probably make another video of it
  6686. 4:04:05but for now let's focus on linux all
  6687. 4:04:07right so let's talk about the linux log
  6688. 4:04:10files which are the most important
  6689. 4:04:11aspects
  6690. 4:04:12uh of uh of persistence or activity that
  6691. 4:04:15is being logged on the linux operating
  6692. 4:04:17system or the linux kernel
  6693. 4:04:19all right so your the log files on any
  6694. 4:04:21linux system can be found on in the var
  6695. 4:04:25well actually let me just change
  6696. 4:04:26directory into that so cd var and it is
  6697. 4:04:29stored in the log directory right over
  6698. 4:04:31here so now that i'm in the directory i
  6699. 4:04:33can list all the files in here
  6700. 4:04:35and these are all the log files that
  6701. 4:04:37currently exist and of course if you
  6702. 4:04:39just read their name they're pretty
  6703. 4:04:40self-explanatory they have all they they
  6704. 4:04:43have they're all they all have their
  6705. 4:04:45various use cases and what data they are
  6706. 4:04:48essentially logging all right so for
  6707. 4:04:50example when talking about uh the
  6708. 4:04:52auth.log file this stores authentication
  6709. 4:04:55logs uh let's see if
  6710. 4:04:57let's see if we can find the kernel if
  6711. 4:04:59we can find yet there we are the
  6712. 4:05:00kernel.log file which essentially stores
  6713. 4:05:03all the kernel logs you then have the
  6714. 4:05:05mail server logs which is of course uh i
  6715. 4:05:08don't think we have a mail server here
  6716. 4:05:09but if we did you'd have the mail server
  6717. 4:05:12logs as well you then have the system
  6718. 4:05:14bootlog which is your boot your boot log
  6719. 4:05:16which again we don't have here for some
  6720. 4:05:18reason
  6721. 4:05:20we then have um
  6722. 4:05:22you have your http the httpd log which
  6723. 4:05:25essentially has logs for your web server
  6724. 4:05:27if you do have a web server
  6725. 4:05:29or a web server that being the apache
  6726. 4:05:31web server so again there are a lot of
  6727. 4:05:33log files here we're going to be
  6728. 4:05:34focusing on the auth log right of you
  6729. 4:05:37which essentially contains the
  6730. 4:05:38authentication logs and then we'll take
  6731. 4:05:40a look at the bash history file which is
  6732. 4:05:43very important as well we'll also take a
  6733. 4:05:44look at the shred file as well so
  6734. 4:05:47let's talk about the shred file and the
  6735. 4:05:50the the auth dot log file
  6736. 4:05:52all right so if i'm just to open up the
  6737. 4:05:54auth.log file here this essentially
  6738. 4:05:56stores all the uh the authentication
  6739. 4:05:59logs which are very very important for
  6740. 4:06:01to a forensics team uh to essentially
  6741. 4:06:03analyze what was happening to the system
  6742. 4:06:05what activities were carried out etc etc
  6743. 4:06:09all right so you can go ahead and
  6744. 4:06:10analyze all all of the files right over
  6745. 4:06:13here and get an idea of of essentially
  6746. 4:06:16uh what was going on and of course that
  6747. 4:06:18is uh
  6748. 4:06:19that deserves its own video in its own
  6749. 4:06:22right because that is more of a
  6750. 4:06:23forensics type of video
  6751. 4:06:25but for now we're looking to get rid of
  6752. 4:06:27this because remember if you're an
  6753. 4:06:28attacker you want to get rid of all of
  6754. 4:06:30these files so that uh they really
  6755. 4:06:32cannot build an idea of what was going
  6756. 4:06:34on on the system all right so let me
  6757. 4:06:37just exit out of this and as i said the
  6758. 4:06:40tool that is most recommended for any of
  6759. 4:06:42this getting erasing files erasing hard
  6760. 4:06:45drives is shred now if you haven't heard
  6761. 4:06:47of shred shred is essentially a tool
  6762. 4:06:49that allows you to delete uh or erase a
  6763. 4:06:52file permanently so it allows you to
  6764. 4:06:54delete files data permanently now many
  6765. 4:06:57of you might be confused with saying wow
  6766. 4:06:58why can't you just delete it well if you
  6767. 4:07:00delete a file
  6768. 4:07:02it can be recovered and i'll explain
  6769. 4:07:03this in a second so shred allows you to
  6770. 4:07:06delete files and data permanently and
  6771. 4:07:07prevents the recovery of that data
  6772. 4:07:10it does this because it over it
  6773. 4:07:12overwrites the file multiple times with
  6774. 4:07:14ones and zeros now when you
  6775. 4:07:16traditionally delete a file with your
  6776. 4:07:19graphical user interface or you simply
  6777. 4:07:21hit the delete a key on your keyboard
  6778. 4:07:23what's happening here
  6779. 4:07:25is your file isn't being deleted it is
  6780. 4:07:27simply marked as a space in which data
  6781. 4:07:30can be written to or data can be written
  6782. 4:07:32on top of therefore replacing the
  6783. 4:07:34previous data and of course this is
  6784. 4:07:35going to be dependent on how you use the
  6785. 4:07:37computer and that's why when you you see
  6786. 4:07:39these real amateurs are doing
  6787. 4:07:41questionable things on their computer
  6788. 4:07:43you know doing illegal stuff on the
  6789. 4:07:44computer
  6790. 4:07:46just delete the file without even
  6791. 4:07:48realizing that you aren't deleting it is
  6792. 4:07:50deleted for you the user but uh in the
  6793. 4:07:53back end the file still exists it's
  6794. 4:07:55simply marked that the sector is simply
  6795. 4:07:57marked as a as a space that should be
  6796. 4:08:01written onto us and when it's written
  6797. 4:08:03onto then the files are lost but you can
  6798. 4:08:05still perform a lot of data recovery
  6799. 4:08:07that's why you have an industry
  6800. 4:08:09dedicated to data recovery because of
  6801. 4:08:11how operating systems are and how they
  6802. 4:08:13uh they essentially mark spaces or data
  6803. 4:08:16that you won't delete it there's spaces
  6804. 4:08:17that can be overwritten all right so
  6805. 4:08:19that is the difference between keeping
  6806. 4:08:21files and maintaining uh the fact that
  6807. 4:08:23they cannot be written to
  6808. 4:08:25or overwritten that is
  6809. 4:08:27by other files and and
  6810. 4:08:29when you actually hit delete so when we
  6811. 4:08:32talk about a tool like shred shred is a
  6812. 4:08:34tool that i've used a lot of times
  6813. 4:08:36before for wiping or erasing hard drives
  6814. 4:08:39when i'm when i'm done with them when
  6815. 4:08:41i'm disposing them or when i'm selling
  6816. 4:08:42drives which is very very rare never
  6817. 4:08:45sell your drives
  6818. 4:08:47all right so shred comes pre-installed
  6819. 4:08:49in kali linux and i'm guessing in pretty
  6820. 4:08:50much all the other distributions so i'm
  6821. 4:08:53just going to clear this out and what
  6822. 4:08:54we're going to do is we're just going to
  6823. 4:08:56open up shred here with the help command
  6824. 4:08:59and the shred tool is quite
  6825. 4:09:01comprehensive and i'll try and explain
  6826. 4:09:03all the commands
  6827. 4:09:04all right so the shred command
  6828. 4:09:06essentially when you when you're writing
  6829. 4:09:08to a file or a particular drive it uh
  6830. 4:09:11it essentially overwrites the specified
  6831. 4:09:14files repeatedly and therefore making it
  6832. 4:09:16difficult or impossible for uh you know
  6833. 4:09:19hardware software or software recovery
  6834. 4:09:21to to get the data back all right so the
  6835. 4:09:24options or the parameters that you can
  6836. 4:09:25specify
  6837. 4:09:26with the shred tool are as follows you
  6838. 4:09:28have the f the f command which
  6839. 4:09:30essentially allows you to change
  6840. 4:09:32permissions to allow writing if needed
  6841. 4:09:34you have the n command which is the
  6842. 4:09:35iterations or essentially this allows
  6843. 4:09:38you to overwrite the amount of times you
  6844. 4:09:40want which is which is good the default
  6845. 4:09:42amount of times is three which is okay
  6846. 4:09:44but if you're really paranoid about you
  6847. 4:09:46know about your files and you really
  6848. 4:09:48want to get rid of them you can increase
  6849. 4:09:50the amount of times all the iterations
  6850. 4:09:52then have the size uh the size of the
  6851. 4:09:54number of bytes to shred you then have
  6852. 4:09:56the u command which is essentially
  6853. 4:09:58allows you to
  6854. 4:09:59uh to truncate uh it essentially
  6855. 4:10:01truncates and remove the files after
  6856. 4:10:03overwriting you then have the v command
  6857. 4:10:05over here which shows your progress over
  6858. 4:10:07both uh shows verbose information about
  6859. 4:10:09the progress you then have the x command
  6860. 4:10:12right over here which essentially
  6861. 4:10:14uh this what this does is again is it's
  6862. 4:10:17self-explanatory but this does not round
  6863. 4:10:19the files up to the next full block
  6864. 4:10:22uh we then have the z command which adds
  6865. 4:10:24the final overwrite with zeros to hide
  6866. 4:10:26shredding so it uh usually with uh
  6867. 4:10:29with software recovery tools they can
  6868. 4:10:31actually detect if there was shredding
  6869. 4:10:33done and this prevents that and you have
  6870. 4:10:35u the u command which essentially
  6871. 4:10:37removes the file after threading which
  6872. 4:10:39is what we're going to be taking a look
  6873. 4:10:40at as well
  6874. 4:10:42all right so let's take a look at the
  6875. 4:10:43command that we'll be using and i'll
  6876. 4:10:45explain what's going on
  6877. 4:10:47all right so we'll be using the vfzu
  6878. 4:10:49command which if we just look at the
  6879. 4:10:51arguments here we are going to be using
  6880. 4:10:53the v so verbose v
  6881. 4:10:55f z u so f we're going to force to
  6882. 4:10:58change the permissions if they exist so
  6883. 4:11:00if you don't have read and write
  6884. 4:11:01permissions is going to force it
  6885. 4:11:03uh so uh there we are so z uh we're
  6886. 4:11:06going to use the v f z u so then z is
  6887. 4:11:09going to be essentially add a final
  6888. 4:11:10override with zeros to hide the
  6889. 4:11:12shredding process which is good and we
  6890. 4:11:14are going to remove the file uh after or
  6891. 4:11:17after the overwriting process all right
  6892. 4:11:19so that is what is going on here so to
  6893. 4:11:21do that we simply type in shred
  6894. 4:11:24and after shred we type in our commands
  6895. 4:11:26or the combination of commands so
  6896. 4:11:28vfzu and the file which is auth.log and
  6897. 4:11:32i'm going to hit enter and there we are
  6898. 4:11:34all right so shred it's going to start
  6899. 4:11:36the shredding process right over here
  6900. 4:11:37and you can see shred uh authored logo
  6901. 4:11:40was renamed to zero zero zero et cetera
  6902. 4:11:42renamed renamed renamed all the way to
  6903. 4:11:44uh to the fact that the file was removed
  6904. 4:11:47or destroyed all right so that gets rid
  6905. 4:11:49of the auth.log file which essentially
  6906. 4:11:52gets rid of the authentication logs very
  6907. 4:11:54very simple you can take a look at all
  6908. 4:11:56the other logs and of course you might
  6909. 4:11:58want to get rid of all the other logs
  6910. 4:12:00that
  6911. 4:12:00that might have existed before or in the
  6912. 4:12:03fact in in regards to the services that
  6913. 4:12:05you might have used so for example if
  6914. 4:12:07you used mac changer which is quite rare
  6915. 4:12:09you might want to get rid of that log
  6916. 4:12:11file the kernel log file which is right
  6917. 4:12:13over here so
  6918. 4:12:14if we open it up
  6919. 4:12:16kernel.log
  6920. 4:12:18and there we are these are all the log
  6921. 4:12:19files in regards to the to the kernel so
  6922. 4:12:22again this is a file that you might want
  6923. 4:12:23to get rid of or you can simply edit
  6924. 4:12:25what you don't want in any of these log
  6925. 4:12:27files so as to to to sort of throw off
  6926. 4:12:31the forensic themes or off of your back
  6927. 4:12:33to essentially make it look really
  6928. 4:12:35really traditional all right so that is
  6929. 4:12:37how to clear your log files of course
  6930. 4:12:39you can use shred for deleting any other
  6931. 4:12:42file this is a video not it's not
  6932. 4:12:43designed to be uh to be about shred but
  6933. 4:12:46there you go you can use shred to erase
  6934. 4:12:48files uh permanently all right so do be
  6935. 4:12:51careful with it as well now let's talk
  6936. 4:12:53about bash history which is a video that
  6937. 4:12:55most of you guys requested me to to talk
  6938. 4:12:58about now bash history essentially keeps
  6939. 4:13:00a record of all the commands that were
  6940. 4:13:02executed by a user on the linux command
  6941. 4:13:05line
  6942. 4:13:06now this is very very important because
  6943. 4:13:09the uh the bash history is a is a file
  6944. 4:13:11that is kept uh
  6945. 4:13:13usually separated for each individual
  6946. 4:13:15user on the linux system so if you are
  6947. 4:13:18the root user you have your own bash
  6948. 4:13:19history file if there was a user called
  6949. 4:13:22alexis he will also have his own bash
  6950. 4:13:24history file you get the idea so
  6951. 4:13:27the directory in which it is stored in
  6952. 4:13:29is in the home user the user that being
  6953. 4:13:32the user that you are using
  6954. 4:13:34and the file is the dot bash history
  6955. 4:13:37file
  6956. 4:13:38all right so i'll get to that in a
  6957. 4:13:39second so if there was a user
  6958. 4:13:42let me just go back into the root
  6959. 4:13:43directory and this is where it is stored
  6960. 4:13:45so if you do have a user it is stored in
  6961. 4:13:47the
  6962. 4:13:48home and the username so this is where
  6963. 4:13:50you put in the username and it is stored
  6964. 4:13:52under the bash history file right over
  6965. 4:13:54here
  6966. 4:13:55all right
  6967. 4:13:56so that is if you are using a particular
  6968. 4:13:59use on the system which is quite obvious
  6969. 4:14:01but if you do have root privileges then
  6970. 4:14:03it's also important but you essentially
  6971. 4:14:04want to get rid of all the bash history
  6972. 4:14:06because this will essentially give
  6973. 4:14:08forensics teams a list of all of what
  6974. 4:14:11you did on that system
  6975. 4:14:13all right so let me actually show you
  6976. 4:14:15how this can be analyzed so i'm just
  6977. 4:14:17going to open up nano here and since i'm
  6978. 4:14:19in the root directory i think i should
  6979. 4:14:20have the there we are the bash history
  6980. 4:14:22file
  6981. 4:14:24uh now i personally have a lot of
  6982. 4:14:26important information in there so i'm
  6983. 4:14:28going to simply show you how to get to
  6984. 4:14:31wipe it all right now wiping it you can
  6985. 4:14:33also use shred if you want to but i
  6986. 4:14:35don't recommend doing that because again
  6987. 4:14:37you're really starting to
  6988. 4:14:39you're helping the forensic team build
  6989. 4:14:42uh an idea of what type of attacker
  6990. 4:14:44they're dealing with so i would
  6991. 4:14:45recommend keeping things as normal as
  6992. 4:14:47possible
  6993. 4:14:48all right so if you you can also use the
  6994. 4:14:50null redirect to clear the file which is
  6995. 4:14:52what i'm going to do so you can
  6996. 4:14:53essentially use the null redirect as
  6997. 4:14:55follows so
  6998. 4:14:56bash history
  6999. 4:14:58and uh as on once i hit enter it will
  7000. 4:15:00essentially clear the file because i'm
  7001. 4:15:02using null redirect so it's essentially
  7002. 4:15:04clearing the entire file so
  7003. 4:15:06bash history let me open up the file
  7004. 4:15:08sorry
  7005. 4:15:09nano
  7006. 4:15:10uh and um
  7007. 4:15:13bash
  7008. 4:15:14history as follows and there we are so
  7009. 4:15:15it's empty now you might be wondering
  7010. 4:15:17well it is empty but did it contain
  7011. 4:15:19anything well if we start using the
  7012. 4:15:21terminal here which uh am i currently
  7013. 4:15:23using this so i'm using terminator
  7014. 4:15:25uh yeah there we are so i was using a
  7015. 4:15:27material session i was just working on a
  7016. 4:15:29few hack the box videos which will also
  7017. 4:15:31be coming out so don't worry about that
  7018. 4:15:33so if i was to do your sudo apt get
  7019. 4:15:36update
  7020. 4:15:38there is a command that i did run and we
  7021. 4:15:40try and open up the bash history file
  7022. 4:15:42right over here and we'll let we let
  7023. 4:15:44that running and that is in my uh
  7024. 4:15:47terminator session all right so let's
  7025. 4:15:48open it up one more time and uh for some
  7026. 4:15:51reason it isn't showing up well we have
  7027. 4:15:52to wait for the command to execute so
  7028. 4:15:54uh let me just wait for that to execute
  7029. 4:15:56so i'll get back to you when this is
  7030. 4:15:58done
  7031. 4:16:00alrighty i'm back i've essentially just
  7032. 4:16:02ran a few commands i was just doing a
  7033. 4:16:04bit of metasploit work i was using
  7034. 4:16:07messer venom all that good stuff because
  7035. 4:16:09i really wanted to show you how much
  7036. 4:16:10information the bash history file can
  7037. 4:16:13uh can actually reveal so let me just
  7038. 4:16:15open it up one more time here
  7039. 4:16:17and my terminal always lags out when i
  7040. 4:16:20resume a video which is really weird
  7041. 4:16:21something to do with my processor let me
  7042. 4:16:23know if you guys know what's going on
  7043. 4:16:25here alright so bash
  7044. 4:16:28bash history like so when we hit enter
  7045. 4:16:30and there you are so you can see that i
  7046. 4:16:32was doing uh some very interesting
  7047. 4:16:34things here
  7048. 4:16:35so i went to my desktop i created a
  7049. 4:16:38payload the message venom i copied the
  7050. 4:16:42uh the payload to my apache directory i
  7051. 4:16:45restarted apache
  7052. 4:16:47uh looks like i removed a motility
  7053. 4:16:50installation i also removed an
  7054. 4:16:52index.html file
  7055. 4:16:54uh well i cleared the terminal i'm
  7056. 4:16:58actually missed i misspelled so yeah
  7057. 4:17:00this reveals a lot of information about
  7058. 4:17:02what the attacker was doing or what a
  7059. 4:17:04particular user was doing on the system
  7060. 4:17:06so
  7061. 4:17:07so there you go and it'll also tell you
  7062. 4:17:09that your attacker has really bad typing
  7063. 4:17:12skills and really makes a lot of
  7064. 4:17:13spelling mistakes so yeah you can pretty
  7065. 4:17:15much get an idea of what exactly is
  7066. 4:17:18going on here
  7067. 4:17:19all right so that's pretty much going to
  7068. 4:17:21be it for this video guys thank you so
  7069. 4:17:23much for watching
  7070. 4:17:24if you have any questions or suggestions
  7071. 4:17:26let me know in the comment section on my
  7072. 4:17:28social networks on my website and i'll
  7073. 4:17:30be seeing you in the next video peace
  7074. 4:17:32guys
  7075. 4:17:36[Music]
  7076. 4:17:47hey guys in this video we're going to be
  7077. 4:17:49taking a look at ssh brute force
  7078. 4:17:51protection with fail to ban now before
  7079. 4:17:53we actually get started with setting it
  7080. 4:17:55up let's get a bit of an understanding
  7081. 4:17:57as to what this tool is and how we can
  7082. 4:17:58use it
  7083. 4:18:00for ssh brute force protection all right
  7084. 4:18:02so what is fail to ban filter ban is an
  7085. 4:18:04intrusion prevention framework that's
  7086. 4:18:06written in python
  7087. 4:18:08and that protects linux systems and
  7088. 4:18:09servers from brute force attacks now
  7089. 4:18:11these are not limited to ssh but the
  7090. 4:18:13scope of this video is going to be based
  7091. 4:18:15around ssh as the primary service that
  7092. 4:18:18is going to be protected uh you know
  7093. 4:18:19from brute force attacks
  7094. 4:18:21all right so it allows you to monitor
  7095. 4:18:23the strength and the frequency of
  7096. 4:18:24attacks and then from that you can sort
  7097. 4:18:26of create various jails that you can use
  7098. 4:18:29and you can sort of customize your the
  7099. 4:18:32strength of the defense you want to set
  7100. 4:18:34up based on the attacks you're getting
  7101. 4:18:36and of course fail to ban can be set up
  7102. 4:18:38to block ip addresses automatically
  7103. 4:18:40based on specific parameters more of
  7104. 4:18:42which i'll explain as we move along all
  7105. 4:18:44right so the great thing about fail the
  7106. 4:18:46ban is that it automates the process of
  7107. 4:18:48protecting your server
  7108. 4:18:50or your ssh from brute force attacks
  7109. 4:18:52alright so
  7110. 4:18:53let's get started all right now that we
  7111. 4:18:56have an understanding of what fail to
  7112. 4:18:57ban is and how we can use it to protect
  7113. 4:19:00our servers you know from brute force
  7114. 4:19:02attacks on ssh
  7115. 4:19:04let's take a look at the infrastructure
  7116. 4:19:05we'll be using in this video
  7117. 4:19:07so for the purpose of this video i've
  7118. 4:19:08just set up a quick
  7119. 4:19:10a quick server here with linux and i'll
  7120. 4:19:12just copy the ip address it's just a
  7121. 4:19:14simple ubuntu server and they'll
  7122. 4:19:16demonstrate how powerful filthban
  7123. 4:19:18actually is so i'll just open up a
  7124. 4:19:20terminal here and we can try and log
  7125. 4:19:22into this server right now i haven't set
  7126. 4:19:24any any other user account so we'll be
  7127. 4:19:26logging as the root user
  7128. 4:19:27and let me just enter the password here
  7129. 4:19:30and that should log us in immediately so
  7130. 4:19:32the first thing i want to do is i want
  7131. 4:19:34to update
  7132. 4:19:35the packages because we do need to
  7133. 4:19:36install fail to ban all right so i'm
  7134. 4:19:38just going to say upgrade update here
  7135. 4:19:40and we do need to run sudo there because
  7136. 4:19:43we're already using the root user but in
  7137. 4:19:45any case
  7138. 4:19:46let's just update the packages here or
  7139. 4:19:48the repositories sorry not our packages
  7140. 4:19:52now filter ban is completely free to use
  7141. 4:19:55and you know you can install it through
  7142. 4:19:56most of your popular package managers in
  7143. 4:19:58our case we're just going to use the
  7144. 4:19:59aptitude package manager so as a apt-get
  7145. 4:20:03install and we're going to say fail to
  7146. 4:20:05pan and we hit enter
  7147. 4:20:07and that is going to prompt us to
  7148. 4:20:09download about 18.7 megabytes and we're
  7149. 4:20:12just gonna let that install
  7150. 4:20:13uh this shouldn't take uh too much time
  7151. 4:20:16and we can see we do have a sim link
  7152. 4:20:18created here that's very important for
  7153. 4:20:19the filter band service so one of the
  7154. 4:20:22first things we need to do is we need to
  7155. 4:20:23ensure that we have enabled fail to ban
  7156. 4:20:25to run on on system startup so in the
  7157. 4:20:27event you do reboot your server uh you
  7158. 4:20:30need to make sure that filter ban you
  7159. 4:20:31know runs
  7160. 4:20:32directly on the startup or during the
  7161. 4:20:34startup so to do this we'll use a
  7162. 4:20:36systemd so system control and we'll say
  7163. 4:20:39um enable
  7164. 4:20:41uh of course we're gonna say fill to ban
  7165. 4:20:44and the service is actually called fail
  7166. 4:20:46to ban dot service so we're gonna hit
  7167. 4:20:48enter
  7168. 4:20:48and as you can see it's gonna say
  7169. 4:20:50synchronizing the state of the
  7170. 4:20:51filterband service with the csv
  7171. 4:20:54service script uh so irregardless of
  7172. 4:20:56whether we used systemd
  7173. 4:20:59so
  7174. 4:21:00what we can do now is we can start
  7175. 4:21:02taking a look at the configuration files
  7176. 4:21:04right now the configuration files
  7177. 4:21:07for failed ban are going to be found in
  7178. 4:21:09the etsy uh they're in the etsy
  7179. 4:21:11directory so we can say um let's just
  7180. 4:21:13list all the files etsy
  7181. 4:21:15fail to ban and we hit enter and let's
  7182. 4:21:17take a look at these configuration files
  7183. 4:21:19so the most important one that you want
  7184. 4:21:21you want to be familiar with is are
  7185. 4:21:23going to be the jail dot conf file and
  7186. 4:21:25the filterband.com file or the
  7187. 4:21:27filterband.com file is a file we'll not
  7188. 4:21:29be taking a look at
  7189. 4:21:30uh in this video but we're taking a look
  7190. 4:21:32at the actual jail.configuration file
  7191. 4:21:34now uh uh if a fairly frequent or common
  7192. 4:21:38term that you'll be hearing uh you know
  7193. 4:21:40that will hear being mentioned when
  7194. 4:21:41talking about fail the ban is the use of
  7195. 4:21:43jails all right so what is a jail in
  7196. 4:21:46filter ban well a jail is essentially a
  7197. 4:21:48configuration file
  7198. 4:21:50that you know contains filters or
  7199. 4:21:52arguments that protect your system or a
  7200. 4:21:54particular service now by default all
  7201. 4:21:57your jails for particular services are
  7202. 4:22:00going to be in the jail.conf file
  7203. 4:22:02alright so if i just get the contents or
  7204. 4:22:04let's actually view the entire file we
  7205. 4:22:06can say um
  7206. 4:22:08let me move into the directory so it's
  7207. 4:22:10much easier for us to work there
  7208. 4:22:12so we can say less and we say
  7209. 4:22:15jail
  7210. 4:22:17jl.conf and we hit enter uh you can
  7211. 4:22:20pretty much see that first of all it
  7212. 4:22:21tells you that uh this is not the uh the
  7213. 4:22:24appropriate way of actually creating or
  7214. 4:22:27modifying the already preset jails the
  7215. 4:22:29reason being is this we should actually
  7216. 4:22:31create another jail.configuration file
  7217. 4:22:34uh with the local extension so you can
  7218. 4:22:36see in most of the cases you should not
  7219. 4:22:38modify this file but provide
  7220. 4:22:39customizations in the jail.loc of the
  7221. 4:22:42gel.local file or you can create
  7222. 4:22:45separate.con files under the jl.d
  7223. 4:22:47directory something we're not going to
  7224. 4:22:48be doing because the gel.local file is
  7225. 4:22:50pretty much the best way of going about
  7226. 4:22:52it so what you can do is you can copy
  7227. 4:22:54this file and you know you can make a
  7228. 4:22:55copy of it however the second copy is
  7229. 4:22:57going to be called jail.local
  7230. 4:22:59in within this uh it has various jails
  7231. 4:23:02that protect various services now the
  7232. 4:23:04first one you can see
  7233. 4:23:06is uh going to be the sshd or the
  7234. 4:23:08openssh server service and it's going to
  7235. 4:23:10be enabled so a jail has already become
  7236. 4:23:13uh has already been configured for this
  7237. 4:23:15but you can see that there aren't any
  7238. 4:23:17protection uh configuration options that
  7239. 4:23:19have been set here
  7240. 4:23:21so for example the band time the default
  7241. 4:23:24band time for all jails on all services
  7242. 4:23:26irregardless of whether it's ssh or ftp
  7243. 4:23:28has been set to one hour now we can
  7244. 4:23:31pretty much customize this for uh
  7245. 4:23:32particular services which is what we
  7246. 4:23:34want to do so you can use this uh this
  7247. 4:23:37same configuration file uh and you can
  7248. 4:23:39copy it you know and use the local
  7249. 4:23:41extension and this will essentially set
  7250. 4:23:43up protection for all of those services
  7251. 4:23:45however in our case i want to
  7252. 4:23:47i want to actually create a new
  7253. 4:23:49jail.local file and the only service
  7254. 4:23:51that i'm going to be protecting or we're
  7255. 4:23:52going to be configuring is the
  7256. 4:23:54the the openssh server this sshd service
  7257. 4:23:57so again all we'll do is we will say um
  7258. 4:24:00we'll use them here and we'll say
  7259. 4:24:02jl.local
  7260. 4:24:04and we're going to hit enter now as you
  7261. 4:24:06already saw within the gel.configuration
  7262. 4:24:09file
  7263. 4:24:10we can essentially
  7264. 4:24:12we we can start working with these
  7265. 4:24:14services that we want to protect so
  7266. 4:24:16again we do this by specifying their
  7267. 4:24:18name so in our case the openssh server
  7268. 4:24:20is defined by the ssh daemon here so
  7269. 4:24:23we're going to say ssh daemon and then
  7270. 4:24:25after this we're going to start
  7271. 4:24:27providing the syntax now the first
  7272. 4:24:29important bit of syntax here is going to
  7273. 4:24:31be the enabled configuration or the
  7274. 4:24:33enabled option
  7275. 4:24:35this essentially you know
  7276. 4:24:37means whether this essentially controls
  7277. 4:24:39whether the jail is enabled uh or
  7278. 4:24:41disabled and the option here we can
  7279. 4:24:43specify is either true or false right
  7280. 4:24:46and of course that is self-explanatory
  7281. 4:24:49enabled means that the uh the jail or
  7282. 4:24:52the protection will be enabled or this
  7283. 4:24:54these particular configurations will be
  7284. 4:24:56enabled so for now let's just keep it at
  7285. 4:24:58false because i want to show you uh you
  7286. 4:25:01know a test brute force attack on the
  7287. 4:25:02server
  7288. 4:25:03uh before and after so what we'll do is
  7289. 4:25:06we'll just say false
  7290. 4:25:08and uh
  7291. 4:25:09after this we can then get started with
  7292. 4:25:11our configurations now let me just talk
  7293. 4:25:12about the various configurations that
  7294. 4:25:14exist here
  7295. 4:25:16uh so we pretty much need to specify the
  7296. 4:25:18service the port and the filter and the
  7297. 4:25:21log file that we'll be using now let me
  7298. 4:25:23explain that sounds like a mouthful but
  7299. 4:25:24it's really very simple to understand
  7300. 4:25:27all right so the first thing i want to
  7301. 4:25:28do is i want to say what's the pot the
  7302. 4:25:30port is going to be the ssh port right
  7303. 4:25:33so the ssh port here
  7304. 4:25:35and
  7305. 4:25:36after this we specify the filter that
  7306. 4:25:38we're looking for now the filter is
  7307. 4:25:40something very important right so let me
  7308. 4:25:42just open up a uh
  7309. 4:25:43i'll open up a new tab here and we can
  7310. 4:25:46try and authenticate to this server one
  7311. 4:25:48more time so i'll just say ssh root and
  7312. 4:25:51we'll just authenticate to this server
  7313. 4:25:53and the reason being is i want to show
  7314. 4:25:55you the log the log file that we're
  7315. 4:25:57talking about this is the auth.log file
  7316. 4:25:59now the auth.log file uh pretty much
  7317. 4:26:02stores all the authentication attempts
  7318. 4:26:04made to the server whether they they
  7319. 4:26:05were successful or whether they failed
  7320. 4:26:08and pretty much you can find this within
  7321. 4:26:11the let's just get the contents of the
  7322. 4:26:13file so you can find this within the log
  7323. 4:26:15directory under etsy and it's called the
  7324. 4:26:17author log file now when i talk about a
  7325. 4:26:19filter again a filter is very simple to
  7326. 4:26:22understand uh we'll just hit enter for
  7327. 4:26:24some reason we don't have
  7328. 4:26:27this file we're looking sorry this is in
  7329. 4:26:29the var directory my apologies i'm just
  7330. 4:26:32getting confused with the etsy directory
  7331. 4:26:33there so you can see that this gives you
  7332. 4:26:35um
  7333. 4:26:36it gives you a log here of all the
  7334. 4:26:38authentication attempts
  7335. 4:26:40and when i was talking about the actual
  7336. 4:26:42filter so if i say filter
  7337. 4:26:44this will essentially mean this is
  7338. 4:26:47essentially where you say fail to ban i
  7339. 4:26:49want you to look for this particular
  7340. 4:26:52filter in our case we're looking for the
  7341. 4:26:53ssh daemon or the sshd service here so
  7342. 4:26:56you can see
  7343. 4:26:57that for example if we take a look at
  7344. 4:26:59the first ssh
  7345. 4:27:01demon
  7346. 4:27:02log here we can see that this is the the
  7347. 4:27:04ssh server listening on port 22 and then
  7348. 4:27:07if we take a look at some authentication
  7349. 4:27:09attempts you can see we have an
  7350. 4:27:10authentication attempt here
  7351. 4:27:12that tells us accepted password for the
  7352. 4:27:14root user and the particular ip address
  7353. 4:27:17here
  7354. 4:27:18and this was made through ssh not a tty
  7355. 4:27:21session so if it can also tell you
  7356. 4:27:23whether the authentication is done
  7357. 4:27:25locally or remotely so that is the
  7358. 4:27:27filter we're looking for so we only want
  7359. 4:27:29to filter for ssh daemon or sshd
  7360. 4:27:32logs there so we then need to specify
  7361. 4:27:35the the location of the log file that
  7362. 4:27:37we're going to be using so say log path
  7363. 4:27:39is going to be equal to and we specify
  7364. 4:27:41the relative directory here so we're
  7365. 4:27:42going to say var
  7366. 4:27:44log
  7367. 4:27:45and auth.log here
  7368. 4:27:48and after this we can just hit enter and
  7369. 4:27:50we can now talk about the security
  7370. 4:27:52options right so the security options
  7371. 4:27:54are very simple the first or the first
  7372. 4:27:56of with of which is the most important
  7373. 4:27:59this is the max retry option and this is
  7374. 4:28:01where you specify the number of attempts
  7375. 4:28:03to be made before an ip address or a
  7376. 4:28:06user is banned all right so to do this
  7377. 4:28:08we say max retry
  7378. 4:28:10max retry and that's going to be equal
  7379. 4:28:12to in our case we'll just say three so
  7380. 4:28:14the number of uh so we say the number of
  7381. 4:28:16attempts to be made before a band is
  7382. 4:28:18going to be equal to three so if you
  7383. 4:28:20enter
  7384. 4:28:21you know an incorrect password three
  7385. 4:28:22times that's that you're going to be
  7386. 4:28:24banned right
  7387. 4:28:25now we then have the band time right so
  7388. 4:28:27the band time
  7389. 4:28:29is again self explanatory this is the
  7390. 4:28:31number of seconds an ip address will be
  7391. 4:28:33banned for now typically you can set it
  7392. 4:28:35to an hour which is uh is primarily
  7393. 4:28:38going to be uh you know 3600 seconds or
  7394. 4:28:41you can uh you can specify a day which
  7395. 4:28:44is a very good option that many system
  7396. 4:28:47administrators set so again
  7397. 4:28:49we can just calculate this so 60 times
  7398. 4:28:5260 um that pretty much gives us what
  7399. 4:28:54we're looking for that's 3600 multiplied
  7400. 4:28:57by 24 hours that's going to be 86 400 so
  7401. 4:29:01we can say 86
  7402. 4:29:04400 and that's typically going to block
  7403. 4:29:06uh any ip addresses that have incorrect
  7404. 4:29:10authentications more than three or uh
  7405. 4:29:12three incorrect authentications for
  7406. 4:29:14entire day
  7407. 4:29:15right so what we can do is we'll just
  7408. 4:29:17set it to 3600 or we can set it to 60
  7409. 4:29:20seconds whatever you feel is appropriate
  7410. 4:29:22for your server based on the attacks
  7411. 4:29:24you've been getting or you can set a
  7412. 4:29:25generic one if you're monitoring your
  7413. 4:29:27server and seeing how many attacks
  7414. 4:29:29you're typically getting which i'll show
  7415. 4:29:31you how to monitor
  7416. 4:29:32you can then ignore ip addresses so you
  7417. 4:29:35can whitelist ip addresses
  7418. 4:29:37so again that's done by specifying
  7419. 4:29:39ignore ip and then within this you can
  7420. 4:29:42then specify any ip addresses that you
  7421. 4:29:44may want to white if you're a system
  7422. 4:29:45administrator it may be wise to enter
  7423. 4:29:47your ip address here
  7424. 4:29:49um so you can do that and i think
  7425. 4:29:52we can also specify uh i've specified
  7426. 4:29:55band time what about find time so the
  7427. 4:29:57amount of time between failed uh login
  7428. 4:30:00attempts
  7429. 4:30:01we can you can just say find time
  7430. 4:30:05or we can actually leave that out
  7431. 4:30:06because we really don't need that uh
  7432. 4:30:08these are these options are pretty
  7433. 4:30:10pretty good um so we can save
  7434. 4:30:13this file
  7435. 4:30:15and we
  7436. 4:30:16we
  7437. 4:30:17ensured that this jail was disabled and
  7438. 4:30:19the reason being is i want to show you
  7439. 4:30:22what you know typical field
  7440. 4:30:23authentication looks like
  7441. 4:30:25so what i'll do is um let me just exit
  7442. 4:30:28from here and i'll just
  7443. 4:30:31ssh into this and i'll enter incorrect
  7444. 4:30:33passwords now typically the the
  7445. 4:30:36the max amount of times you're allowed
  7446. 4:30:37to authenticate incorrectly is three
  7447. 4:30:39times that's the default one but i'll
  7448. 4:30:41explain something interesting here so
  7449. 4:30:43for example
  7450. 4:30:44uh actually before i do this because i
  7451. 4:30:46do want to block my ip address because
  7452. 4:30:48it is going to connect to it remotely
  7453. 4:30:51let's see if we can actually use proxy
  7454. 4:30:53chains here so let me just open up this
  7455. 4:30:55in part os and i'll expand this
  7456. 4:30:59uh or we can actually use anon surf so
  7457. 4:31:01let me just use anon surf instead of
  7458. 4:31:02using proxy chain so we'll just start
  7459. 4:31:04this
  7460. 4:31:05yes go ahead
  7461. 4:31:07and the reason being is i don't want to
  7462. 4:31:09actually expose my real ip address here
  7463. 4:31:11because when i'll be showing you the ip
  7464. 4:31:13addresses that were blocked uh this will
  7465. 4:31:15come into play so what i'll do is i'll
  7466. 4:31:17just wait for announcers and on surf to
  7467. 4:31:19start before we authenticate to the
  7468. 4:31:21server and i'll show you what happens
  7469. 4:31:24here
  7470. 4:31:24so remember the jail has is currently
  7471. 4:31:26disabled and ssh protection is is
  7472. 4:31:29currently not active with fail to ban
  7473. 4:31:31all right so we are currently uh
  7474. 4:31:34anonymized here so what we'll do is
  7475. 4:31:35we'll say ssh
  7476. 4:31:37root at
  7477. 4:31:38and we'll hit enter
  7478. 4:31:40and we'll say yes we want to accept the
  7479. 4:31:42fingerprint and we'll enter incorrect
  7480. 4:31:44password so i can just say password
  7481. 4:31:47and again that will be incorrect
  7482. 4:31:49permission denied
  7483. 4:31:50password will hit enter
  7484. 4:31:53another incorrect password attempt for
  7485. 4:31:56authentication attempt hit enter one
  7486. 4:31:58more time
  7487. 4:32:00and there we are you can see so it gives
  7488. 4:32:02you three attempts by default and then
  7489. 4:32:04after which you're told permission
  7490. 4:32:05denied let's try this one more time so
  7491. 4:32:08we're we're sort of exceeding the amount
  7492. 4:32:10of attempts but remember we haven't
  7493. 4:32:11enabled the fail to ban jail so we can
  7494. 4:32:14still try authenticating incorrectly
  7495. 4:32:16say password
  7496. 4:32:19and
  7497. 4:32:20password let's try it a few more times
  7498. 4:32:22and there we are we can still see that
  7499. 4:32:24after three unsuccessful attempts
  7500. 4:32:27uh it uh it it essentially disconnects
  7501. 4:32:29the the connection what i'll do is we'll
  7502. 4:32:32just wait for we'll just close this and
  7503. 4:32:34uh let's restart the service before we
  7504. 4:32:36actually get started so again uh before
  7505. 4:32:38after writing any changes to your uh to
  7506. 4:32:41your jail configuration file
  7507. 4:32:43uh you essentially need to restart the
  7508. 4:32:45the filterband service so we say system
  7509. 4:32:48control
  7510. 4:32:49sorry system
  7511. 4:32:50system control and we say restart
  7512. 4:32:53uh we'll say fill a two band service and
  7513. 4:32:57we
  7514. 4:32:58hit enter and that's going to restart it
  7515. 4:33:00so now that we've tested that this uh
  7516. 4:33:02that we you know we currently do not
  7517. 4:33:04have any brute force protection here uh
  7518. 4:33:07what we can do is we can modify this
  7519. 4:33:09file and we can say uh set this to true
  7520. 4:33:12so now we're going to activate the
  7521. 4:33:13protection so we're gonna say true
  7522. 4:33:16and we're going to write changes and
  7523. 4:33:18exit and we'll restart the filter band
  7524. 4:33:20service and let me just check the status
  7525. 4:33:22here
  7526. 4:33:24[Music]
  7527. 4:33:27sorry that is incorrect
  7528. 4:33:29we'll just change this to status and we
  7529. 4:33:31can see it's active and running this is
  7530. 4:33:33very important because
  7531. 4:33:36if you do want to actually check if
  7532. 4:33:38you're having any issues with your
  7533. 4:33:39syntax or any of the filters you've set
  7534. 4:33:42up for your particular jail in the jail
  7535. 4:33:44configuration file
  7536. 4:33:46this is where you can actually check if
  7537. 4:33:47there are any issues and you also have
  7538. 4:33:49the log here so you can see stopped
  7539. 4:33:50start started and we're ready again so
  7540. 4:33:54we can now get started and we can test
  7541. 4:33:56it one more time so what i'll do is i'll
  7542. 4:33:58use the same ip address here
  7543. 4:34:00and what we'll do is we'll just say ssh
  7544. 4:34:03root act
  7545. 4:34:04and for some reason we're being told the
  7546. 4:34:06connection was closed by remote host
  7547. 4:34:09so let's try a different ip here so uh
  7548. 4:34:12let's see if we can let's check the
  7549. 4:34:15um
  7550. 4:34:16the status of of the tor service
  7551. 4:34:19and we remember we need uh
  7552. 4:34:22do we have tor running we currently have
  7553. 4:34:24door running i believe but i think we
  7554. 4:34:26still need to disable the anon surf here
  7555. 4:34:29we can just stop it
  7556. 4:34:32uh so we'll say stop and we'll wait for
  7557. 4:34:34this to stop
  7558. 4:34:36and i think we can just use proxy chains
  7559. 4:34:38now that would be much better
  7560. 4:34:40uh instead of using anon surf
  7561. 4:34:43although i should have done that before
  7562. 4:34:45but i just wanted to explain a point
  7563. 4:34:46here so
  7564. 4:34:48all anonymous mode has been stopped and
  7565. 4:34:52we'll just start store
  7566. 4:34:55uh actually yeah we can we can do we'll
  7567. 4:34:57start it and uh now let's use proxy
  7568. 4:34:59chains i'll say proxy chains
  7569. 4:35:02ssh um i'll say root at and we'll paste
  7570. 4:35:06the ip in here
  7571. 4:35:08all right so it'll ask us for the
  7572. 4:35:10password and i'll just enter an
  7573. 4:35:11incorrect password late enter
  7574. 4:35:14and uh lend an incorrect password again
  7575. 4:35:17remember we have said we have set the
  7576. 4:35:18options in the gel configuration file to
  7577. 4:35:20three so again it will just uh it will
  7578. 4:35:22block the user for the first three
  7579. 4:35:23attempts obviously
  7580. 4:35:25uh we aren't getting a response we can
  7581. 4:35:27also try brute forcing with hydra
  7582. 4:35:30which is also another option so let's
  7583. 4:35:32try this out so we'll say
  7584. 4:35:34hydra
  7585. 4:35:35uh l uh we'll say root
  7586. 4:35:39and the password list is gonna be user
  7587. 4:35:42uh share
  7588. 4:35:44and we're gonna say word lists and we'll
  7589. 4:35:46use some of the meta split word lists
  7590. 4:35:48here
  7591. 4:35:48uh let's see which ones we have
  7592. 4:35:51do we have any ssh ones
  7593. 4:35:53nothing much
  7594. 4:35:57we can use the common roots let's try
  7595. 4:35:59that we can just use any the the bottom
  7596. 4:36:01line is i just want to show you
  7597. 4:36:03what this would look like
  7598. 4:36:05so we're looking for ssh
  7599. 4:36:07and we specify the ip address here
  7600. 4:36:09let's get rid of any other sessions that
  7601. 4:36:11i had and let's have some verbose output
  7602. 4:36:14and let enter
  7603. 4:36:15and you can see it tells us that could
  7604. 4:36:16not connect to
  7605. 4:36:18to this particular ip
  7606. 4:36:20connection refused what i'll do is uh we
  7607. 4:36:23can you can see that after the third
  7608. 4:36:25failed attempt
  7609. 4:36:27we can see that we get no response and
  7610. 4:36:28that actually proves that it's working
  7611. 4:36:30however i'll i'll actually show you how
  7612. 4:36:32you can check this so if we just
  7613. 4:36:34terminate this and we go back in on to
  7614. 4:36:37our server we can view the logs and the
  7615. 4:36:39failed authentication attempts and the
  7616. 4:36:41blocked ips
  7617. 4:36:42uh by taking a look at the filter ban
  7618. 4:36:44client here so i can hit enter and then
  7619. 4:36:47after this we want to display the status
  7620. 4:36:49right so if i hit status and we hit
  7621. 4:36:51enter this will give you the number of
  7622. 4:36:53jails that you have and as you can see
  7623. 4:36:54we have only one gel and that is the ssh
  7624. 4:36:57daemon so we want to check the status of
  7625. 4:36:59the ssh
  7626. 4:37:01daemon or this is ssh server as the
  7627. 4:37:03openssh server
  7628. 4:37:05uh jail and we hit enter all right and
  7629. 4:37:08you can see that the status for the jail
  7630. 4:37:10is as follows so the filter is
  7631. 4:37:12the currently failed is zero the total
  7632. 4:37:15amount of failed authentication attempts
  7633. 4:37:17is six
  7634. 4:37:18uh you then have the file list which is
  7635. 4:37:20uh the authentication log that is going
  7636. 4:37:22through uh it's banned three ip
  7637. 4:37:24addresses so the total amount of band
  7638. 4:37:26ips is three you have the band ips that
  7639. 4:37:29i think we used with unknown surf
  7640. 4:37:31and also with store and my ip address
  7641. 4:37:33here which for some reason it blocked i
  7642. 4:37:35think that's because i disabled
  7643. 4:37:37um i think i disabled announcers and
  7644. 4:37:40pareto's using my ip in any case
  7645. 4:37:43so what we can do now is we can go back
  7646. 4:37:45into parrot and um
  7647. 4:37:48if we take a look at hydra we can see
  7648. 4:37:50that we have a few issues here so let's
  7649. 4:37:52test this one more time by running anal
  7650. 4:37:54surf
  7651. 4:37:55again and then we'll try and run hydra
  7652. 4:37:57with that so that we have a new ip we
  7653. 4:37:58can work with
  7654. 4:38:00because it looked through the filter
  7655. 4:38:01bank line that it did work um
  7656. 4:38:04so and when i'd run
  7657. 4:38:07i'd run proxy chains with hydra here
  7658. 4:38:10uh because actually didn't run proxy
  7659. 4:38:12chains directly so if i try and do that
  7660. 4:38:14right now we can actually do it here so
  7661. 4:38:16we can save proxy chains
  7662. 4:38:18um
  7663. 4:38:20we'll wait for this to connect first so
  7664. 4:38:21we're currently on the announcer tunnel
  7665. 4:38:24so we can just run it through this so we
  7666. 4:38:26hit enter
  7667. 4:38:27there's going to test if possible
  7668. 4:38:28authentication is supported and you can
  7669. 4:38:30see it is working and
  7670. 4:38:33immediately we're getting a few
  7671. 4:38:34connection errors so
  7672. 4:38:36it's going to try connecting again but
  7673. 4:38:39what we can do is um
  7674. 4:38:41[Music]
  7675. 4:38:42we can say sudo
  7676. 4:38:44we'll say
  7677. 4:38:46proxy chains and we'll run this with
  7678. 4:38:49hydra right and i'll enter my password
  7679. 4:38:51here
  7680. 4:38:52so we can see that it's currently
  7681. 4:38:54supported
  7682. 4:38:56and
  7683. 4:38:57immediately we get uh authentication
  7684. 4:38:59errors to the server so that's working
  7685. 4:39:01fine let's take a look at the filter
  7686. 4:39:03bank client one more time so again i'll
  7687. 4:39:06just clear that out and we can run the
  7688. 4:39:09fill to burn client and check the number
  7689. 4:39:11of failed authentication attempts again
  7690. 4:39:14and now you can see that again the
  7691. 4:39:16amount of failed authentication attempts
  7692. 4:39:18has moved up to 38
  7693. 4:39:20and the currently the the total amount
  7694. 4:39:22of band ip addresses are as follows so
  7695. 4:39:25we have various ones that we had uh that
  7696. 4:39:27we have uh that we got with anon surf
  7697. 4:39:30and proxy chains to uh
  7698. 4:39:32to a certain extent so
  7699. 4:39:34uh that's pretty much how to view
  7700. 4:39:37um
  7701. 4:39:38this is pretty much how to view all the
  7702. 4:39:39failed authentication attempts and the
  7703. 4:39:42blocked ips which you can then use to
  7704. 4:39:43build a geographical model of where most
  7705. 4:39:46of the attacks are coming from even
  7706. 4:39:47though they may be coming from a botnet
  7707. 4:39:49uh so again that's how to use feldeban
  7708. 4:39:51uh so again if you want to disable a
  7709. 4:39:53particular jail uh we can just check
  7710. 4:39:55this out here
  7711. 4:39:57uh fill the ban and you can then modify
  7712. 4:39:59the local configuration file so we can
  7713. 4:40:02use fim and we say jail dot local
  7714. 4:40:05and we enter so if i'm working with the
  7715. 4:40:07ssh daemon i can just disable this
  7716. 4:40:10to false here and that will disable the
  7717. 4:40:12protection
  7718. 4:40:13and if i just run and exit and we can
  7719. 4:40:16try and restart this service so i can
  7720. 4:40:18say
  7721. 4:40:20system control
  7722. 4:40:23we can say restart
  7723. 4:40:25oops sorry
  7724. 4:40:26restart let me just reduce the font size
  7725. 4:40:28here and we'll say fill to ban
  7726. 4:40:31service and we'll hit enter
  7727. 4:40:34and there we are
  7728. 4:40:35all right uh let's take a look at
  7729. 4:40:38whether we can actually log in now
  7730. 4:40:41so i'll say exit
  7731. 4:40:42and this is through my local ip i'm not
  7732. 4:40:44going to use proxy chains
  7733. 4:40:46um so i'll say
  7734. 4:40:48ssh will actually just ssh without proxy
  7735. 4:40:50change ssh
  7736. 4:40:52root at this particular ip and you can
  7737. 4:40:55see it now works perfectly fine so if i
  7738. 4:40:57hit another
  7739. 4:40:58uh you know some other incorrect
  7740. 4:41:00passwords we are now able to
  7741. 4:41:03at least get authentication attempts
  7742. 4:41:05across the line uh but yeah that's
  7743. 4:41:08pretty much all that i wanted to show
  7744. 4:41:09you guys how to do um you know with
  7745. 4:41:11failed by how to use fill the band you
  7746. 4:41:13know to protect to protect your server
  7747. 4:41:15from uh ssh brute forces uh let me know
  7748. 4:41:17if you have any questions or suggestions
  7749. 4:41:19and i'll be seeing you in the next video

About this transcript

This page contains the full transcript of Linux Essentials for Ethical Hackers - Full InfoSec Course by freeCodeCamp.org, generated from the public captions YouTube serves with the video. The transcript has 53,297 words across 7,749 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.