apt, dpkg, git, Python PiP (Linux Package Management) // Linux for Hackers // EP 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so how do you install stuff on linux like if you want to install software programs or packing tools what do you do if you're fairly new to linux you might be a bit lost don't worry i got you in this video i'm going to show you how to install pretty much anything on linux everything from common tools that everyone uses to even some custom hacking stuff that other hackers create you can download on github how do you do all that let's get started this is episode 5 of linux for hackers and everyone because everyone needs to learn linux in this episode we're covering linux package management or basically how do you manage all the software and the programs on your linux machine and i'm going to do my best to cover pretty much everything so if you're looking for any particular way to install something check the timestamps jump to it also i want you to do this with me every command i type everything i install do it with me the best way to learn anything is hands-on especially linux and you can do that for free right now thanks to our sponsor hack the box academy get signed up for free at the link in the description and you'll get access to a pwn box which is as cool as it sounds it's basically a linux computer that you can use right here in your browser it's amazing and it's free like yeah just do it just do it also what the junk is hack the box academy well i like to think of them as uh hogwarts for hackers you're a wizard harry they teach you how to become a hacker from zero to whatever you need to be it's awesome they also recently came out with a student subscription so if you are a student you get a discounted rate and you get cpe credits for completing tier 1 modules and above it's awesome check it out link below so get your pond box ready grab your cup of coffee what are you drinking i'm drinking networkchuck.com check it out let's get started oh by the way have you hacked the youtube algorithm today let's make sure you do like this video comment subscribe notification bell let's hack youtube today ethically of course oh let's get started okay as always get logged in to hack the box academy and launch the linux fundamentals module right here and today we're going to be focusing on package management which is right around here so go ahead and click on that now again freaking fantastic stuff right here but the stuff you want to look at right now with me as you follow along this video is right around here scroll down click on start instance to start your killer awesome phone box and while that's brewing perfect time for a coffee break and mine is ready i want to jump in there and get this party started so in linux the stuff we want to install our apps our programs like you know discord or firefox or minecraft anything we want to install is contained in something called packages we install packages packages are the thing packages packages packages sorry i've already had too much coffee today no such thing as too much how do we install these packages well as you may have guessed from the intro it's something called a package manager now there isn't just one package manager of course there's not just one it wouldn't be that simple right it's not there are two main ones we see all the time though one is called dpkg or d package that's the way i like to say it the other you'll see all the time is apt apt now i'll go ahead and get this out of the way apt is awesome it's super easy to do you can install things in a flash no worries but i'm not going to show you that one just yet you got to earn that you got to pay your dues i'm going to show you the harder way first so you can appreciate what this is and what it does for us don't you want to do that yes i'm answering for you so first i'm want to show you d package or dpkg i said it right that time now i say hard it's not too crazy but it does look stupid compared to apt it's referred to as a low level package manager because it's kind of and this is my opinion kind of dumb i mean sure it'll do the job it'll install your software it'll install your packages it'll uninstall or remove them but it has two major huge flaws that i hate so let's go ahead and launch our terminal our shell the green or yellow thing up here and we're gonna install our first application discord and it's gonna be hard it's gonna be difficult because we're using the more difficult way of doing this and already we've hit our first flaw because to install this cord we have to go find it and download the package so let's go ahead and launch our web browser we'll go to discord.com click on the little side panel over here and click on download we'll scroll down and right here we have download for linux click on that that's going to say deb who's deb i'll explain here in a minute click on deb now instead of open with i want you to do save file just work with me here click on that save file and then click ok and it should go pretty stinking quick so now we can close firefox and get back to where we love being our terminal our bash shell yes first thing we want to do is get to our downloads folder if we type in ls to list our contents of our stuff here we have a downloads folder let's cd to that so cd downloads type in ls to see what's inside and there's our discord right there our discord debi when you see deb that's the file extension for packages and linux specifically debian based which is what we're on right now we're using parrot os which is a debian based system it's sort of like exe what you see on windows and dmg you see with mac now if you do happen to be on another linux system that's maybe not debian based maybe it's centos maybe it's uh opensuse redhat instead of.deb you'll see rpm but we're not going to cover that today we're going to cover debian based systems so how do we install deb here our discord server or not server our discord application it's pretty straightforward actually we'll type in dp dp i'll never get this right dp k g for d package we'll do a dash i for install and then we'll specify our package there it is that's simple but no it's not though no you you can do this but it's going to fail let's do it anyway this is going to reveal the second major flaw with d package oh wait that wasn't it we do need pseudo privileges if you don't know what pseudo means go watch episode four so pseudo d package let's do that now flaw coming so far so good looking good right whoa whoa whoa whoa error i hate seeing errors problems more specifically dependency problems and that's the second major flaw with d package you see most packages in linux they depend on other packages to work for example discord here if i scroll up a bit this core depends on the lib app indicator 1 which is not installed and the lib c plus plus one and it's not installed those are two packages that have to be installed for discord to work so d package the dummy is like hey yeah sure i'll install discord for you but it needs two other things and um i'm it's just not gonna work sorry you need to go get those two other things yourself okay lazy so yeah sure we could go out and find these and install it using d package but that's stupid this is where apt shines it's better let's talk about apt apt is beautiful and if you've ever installed anything on linux any kind of debian based system you've probably used apt before it stands for advanced package tool and when comparing that to d package duh it's advanced d package is stupid anyways it has its place sometimes you may have to install something manually with a deb file whatever we'll get to that why that is in a second coffee break for a second real quick so let's install something with avt now first thing we're going to do real quick new command time we'll do sudo apt and we'll do the command update i'll explain that here in a moment just go ahead and do it let it do its thing now time to install something so do sudo apt this time instead of update we'll do install and then we'll just name the program or package we want to install i'm going to install an old favorite uh pigeon remember pigeon the open source instant messaging app so instead of having to specify the deb file instead of talking to deb all i have to do is reference the package name which is pigeon and that's it now it's not going to work and it's not his fault it's actually d package's fault i'll show you apt was smart it went out and found everything but then it's like whoa hold on um discord we noticed that it's kind of broken we don't have the dependencies of the lib indicator and the c plus plus you might want to fix that dumb old d package but it even gives us a way to fix it apt fix broken install it'll fix discord force so let's do that real quick i'm just going to copy that command apt fix broken install let's uh paste that in there i'll do a control a to get to the front of my command and type in sudo right before it and let's um let's fix some discord it's going to install those two packages hit enter thank you apt so i fixed that i'm going to clear my screen and let's try to install pidgin once more up arrow twice or three times four times there we go and let's hit enter on pidgin right now now real quick before i hit enter to say yeah let's continue this let's scroll just a little bit here notice it's not only installing pidgin super smart amazing apt goes oh hey we have some dependencies the following new packages will also be installed as well and it's kind of a lot right but it's going to do it for us which is what you expect that's like you won't you want that to happen so let's go ahead and do that hit enter coffee break very short i love this actually long coffee break it's kind of long isn't it and that was it i want to try launching pigeons by typing in pigeon look at that i'm not going to use it but that was pretty cool right way easier than d-package now i'm not sure if i mentioned this before but apt is a high-level package manager which basically means it's easier for us to use now one of the main differences between itself and d-package is that d-package required us to download the deb file the actual package file apt doesn't need that or use that as you saw in our example apt just needed the package name but how does that work apt will rely on a thing called a repository a repository is basically a storage location or essentially just someone's server that has a collection of all the software that we might want to use the most common stuff anyway so when we typed in apt install pidgin apt went out to his repository and goes hey where's this pigeon thing at you got it and the repository said yep here it is go ahead and download it it's good and going back to that first command we entered what was it do you know what it was the first command was apt update and what that did is apt went out to the repository and said hey give me all those packages what you got there i want a list of everything you have the repository replies with a list of everything he has and by the way this is something you want to do every time you install something before you say apt install whatever tool you want to install do apt update to update your list of stuff because these repositories are owned by someone else and they're regularly updated there are a lot of repositories out there which ones are we using well let me show you there's an easy way to do this and we'll use the apt command here as well new command time the command will be and we're going to always start with sudo apt space edit dash sources and hit enter and it's so nice it asks us what a text editor we want to use um nano my favorite one i don't care now parrot pulls like a bait and switch normally you'll have your list of repositories and this file parrot's like nah nah nah we put our stuff somewhere else it tells us the parrot repo is located at this location right here so i want to do right now is just highlight that copy it go ahead and do that with me let's control x to get out of this file and we're going to cat that file so i'll type in cat paste that file there and hit enter almost not i've highlighted the entire thing yeah it's parrot dot list oh yeah i've got the list dot list dot list there we go and actually instead of cat let's go ahead and just nano that so i'll do sudo nano just so we can see it a bit cleaner i think that list yeah that's better so right here we have a list of servers or repositories that apt will look to to pull packages from notice it does have the deb preface before it and what do you say we go check it out real quick we can actually just click on that link here control click yeah that's what control and click we're browsing the repository so if i jump into uh the pull directory right here go to let's say the the main directory we got a bunch of stuff in here let's go to the uh the ends let's go to n and look there's nmap right there in the repository so when you do sudo apt install in map it looks at that repository and goes oh there it is let's pull that down now sometimes the tool you want to install is not in these repositories like for example this is the one that's provided by parrot os what do you do then well most of the time these tools will have an alternative way to install it we'll cover that here in a moment or they'll have their own repositories that you can add to the sources list they'll document it for they'll say hey here's our source add that to your sources list do a pseudo apt update pseudo apt install you're solid now you're ready new commands with an s time apt has some cool stuff we can do with it now first always you can do sudo apt-h what the heck am i doing here it'll tell you some stuff you can play with some of those switches you can use let's walk through a few real quick pseudo apt list will list all the available packages in your um i can't talk repositories you can also do apt list dash dash installed to see what your system is installed with very handy if you want to search through that list just do a pipe at the end of that pipe type in grip we'll explain that sometime in another episode and then just um search for something like let's search for say anything that begins with nmap and there it is nav is installed right there let's say you want to learn more about what tools you have installed like what the junk is that what does it do you can do pseudo apt show or show me what it is let's just say nmap show nmap and it'll dang tell you the network mapper and it tells you all about it you can also do apt search and let's just say again nmap and it's going to search through the description of a lot of stuff and show you all the stuff and that's an easy way to search through a bunch of packages now we covered how to install packages but how do we remove stuff how do we uninstall something two ways apt is still the guy for this so sudo apt new command time remove pretty self-explanatory so if you wanted to remove pidgin just type that in hit enter and it's going to say are you sure and i'm going to say no not right now because i got more to tell you remove is kind of a safe command because it will remove the application but not your user data basically the config you might have put into the application so if you removed it accidentally or you want to reinstall it all that stuff will still be there now if you're confident you don't want this dumb app anymore you want it gone you can use a different command the purge so we'll swap out remove for purge this sounds so intense we're gonna purge pigeon this will remove everything and let's go ahead and do that so if we do our command that we learned earlier pseudo list dash dash installed regret for anything that begins with pidgin so it did remove the main package but not this secondary one the pigeon data so i want to remove that real quick let's purge pigeon data let's see if pigeon's here now no pigeon here all right two more useful commands with apt first pseudo apt upgrade as you might imagine sometimes your applications your packages get updates you would hope they get updates and this is the way to update those packages now normally you'll see this command combined with the update command so you might see it like this pseudo apt update to go to the repository and say repository can you tell me if the packages have been updated otherwise you wouldn't know about it right so update that and you'll see an n and which allows us to do two commands in one line which is awesome pseudo apt upgrade so check the repository and then update everything now there is another version of this now upgrade will just upgrade your applications if they need upgrading another one is full dash upgrade full upgrade will actually remove previously installed applications or packages that aren't required for the upgrade so maybe old versions of things now i do want to jump back to our old guy d package real quick he does a lot of the stuff too i'm not going to go over everything but just give me an example dpkg if i do a dash l he'll also list all the install packages on your system i can do the same thing as i did before with uh mr apt by grepping his stuff and looking for anything that starts with nmap that didn't work let's just try nmap there we go and again it has a lot of the same switches and features i'm not going to do that again so d package low level stupid apt high level awesome but there's also one other thing worth mentioning it's something called aptitude which starts with apt but just has a full word to it this also is high level but it's sort of like apt on steroids a bit it does more now i'm not going to go too deep into it but just give you an example of what it might do let's just type in aptitude actually i'll do sudo aptitude just type that in just like that enter oh fancy you kind of get a nice little interactive gui thing in your command line so that's fun anyways i'm going to quit but that's also a package manager that's high level that will get the job done for you i told you installing stuff in linux can be very easy but there's a lot of ways to do it one very popular way that i personally think is amazing is called snap now not like the previous episode where thanos destroys users and stuff no no this thing called snap is also kind of a package manager when you install it if you don't already have it installed it's actually called snap d snap d but snap isn't really a repository it's more of like a store a snap store and it works very similarly to apt as far as actually using the command line but the main difference here is that when let's say you're a developer and you make your app and you want people to be able to install it easily right now on any linux system it might take some time to get your app on a repository especially one that's already existing on the system like ubuntu's parrot os's calis whatever a better way is to be able to add your app to a store that and then it becomes immediately available just like in a snap right is that why it's called that i don't know so that's what snap is for they can add their app to the snap store and it's available in a snap right i don't know so it's pretty easy check it out so if you don't again if you don't already have snap installed we do on the system but you just do apt install snapd you would you would use apd to install another package manager but anyways a lot of the modern apps do this so let's install something like um i don't know vs code i love vs goes my favorite ide code editor whatever it is whatever you want to call it so let's try sudo snap this is all it is it's just like abt install and then your app now for vs code they do require the dash dash classic switch but then we just put in the package name which in this case will be code for vs code and that's it just press enter and it's going to start doing it snap d going at it coffee break oh coffee's cold i've been doing this too long and bam it's installed if i just type in code i think it should launch i think yeah there it is okay so snap is pretty cool i can see this being one of the main ways we get our apps now no we're not quite done yet there's more ways to get apps in linux now we've covered the main ways but the next few ways are interesting because they're based on python and ruby and more like specific to a programming language what do i mean well for example when you run a python script there may be some specific dependencies it needs certain libraries certain just things that help it to work or you know packages python has its own package manager called pip we absolutely will be using this in a moment when we talk about git so i almost said button your seat belts buckle your seat belts unless your seat belts have buttons i don't know that's weird another one would be ruby ruby's a programming language that's very popular and that will use a package manager called rubygems and the command you actually use is called gems you'll use gem install so similar syntax as every other package manager we've seen but it's specific to ruby so you might install rails never heard of ruby on rails well you would actually do a gem install rails to you know mess with the rails but now let's get to get get to get okay let's get it i use github all the time to install hacking scripts scripts that other hackers might create and they're amazing they help you do all kinds of amazing things in fact i've done a number of tutorials that involve using git to go out to github and grab the information so you can use it on your system but how do you do that now first a requirement is that you would need to have a git installed so use your favorite package manager we've already learned about this pseudo apt install git now thankfully we already have git installed on our system how do you yeah quiz how do you how do you see that comment below what's the command so here we go scenario let's say you find this amazing hacking tool there's one actually found it's pretty neat let's go look at it right now it's called turbo lister and what it will do is look at a website and list all the sub domains of that website it'll go and do it in kind of a passive way very cool but here i am on github and i want to use this tool but what do i do let's do it so the first thing i'll do is kind of just get the url at the top here so it's github.com for slash leak captain forward slash turbo lister i'll put a link in the description i'm just gonna grab that link and that's the repository link so copy that i'll go over here and the command will be get clone we're gonna clone that repository we're basically taking their code and copying it to our linux machine here which is super cool so i'm going to paste that url right after clone and that's it it's going to do something really cool you ready and also it's going to clone it to whatever directory i'm in the working directory so right now you can see i'm in downloads so i'm going to hit enter and it did it that's so cool so if i do ls to list the contents of my current directory there she is turbo lister ready to go so i'm gonna cd into turbo lister the directory there type in ls to see what's inside there and i've got a few things going on now specifically to this project it's a python project and to use this tool i would use this python script right here turbo lister.py but but there's one big thing before we can do that just like every other application we install on our system just like any script you might use in python there are some requirements that we have to meet we have to make sure we have the python libraries and packages installed to make this thing work now if only there were a tool that could help us do that what do you think it is it's pip so right here while we're in this directory we can actually just very quickly install all the requirements let me show you the command the command will be pip 3. now i'm saying pip three because we're actually using python three versus python two which would use just command pip so python three pit three pit three install dash r and then we'll put in requirements so with this command pip3 is going to go huh let's look inside the requirements.txt file which is right here and see what dependencies this script needs it'll go through it install them and then we're ready to go so let's try it i'm going to go ahead and hit enter on this and fingers crossed coffee break oh that was quick man and let me tell you something that was pretty much it like as far as downloading a script or an application or a hacking tool from github you download the repository you install the requirements then you run the the thing you run the script let's just do it real quick so the command will be for this python3 and then the script name which was turbo lister yeah there was now like most things if you don't know what to do just type in dash h and it will give you some help but i know what i want to do real quick i'm going to do d for domain let's take a look at hack the boxes sub domains hack the box dot eu and hit enter now one thing i love about all these scripting tools is that they have you know some really cool ascii script up here making it look really neat but anyways it's going to go through all these things and try to find the subdomains of hackthebox.eu which by the way is what we're using right now so it's kind of fun inception we're attacking from the inside we're not we're not attacking it's just passive reconnaissance and bam there it is look at that all these sub domains have hacked the box that's kind of cool right they have a lot goodness gracious now that was a lot we covered how to install stuff in linux and also remove it and and all kinds of stuff so real quick quick review 1000 foot look at this the two main ways we install stuff on linux is with our package managers d package or apt d-package being the low-level dumb version and apt being high-level and it's awesome whereas d-package requires you to download the dot deb file deb hi deb and then also does it install dependencies for you what a loser but apt it just looks at a repository when you reference a package like hey install docker for me please and it goes out and gets it for us and it also installs all dependencies it might need because packages need packages on packages on packages there's a fancier version called aptitude which looks really cool i've never played with it but it looks fun and then there's snap which i think is the best out of all of them because the developers can just upload their new applications they code straight to a store and you can just get it in a snap with the snap install command and it does work in a similar way to apt except it's not looking at a repository to pull information as looking at a store and then we had our programming language specific package managers now this is not exhaustive but the main ones we see right now are python with this pip or pip 3 for python 3. ruby has gem or that's the tool it's actually called rubygems and again these are both handy for installing programming language specific packages to help you run your scripts and apps and then last but certainly not least we have git it's a command line tool we can install with another package manager like apt apt install git and what git allows us to do is pull down stuff from places like github which also is itself a repository don't get confused so we demonstrated how you might find an amazing hacking tool that a hacker another hacker developed and you would use git to go get that tool download it to your linux machine and in this case we were using a python script so we used pip3 to install the requirements for that because it did have some requirements and then we used that amazing turbo listed tool to list sub-domains super fun so yeah that was a lot let me know what you think of this video if you have any questions or comments or anything just comment below i'll take a look and also let's see how you did like as you went through this and you learned you took notes and practice you got hands-on let's test your skills i've got a quiz in the link below i also have a walkthrough lab you can go through as well to kind of reinforce these things check it out free sign up no big deal and of course sign up for hack the box academy dude what we're doing here is completely free and if you want to go down further and become even an even better hacker and learn other stuff like hacking wordpress and all kinds of weird things you can subscribe as a regular person or as a student and it's just do it and yeah that's about it this was episode 5 of linux for hackers and everyone because dude everyone's got to learn linux and also if you like this shirt which is a raspberry pi blueprint or this mug go check out my store networkchuck.com you can get all this merch as well as coffee of course and yeah seriously that's all i have today thanks guys for watching this uh continue the next episode if it's already out which it should be hopefully if not we'll subscribe and hit that notification bell because it'll come out any day now you never know yeah i'll catch you guys next time [Music] you
Info
Channel: NetworkChuck
Views: 288,212
Rating: 4.957489 out of 5
Keywords: Linux for everyone, NetworkChuck, apt, linux package management, dpkg, install apps on linux, uninstall apps on linux, hacking tools, linux hacking tools, linux file system, linux for hackers, linux for everyone, linux fhs, parrot os, kali linux, linux tutorial, learn linux, linux course, linux file system hierarchy, linux file system types, linux file system explained, linux directory structure, linux tutorial for beginners, gnu/linux, linux file system commands
Id: vX3krP6JmOY
Channel Id: undefined
Length: 26min 5sec (1565 seconds)
Published: Fri Jun 04 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.