Raspberry Pi LESSON 2: Linux Essentials in One Session

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys this is paul mcquarter with toptechboy.com and we're here today with episode number two in our incredible new tutorial series where you're learning how to use the raspberry pi what i'm going to need you to do is pour yourself a nice tall glass of iced coffee that would be straight up black coffee poured over ice no sugar no sweeteners none needed and as you're pouring your coffee as always i want to give a shout out to our friends over at sun founder sun founder is sponsoring this series of lessons on the raspberry pi and in these lessons we will be using the most excellent sun founder ultimate raspberry pi kit now we will be starting with that in about two more weeks and so you guys need to go ahead and order your gear look down in the description there is a link to amazon where you can pick this kit up but go ahead and order your gear so when we crack into it and start building circuits and learning how to control sensors and actuators you will have your gear okay enough of this shameless advertising let's talk about what i am going to teach you today and what i'm going to teach you is the essential elements in linux now you could spend months and months and months and years and years and years learning everything there is to know about linux but what i want to do today is just teach you enough that you can kind of understand how to find your way around the terminal how you can find your way around the operating system from the command line also i want to sort of get you to the point that you're comfortable when someone shows you something new in linux you actually understand what they're doing or even if you haven't seen that particular command before you sort of have a framework or a cons a construct to understand what they're doing and so we're going to try to go through the basics today and enough to get you through this class and enough to get you where when you see somebody doing something in linux it'll sort of make sense and you'll sort of understand it okay so what we will be doing is we will be going to our code view here and so this would be a great time for you guys to go ahead and boot up your raspberry pi if you don't have the raspberry pi look down in the description i've got some links to where you can order some pies right now the pies are a little expensive and a little bit hard to find and so i've found i've put a link to the best the best deal that i've been able to find but feel free to look on ebay or borrow one from a friend or go to a swap meet or something like that but i will admit they're a little hard to find right now but with a little effort i'm sure you will be able to get one okay so let's talk about what we're going to learn today and as i said we're going to be learning about linux and i will get out of your way here and uh let me just sort of tie this to last week last week you learned how to boot the raspberry pi and then after booting the raspberry pi we learned how to configure the desktop where it's not quite as lame and ugly and low contrast as it comes out of the box and gets something that's a little bit better to work with and then you sort of learned how to use your start menu and you played around with some of these programs sort of got familiar with what you could do on the pi using it as a desktop machine and you probably also got in here and opened up your file explorer and you had kind of a folder view that came up that you should be very comfortable with if you come from a windows world or if you come from a mac world you sort of have folders inside of folders inside of folders and you were probably very comfortable navigating with this folder view and we can kind of see the file system here you start up here at the top folder the root folder the slash folder that's called the root folder and then you can see inside of the root folder there was this folder called home and then if you go inside of home there is your user folder pi that is you your pi because that's the default user when you install the raspberry pi operating system the default user is pi and then inside of pi you have things like your desktop your documents your downloads your music and everything if you added another user he would also be inside of home and he would have a different name and he would have a different folder here okay you should be very familiar with that but how do we do that same type of thing but instead of using excuse me a graphical user interface we were using the terminal the linux terminal the command line well to get there you need to come down to the lower left and you see this little icon that looks like a computer screen or a terminal you click on that and then your terminal will pop up here and then what you see is you have a command line waiting for you to enter a command but before we enter a command let me just kind of make you feel comfortable with what you are looking at here the first thing it says is pi well what is that pi is the username since you are the default user when you boot up raspberry pi you are user pi and then it says pi at raspberry pi raspberry pi is the machine name it's the name of your particular raspberry pi and again that's the default that it comes in when you boot now if you wanted to change your machine name you could come down here to the happy little menu uh the happy little raspberry pi icon that brings you to your menus you could come to preferences and you could come to raspberry pi configuration and then that pops up with this little menu box here and you can come over to system and if you look at host name you can see that your host name is raspberry pi now if you change that then it's going to change up here now i would demonstrate that but that requires a system reboot and so i don't want to slow us down with a system reboot but just know that if you change the name of your machine okay and then reboot your machine then your machine name will show up here so you've got your user at your machine name and then you have a colon and then you've got this dollar sign that dollar sign means that it is waiting your command it is awaiting your orders but before the between the machine name and the colon and the command prompt wanting a command from you you see that we have this little squiggly that squiggly is the shortcut to indicate that we are in your or my home directory so the squiggly is the shortcut for the home directory well what directory are we actually in i don't want to know the shortcut i want to know the actual path name and we can figure that out by typing in pwd which is print working directory so if i put in pwd for print working directory it shows me that i am in the folder slash home slash pi well let's come back over to our folder view and you can see that if we go up to the slash the root we can see inside of root one of the folders is home and then inside of home is the users and we have one user pi and then we are in the pi folder so we are in the slash for root that's slash home slash pi and then we will come here okay and so that is what is telling us it we are in the slash home slash pi so you've learned your first unix command pwd for print working directory and it shows you specifically what working directory what directory you are in okay now let's learn our second linux command and that is we can go to a different directory so let's go to our root directory the root directory root means the very very top the ultimate top level folder or the top level directory and so we could go there by putting cd for change directory and then a slash so that's change the directory to the root okay now what is in the root one way we could see what is in the root is come in and look here and go to the root and you can see there's all of these folders but again we don't want to be messing with that graphical user interface it just slows us down so we can do an ls and it shows you it shows us the folders that are in our root directory or our top level directory it shows us the folders that are in there and this matches what you would see if you went back and looked at your graphical user interface okay so there we are well now how do we get back to our home directory well i could go cd and then i would go home because i see the folder home here and so i could say cd for change directory home and then you can see i'm in the slash home and now i could do an ls again to list what's inside of that and the only thing in there as you already know is pi so i can go to the pi folder by saying cd pi like that and now if i do a print working directory again i'm in the slash home slash pi well let's go back and i could go to change directory to the root and let's say that i wanted to just go to pi and i just said cd pi well i get an error because you can only you've got to give it a very explicit path if i'm in root and i say go to pi it doesn't see pi because it doesn't drill down into the folders it only sees the folders immediately inside of itself so what is inside of root these folders i think perhaps you get a little bit further out of your way okay i think that'll make you a little happier uh you can see that these are what are inside of root and so now i would do cd home okay and then i could do c and then i'll do an ls now you can see pi and so now i can do a cd pi like that okay now what if i did cd back to root and now i did the ls and now i said change directory home that's all good now what if i said change directory slash pi okay let's do an ls so that you see pi is there okay now what if i did a cd for change directory into slash pi well i get an error no such file or directory why when you put the leading slash when you put that leading slash that you see here that says go back to root so when i did cd slash pi it went cd it went all the way back to root and then it didn't see pi there and so the right way to do it would be let's look ls there's pi i just do cd to pi and then it's happy and now boom i am back in my home directory now you can also string these things together so you can do them all at once i'm going to go cd and where do i want to go i want to go i want to go all the way to root and then i want to go to home and then i want to go to pi and then i want to go to vid i erased all that so i want to go cd i want to go to the root i want to go home i want to go pie and then i want to go to videos okay because you can see right there is there's a videos folder and then i go boom and now i am in the videos folder all right now i'm in the videos folder and if i do an ls you can see that there is nothing in there well what if i wanted to go to music from videos so i'm in videos and i want to go to music well one way i could do it i could go cd i could go all the way back to root and i could say go home go pie and then go what did i say did i say music okay let's go music it's happy and there's no music there all right now let's say i want to go back to videos instead of going all the way back to root what i could do is i could go up one and i go up one by going dot dot that takes me up one back to the pi folder and then slash and then i can come back into videos like that and boom i'm in videos and there is still nothing there also let's just say that i go to home to i'm sorry i go to root and now you can see i'm back at the root with all these system files in there what is an easy way that i can go back to my home directory i could go slash home slash pi or an easier way i could say cd squiggly and then the cd squiggly will take me back to my home directory really i don't use the squiggly as a shortcut because when i'm just navigating my own little area here in the terminal it works great but if you start programming and you start using the squiggly inside of programs inside of path names that can generate all types of confusion and it can generate all types of problems and so what you really don't want to do is i just don't use that as a shortcut because it can if i get in the habit of doing it then i'll do it in a program and that can sometimes cause problems okay so where are we right now where are we pwd we are in our home slash pi uh directory and then if we look there we have all these things these things are all pretty much empty well let's move on now you kind of find out about how to find your way around dot dot goes up one i can't help it let me do one more what if i did cd and i went dot dot slash dot dot what would that do that would take me all the way to root because the first dot dot is going to take me to home and then the second dot dot is going to take me all the way to root and you can see the slash there i am in root if i do a ls for list the contents of the directory you can see there we are so i will now go cd i will go back home and i will go back to pi and now ls there i am i am in my home directory the slash home slash pi okay does that make sense all right we have played around and we have made our way around okay what if we wanted to install some software most software you stop install using the command apt apt-get app get and then the program name so let's say i want to install putty putty is a little application that allows you to ssh or remotely log into other computers and so i'm going to say apt-get and then install [Music] putty the program putty this pro tip this only works if you're on the internet because it's going out to the internet to look for the uh the program to install so i'm going to say app get install putty and then oh that was very bad i missed the i'm i hit the slash key instead of hitting the enter key and this will show me though that if you want to go back to a previous command hit your up arrow and if i hit my up arrow i get my last command back and then i'm going to pass backspace over that slash that shouldn't have been there and then enter and then it says could not open lock file permission denied anytime you see something with permission it means you the user pi just on your own you don't have the permissions you need to do the command and so you can't just install something using a command like app get what you have to do is you have to go into super user mode and you use a super user do which is sudo which is su for super user do okay so i'm going to sudo i call it sudo just because it doesn't sound as silly as sudo but most people say sudo so forgive me if i say sudo but i'm going to say sudo and then what apt get install putty all right and what this is going to be doing is me pi i'm going to put myself in super user mode and then i'm going to app get install putty and i'm going to see if i get rid of those those errors and it looks like i did it says that it's reading them it is doing some different stuff this operation will do things it looks like it's reading things unpacking all that's really good and boom so now let's see if we can run putty so i'll say p-u-t-t-y and see if that thing will pop up and boom here is a little terminal and in this terminal i could put in a ip address and then i could log on to a different computer that is on my network and so that's a nice little thing putty okay now what if i want to get rid of it well there i would say i would say apt get get and then i would say remove and what do i want to remove putty but what do we figure is going to happen it's probably going to want administrative privileges how do i give it administrative privileges with sudo sudo apt-get remove putty and let's see what that does okay looks like it is going in there are you sure you want to continue yes i want to get rid of that and then it will go in and it will uninstall it so what have we learned we've learned how to find our way around the file system using cd we've learned how to look at what's inside of a directory by putting ls and we have learned that d print working directory gives us the full path name of the directory that we're in and boom it looks like that we have uninstall putty which is uh which is good we'll probably put it back on later but i'm just showing you i don't know if i can do this now but sometimes when you uninstall things it doesn't get rid of them completely so what i can do is app get app get and instead of remove you can do purge and so you could say app get sudo apt get purge putty and that would absolutely completely get rid of everything okay and so here you can see that it looks like it actually found some things in there to to get rid of okay and okay looks like it now has has gotten rid of everything so i usually don't do sudo apt get remove i usually do sudo apt get purge because you end up with all this like remnant nonsense on your computer and when i get rid of something i want to get rid of it as completely as i possibly can and it seems like on both windows and linux that it's just hard to absolutely positively remove something once you've installed it but purge on linux is better than remove at least that has been my experience okay so we have found how we can move around the file system and we understand root we understand the squiggly we understand cd we understand ls and we understand pwd well like if i look at my files here i really don't have any files these are all folders what if i wanted to just create a file i could create a file by just saying touch and i could touch my file like that okay touch my file now if i do an ls there is the file my file now because i created it using touch it is flat out completely empty file it is just a file with a name it is completely empty okay well how would i get rid of that empty file i would say rm for remove and then remove my file like that and then i do an ls and you can see that it is gone okay but let's just create some files let's say i'm going to create touch my file one and then touch my file file two like that and then ls there they are like that okay and let me touch let me touch my file my file my file three okay and else there they are so you can see that i created all of those i created all of those well it's kind of uh it's kind of bad practice to not put a extension on your file because what is this is this a python pro program is this a text file is this a picture so you want to kind of put extensions on your uh you want to put extensions on your file names but uh but what do i have to do here would i go delete all of those and then come back and put extensions on them you could do that or an easier thing would be to rename them well how do you rename something in linux will you rename something in linux actually you rename something in in linux by moving it you move it from the old name to the new name so i'm going to mv for move i'm going to move my file 1 to what my file dot t t x t okay and now if i do an ls you can see that i have the my file.txt so now it is a txt file and then i could do the same thing i could do a move my file two to my file to dot txt you see move is the way that we rename things now how can i do this quicker i could hit the up arrow to get my old com my old uh command back and i could put the three here and then come over and put the three and then ls and boom you see now i have the extensions on there by using the move command now what i could also do is i could move it to a new place and that wouldn't rename it that would take it and move it to a new place and so what would be a new place well let's say that i create a directory so let me let me go down into documents and so i'm going to change directory into documents and you probably won't have anything there i've got a few things there from earlier and so uh ah i don't want to do that let me change directory dot dot okay now i'm back in my home there's those i want to make a directory right here and what i'm going to call that directory i'm going to call it scratch and so i'm going to make directory maker mkdir and what do i want to make i am going to make scratch like that just a place for me to play around in and now if i do an ls you can see that i have my three text files and then i also have scratch okay i also have scratch and so that's pretty good now i'm going to change down into i'm going to change down into scratch okay and now ls there's nothing here now i want to move those files i want to move those files into scratch well how would i do that i would say envy and now if i just said my file three dot txt what's the problem it's gonna look inside of this folder where i am the scratch folder and it's not going to see my files 3. you always have to give the path to what you're looking for because just because you know where my file 3 is that doesn't mean that linux knows where my file 3 is and so what we're going to do here is we are going to back up and we've got to give it a path well one way i could do it is i could just say go up 1 now i would be in the slash home pi my you know my folder and so dot dot takes me up to that and then take my file dot txt and then move it where move it right here to where i am my file dot txt why do i not need a path name on the second one because on the second one i want it to go into the folder where i am and so i don't need to put a path name and then if i do that and now ls there it is my file.txt what's another way i could do it well i could say mv and i could go all the way back to root and then i could go to home and then i could go to pi and then i could get my file 2 dot txt and then where do i want to move that i think that i need to make this higher so it's going to keep going behind my head i think so i'm going to do it like that i think you can see that good now okay so i'm going to move i'm going to go all the way to root and then go to home and then to pi and then there is my file dot txt and where do i want to put that well i could put a path on it so i could go i could go to the let's say that i could go up and now i'm in the pi folder and then back down to scratch so if i go up and back to scratch i'm already in scratch that's like a round trip right it doesn't do anything but i'm just showing you the different ways you can manipulate this and then i will put it in my file too i could also call it myfile2copy.txt like that and now if i do an ls you can see that i've got my file to copy.txt and myfile.txt and now if i do a cd dot dot and i go back up you can see that the only thing left up here is file three because i'm actually moving them okay i'm actually moving them so now that i've moved them what if i want to move it from right here well if i want to move it from right here i just say mv now i don't have to give it a path because it's in my working directory file3.txt and then where do i want to go well i want to go down into scrat scratch scratch like that and then i want to go to my file three dot t x t like that and then l s it's gone change directory cd into scratch change directory into scratch and now ls and there are all my files now putting that copy on there that is not really that great so i'm going to move mv my file to copy.txt and i'm just going to move that to my file 2.t xt like that so i'm renaming it ls now i've got my file 2 my file 3 and my file dot txt does that make sense i think that is pretty cool now that's the move the copy works a lot like a lot like move but let's say that i did copy my file dot txt and where do i want to copy it i want to copy it back where it was so i'll go copy it up back up okay and then my file.t xt like that okay and now ls you can see that it's still here my file is still here but now if i do an ls i don't want to go up and come down so i'm just going to ls my home folder my slash home slash pi i'm going to ls it from here by just doing ls.up1 and then like that okay and there is the myfile.txt which was copied up there and it remains in the existing folder so copy makes a copy and you have it at the new place and the old place and move takes it and puts it in the new place and you just have one you just have one copy okay let's see some other things we could do let's say i went down into change directory pictures like that okay now what happened okay i need to go change directory dot dot now i go ls now i'm going to do change directory into pictures okay now i can go peek inside of the scratch folder without actually changing over there and looking at it and then come back and i could do that just by saying ls and then where is scratch well i would go up one and then down into scratch and then it will show me what's over there but notice i'm still in the pictures folder or i could say ls and i could do the squiggly down to scratch and it does the same thing or i could do ls all the way back to root and say root to home to pi to scratch and there it is does that make sense so you see that the key of knowing how to do things in linux is keeping track of your path and also you've really got to be very very mindful like let me go back and let me i'm gonna from here put another i'm from here going to put a uh a folder let me see i'm gonna ls dot dot okay and so you see i've got still got my file.txt up there okay well what if i want to delete that what if i want to delete something i delete something with rm okay i delete something with rm for remove so what do i want to remove i want to remove go up one and then i want to remove my ah that was bad i hit the up arrow by by mistake remove and then i go up one and then i want to remove my file dot txt like that and then ls dot dot okay i think you can do ls.dot or ls dot dot slash those will be the same in that case okay now i'm going to go ahead and go up one so i'll go cd dot dot and then ls and now let's uh let's look at what's inside of scratch so let's do ls scratch like that okay ls cannot access scratch what happened i put the leading slash which told it to go all the way back to root and then in root it didn't find scratch and so one of the commonest mistakes that i find among new students who are here learning unix is not being deliberate about when you put the leading slash and when you don't you see like if i'm just going something slash something slash something and you put the leading slash that's telling it to start at the root and a lot of times you don't want that you only want to put the leading slash if you deliberately want to start it well if you wanted to do that you would say ls if you're going to go to root you would have to go through home through home and then through pi and then to scratch like that okay and then it's happy then it makes all those things all right and so now let's just see what we have here i showed you how to remove something okay well what if i wanted to remove and i showed you how to make a directory right mkdir what if i want to get rid of that directory okay what if i want to get rid of that directory well what i could do is i could say remove directory remove directory mdr room dir remove directory i hate being such a munchkin there let's see if you can see it if i get a little bit i think you can see that all right i'll make this go up a little bit but i feel it's impersonal if i get that small okay okay remove directory remove directory and i want to remove scratch okay remove failed because it's not empty wow you cannot you cannot remove a directory that's not empty so i could come here and i could change directory and i could change directory into scratch and then ls and i could say our i could say rm my file dot txt like that and then ls and i could remove those one at a time okay i could remove them one at a time but that would take a long time so let me put that one back in there so i'm going to put it back by saying touch my file.txt so i put that file back in there and now i've got those three files how can i get rid of those all at once well what i can say is remove and what i want to remove is everything so if i say star dot txt like that it's going to remove star is the wild card so star is going to remove it's going to remove star wild card anything dot t x t okay so let me do that and then i do an ls and you can see that there's nothing in there well let me put those things back in there so i'm going to say touch i'll just say file 1 dot txt touch file two dot txt touch file three dot t dot t x t and touch file four dot p y okay now i'll do this and you can see that i have four files well if i do an rm and if i do an rm star if i do an rm star dot txt what happens it removes everything except the pi file because it was wildcard dot txt so anything dot txt it got rid of all of the txt files but not the dot pi file so let's put them back in there so i'll just say touch file one dot t x t touch file two dot t x t touch file three dot txt and then i do an ls and look at all those okay now i'm gonna go up one just to show you okay cd dot dot now i can delete them down in the folder without being in the folder how would i do that well i could say remove and this time i want to remove everything dot everything so any prefix and any suffix i'm going to remove but where do i want to do that i've got to give it a path in in scratch okay in scratch i want to remove in scratch the star dot star and if i do that now i look that is my uh that is my uh existing folder what is that big pink thing that just showed up that is a screen capture because when i tried to hit shift while ago i hit screen capture and so we got a picture we got a picture in our home folder now which is that long pink file name but i digress so let's change directory into scratch and you can see that it's empty now now let's see if i did that let's see if i if if i did this i could also just say okay touch file one dot txt touch file two dot txt touch file three dot pi oops uh oh i misspelled it touch i'll three dot py what am i i keep misspelling it touch file three dot p y there it is touch [Music] file four dot file four dot p y okay now let's do an ls and you can see i've got two text files and i've got two python files all right now let's go cd dot dot now what i could also do is i could do a remove in scratch scratch i could remove what just star it i need a slash start and star it's not like anything and a dot in anything star is just anything and so that's going to remove everything ah i got to go change plus okay so i am going to say remove [Music] okay i don't know why it didn't work the first time oh i misspelled scratch that scared me pretty bad because i thought this should work i'm sitting here looking like really cool and calm but i'm thinking that should have worked all right so now i'm going to ls scratch like that and you see there's nothing in it because the star just took everything out the star took everything out all right now the one thing you never ever want to do is you never want to like make directory you never want to make directory and like call it my directory okay never ever ever have a space in a file name and never ever ever have a space in a folder name because you're just going to really really really mess things up you're either going to get an error when you create it or you're going to get an error when you try to delete it or you're going to get an error when you try to access it and so you can just really really really mess up your system by putting spaces in file names and so what i like to use is i like to use bumpy font and so i would call this like my directory and with bumpy font the first letter is lowercase and then the first letter of every new word is uppercase so this would be like my little picture like that that would be fine and then like t dot uh jpg or something like that you you could no i'm sorry i'm making a directory so it would be my little picture directory you could do something like that or you could touch and you could touch you could say go down into go down into scratch and you could create inside of scratch don't put that leading thing there scratch go into scratch and then create my picture dot jpg like this then change directory scratch and then ls and then there is the mypicture.jpg and also you see that linux color codes the types of files and so you can see here that when i have this uh when i have this jpeg it colors the file pink showing you that it's a picture just like this png and then just the text file show up as white and the python file show up as white so there's a little bit of color coding going on here okay well let me make some let me make some more things here we're in scratch so i'll just say file one dot t x t and then touch file two dot t x t and then touch file three dot t x t okay and then change directory dot dot all right now we go ls and you can see that there is scratch and remember that we wanted to remove that directory earlier and that's why i was showing you how to delete the things out of it and then after you delete the things out of it let me go ahead and do that so i'll say remove yeah remove in scratch and i'll say remove star dot star so anything dot anything i am having trouble spelling today remove scratch i needed the slash there like that okay now it's happy ls scratch and now that it is empty i can say remove rmdir scratch and now ls you can see now scratch is gone but you can't remove the directory unless you get everything out of it first but let's make scratch again so i'm going to say cd and i'm going to say mkdir make directory and i'll make scratch back like that ls okay there there is scratch okay now i'm going to change directory into scratch [Music] like that and now i'm going to touch file one dot t x t i wonder if i can do two at once or if you can do that hey you can okay i'll go like that and now i'll call this one file three and i'll call this one file four okay change directory dot dot ls okay scratch and you can see there's all those files in there although no no no no that did not work that was bad that was bad because what it did was it created a file name with a comma as part of the file name and so that was a that was a mistake shouldn't do things on the fly but um you can see uh you can see that i've got now these complicated things well what i could do is i could just do a rm dot star it would remove everything okay or just to remove star i could get rid of them that way but now the thing is i want to remove scratch and i want to remove scratch without having to delete everything in it and then deleting it can i do it in one step well you can but instead of doing re remove directory you just say remove and then remove recursively which is minus our remove recursively minus r and i want scratch okay like that and what that does is that removes everything in it it's sort of like you and the horse you wrote in on okay it gets rid of everything out of scratch it gets rid of all those files out of scratch and it gets rid of scratch itself so now if i do an ls you can see that scratch is gone okay scratch is gone okay let's play around with this a little bit more let's do an ls or let's do a let's do a make directory and we will make our scratch again okay we'll make our scratch again and now you know how we did like the touch we did the touch and let's do uh i guess i should go down in it so i'll say change directory scratch like that and now that i'm down in it i can say touch uh let's say my dogs dot txt and then touch my cats dot t x t and then i could say touch dogs dot pi like python program and touch touch cats dot py like that okay now i've got all those empty files what can i do well i can edit them and i can put things in them but if i look at them i can look at the contents by using the cat as in catalog so if i say cat dog stop pie there's nothing there it's empty or cat catalog cat stop pie there's nothing in it well how do i get something in it i can edit it and the raspberry cut pie comes with an old school text editor called nano and so you can edit things using nano so i'm going to nano i'm going to nano my dogs dot txt okay and now you see this comes up and i can start i can start making notes here these these were my dogs okay my first dog when i was about seven or eight years old was spook a very big wonderful belgium shepherd and then i had a german shepherd named susie and then after that i had spook number i had spook number two and then after spook number two i had a dog called little sweet and then i had a dog called ginger and little elmo and now my dog is indigo and i have another dog named dutch so i have two dogs right now and so right now this is a tally of the dogs of my life going back to like seven years old and i've always had a dog and so one two three four five six seven uh eight dogs have taken me through my life and that kind of makes sense dog lasts dogs don't live as long as we would like them to okay but i have digressed and so you can see that the the file name the file name is mydogs.txt i've done this but now i need to save it okay how do i save it well i hit control o and what that does is that saves it it says file name to write well i started it as mydogs.txt so it says do you want to save it as that well yes and so i will click enter and now it has saved now how can i exit ctrl x to exit and i'm out of there now if i say cat my dogs dot txt like that it shows me what i've got there or i could nano my dogs dot t x t okay and then i'm back in here editing it again all right and let's just say that i changed this and i didn't say spook number two but just spook space 2 like that now what if i exited without saving i put ctrl x to exit without saving it says don't you want to save it save it yes or no so you see i can put a yes or no i'll put a y for yes and then it says do you want it under my dogs.txt well yes i'll put it there and now cat my dogs dot t x t like that okay now let's do the same thing let's nano and let's remember exactly what we call these nano let's uh nano cats are nano my cats dot txt like that and say i have no cats cats are evil never trust a cat okay control x control x yes enter cat i cat my cats.t xt and boom i have no cats cats are evil never trust a cat okay we can also nano those python programs so what were those we look ls i could nano let me do this too i'm going to go all the way back to root so i'm going to cd back to root and now what i can do is from there i could i could nano and i could nano cat stop pie but the problem is it's not going to find it why it needs a path so where would i go i say here i'm already in root so i could do it home slash pi slash cats i could do it that way and it would find home because i'm already in the root or even if i'm in the root i could still put the leading one either way would work but let's do it without it and there we are and uh now we're going to edit cat stop pie and so i'm just going to say print and then i'm going to say cats are evil like that okay control x yes okay now i'm going to change into home i'm going to change directory into pi i'm going to change directory into downloads okay now ls now how would i run cat stop pi from here well to run a python program you have to say python and i want a python cat stop pi but what's the problem it's not in this folder so what do i need to do i need to navigate to the folder well from downloads i would go up one i would go then down into scratch and then i would run cat stop pi and why did that not work let's uh this is a rather shocker let's do nano nano dot dot slash scratch slash cats dot pi like that how did did i not save that okay somewhere i've made a mistake so i'm going to go back to scratch change directory up up down to scratch okay ls okay and then i am going to i am going to uh nano cat stop pie it's empty so i'm not sure maybe i didn't save it print cats are evil you guys probably saw what i did wrong but i am not sure what i did wrong so i'm going to control x yes enter and now i'll just run it from here python cat stop pi and cats are evil boom first little python program that's next week's left lesson is python but we're playing around here and then we are going to let's just say now let's go from scratch let's go up and into downloads like that and now ls nothing is in downloads but from here i can nano and i can nano i can nano go up and then go down into scratch and i can nano dogs pie okay and then i can print i love [Music] dogs okay control control x yes enter and now i can instead of nano i can python python scratch dot dog stop pi i love dogs boom okay so you see i ran the python program from this existing folder what else could i do i could python now let me just start i shouldn't be hitting the up arrow so much i could python and i could get there to there from where from slash which is root home slash pi slash scratch slash scratch slash and then what did i call that dogs dot p y like that so i'm going to go all the way back to the root i'm in download so i'm going to go all the way to the root come back to dog stop pie and boom i love dogs okay guys do you see how this works this is pretty darn cool okay let me go back over there so i'm going to say cd dot dot slash scratch okay and now what i'm going to look is i've got those i've got the cats and dogs and i've got my cats and my dogs well i could do and i i could do a make dir and i could make my dogs directory and make der i could make my cat's directory and then i could move and i could move what i could move star slash star slash i wouldn't do it that way i'm in scratch so i would say star dot dogs and where would i want to put that i would want to put that in dogs so anything that ends in dogs i'm going to put in dogs okay and let's see what happened there oh i'm sorry i would put i would put uh this gets more interesting this i i wasn't thinking when i did this so let's do an ls okay and i've got dogs and i've got cats and i've got cats and i've got dogs and so uh let me do this differently i am going to uh i'm going to remove remove directory cats remove directory dogs i'm going to make directory text files and make directory make directory python files okay now what went wrong you see what kind of went wrong on me is i was thinking that i could sort things on cats and dogs but you can see this dogs has a lower case and this dog's has an upper case and so it wouldn't be easy so i'm going to i'm going to sort things on whether it's a python or a text file so now i can say move the star.txt and where do i want to move those i want to move those to to yeah let me make sure did i make them yeah okay so i made the txt file what happened to my python file so i need to make directory oh i see that i put the make dir upper case and it didn't take so make directory python files like that now i do a dir and you can see i've got python files and text files so now i'm going to move i'm going to move the star dot pi to python files like that so move star dot pi anything ending in dot pi moved python files ls okay now i say ls python files and you can see that they're there okay now i need to move the text file so now i'm going to say move and guys i'm going to give a path i'm going to give a path all the way back to home slash pi root home slash pi slash scratch okay slash star dot i'm going to move that up a little bit further for you okay star dot what do i want to move this time i want to move the text file star.txt and then where do i want to move those two well i want to move them to let's say that i want dot dot that's up one okay and then i could go down into scratch that's exactly where i am now and then go into the text file and then it should put them there and now ls text file and there they are ls and i've just got the folders okay and so some of those things in there i was kind of giving it a complicated path name just so that you could see how to do that so let's see we have done a nice amount of things today we've done the print working directory we've done the cd we've done the cd and ls with path names you understand the path names we've made a file we've renamed a file we've deleted the file we have recursively removed things we have done a lot but the main thing is understanding those path names and understanding when it's relative to where you are now and when you're referencing back to root if you're referencing back to root you use the leading slash and then you've got to guide it all the way back down but i am hopeful that this sort of made sense and so man this has been a lot of good stuff that we've learned but one of the really frustrating things that i had as i was trying to learn to program they would just jump in and start typing in all of these linux commands and i had no idea what that dot.net or all those slashes or all those different things so if you sort of see how these path structures work and i showed you them to you for several different commands as you're learning new commands and going forward i think a lot of it will make a whole lot of sense because we've kind of laid the foundation here and i hope you kind of had fun with that what your homework for next week is your homework for next week is to go in and play around with like the things that i've done here and you know go up go down work your way around the linux file structure using the cd using the ls making files deleting files moving files copying files just play around with that until you're really really comfortable with it okay lesson number two we've completed we have the fundamentals in one session we have the sort of essentials of linux that you've learned in one section next week what we're going to learn is we're going to learn the essentials of python now you know i've done like a 50 lesson series on python and some of you guys are already really experts you guys that are experts i still hope that you'll tune into these lessons maybe look in the comments maybe answer people's questions you know participate be a part of the channel and then it will be in the fourth lesson where we jump in and we start actually actually what we'll do in the fourth lesson is we will start accessing these gpio pins on the raspberry pi and so we will take the sun founder ultimate raspberry pi kit and we'll start using components and we'll start connecting things to the gpio pins now it's not quite as straightforward as it is on the arduino the arduino is really built around those gpio pins and you just send commands and it works but there's just a little bit a little bit more that you have to do on the raspberry pi side but what we will be doing in lesson number four we'll start learning how to use components that are in the sun founder ultimate raspberry pi kit connecting them to the gpio pins on the raspberry pi and then programming things in python and so we will be sending commands to things like sensors and actuators and leds and lights and speakers and we'll be reading things from sensors and potentiometers and things like that and so we'll be reading from things doing things in computation and then writing to things and that is really what the focus of these lessons is going to be is how to make these uh gpio ping pins sing and dance okay guys hey i do always want to thank you guys that are helping me out over at patreon really appreciate it it's a huge encouragement to me i have a link down below to my patreon account if you want to hop on over there and hook a brother up help me keep this great content coming if you enjoyed these lessons make sure to give them a thumbs up if you haven't subscribed to the channel already make sure that you subscribe when you do ring that bell so you'll continue to get notifications when new lessons come out in this series and as always share this with other people because the world needs more engineers and more programmers and fewer people sitting around watching silly cat videos paul mcquarter i better get back to the river view okay we always sign off with a river here no uh no fishermen out there today but yet still a beautiful scene paul mcquarter from toptechboy.com i will talk to you guys later
Info
Channel: Paul McWhorter
Views: 60,969
Rating: undefined out of 5
Keywords:
Id: 8kg3xIifMN4
Channel Id: undefined
Length: 61min 59sec (3719 seconds)
Published: Thu Mar 17 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.