GMT20200901 222307 CTS1111C L 1920x1080

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so i'm signed in to rhs1 i'm signed in as the student account and i'm in my home directory so what we're going to do is start working on links so someone sent me an email in regards to i'm missing a file that the lab refers to so in this section of the book it refers to a file called new file.txt so if i do a list i don't have that file so i'm going to do touch new file dot txt list and now i have the file the touch command does two things i'm going to do a list long new file if this file already existed it would just update the access time that's what the touch command is designed to do if i do touch dash help i can change the time if i wanted to using this format so this dash t switch so i could do touch new dash t 18 57 um november first new foul i'm doing something wrong i'm at 12 57 so this is the year this is the month this is the day this is the hour military time and this is the minutes so new file so this file was last used november 1st 1857. so there's stamps you know you hear a lot about this forensic stuff is really irrelevant so the purpose of the touch command is to update the time but if the file doesn't exist it creates it so if you if if the system refers to a file that doesn't exist like this lab that we're doing touch it and then you'll be good to go okay so i have this file called new file.txt and there's one copy of the file right there that tells me there's one copy of this file because what we can do is create something called links we have two types of links uh symbolic links in heart and in um hard links sometimes a symbolic link will be called a soft link and i'll explain the difference between those two so first thing i'm going to do is do a hard link and i'm going to specify ln for the link command the source file and the destination will be the temp directory new and just to make this clear hlink2.txt to stick with what the book is doing so basically i have this chunk of data on my hard disk and when i look at my directory this term new file points to that chunk of data so now i'm going to have two pointers pointing to that chunk of data on my hard disk this will point to that chunk of data and this will point to that chunk of data that's a hard link basically two pointers to the same file as long as one of them exists that file will still exist okay so i'm going to do list long new file dot txt so right now i have a two right here that's telling me that there's two pointers to that um um chunk of data that actual the actual text file i'm gonna echo something into that file just so we can see it has some content so normally if i type this it comes out on my screen here i'm redirecting my output to that text file so it's going to insert the word something into that text file if i cut the text file i can see it has something in it if i cut the other link it also has something if i echo something else into this file and i cut the other file i can see they both have the same content so both files point to the same both of these directory entries point to the same file that's a hard link there are limitations to hard links a hard link could only exist on the same partition there's a i know discussion in the book you can you can read that but if there are um if there's a hard link that hard link can't cross different partitions it has to be on the same physical partition but i've had this discussion with a bunch of other people you know nowadays we don't really have a lot of uses for hard links um if you want to back up a file to make sure no one accidentally deletes it you can do a hard link and that's gonna make sure the file still exists so right now if i delete this file this one right here as long as this exists i can still access that file so i'm going to delete that rm to remove that file and then i do a list temp new file kind of think of a hard link as two pointers to the same file now if i do a list long this i can see there's only one pointer to this file the other type of link that we have is a soft link so i can do i'm going to remove this temp new file so i've just deleted the last pointer to that file you can actually see i know by doing a list dash i but i'm not going to go get into an indoors discussion so i'm going to create this file again what is this command going to do um no let's do this if i type history how can i rerun this command what do i type to rerun that command put it in the chat box 42 yes so bang 42. just a reminder if you talk i it will be part of the recording as long as you don't care i don't care so that's going to recreate this file there it is now i'm going to do a soft link or a symbolic link i'm going to the source file is new file and the destination where the soft link will be will be new file soft link dot txt so if i list long new file i can still see there's only one pointer to that chunk of data to that file so this link right here points to this link this link points to the actual file so if i delete this this will point to nothing so you know there's there's actually going to be an issue if you delete the original file if you delete the original file at that point the link won't do anything it's just going to point to another link and that link normally would point to the file if we delete it it's gone there'd be no way to access that file but the benefit of doing a soft link over a hard link is it can cross different partitions because it's not pointing to a chunk of data on the hard disk i can point this pointer to a pointer on another partition so you don't have that benefit with a hard link but you do with the soft link it can go across different partitions you'll come across links every once in a while if i do a list dash long uh to the root directory here's a link right here here's a link right here here's a link right here so if i so i can do a link to a directory as well so i'm going to make a new directory new dir and i can do a link uh symbolically the source is neutral this other directory it's going to be a relative path will be a new der soft link now list long so if i go into this directory right here it'll actually take me into this directory so i'm going to cd into new der softlink if i touch a blank file if i go up one level then down into neuter and do a list i can see the blank files there so anytime i do anything in this directory right here i'm really making a change to this directory so you can link directories or you can uh link files so i'm going to go to the next chapter the next section the next section is a lab a lesson eight is a lab that you're going to be doing again if any of the directories or any of the files aren't there you can create them so i can see that in your lab it wants a directory called files i don't have a directory called files so i can just make their files if it wants me to create a file inside of that directory i can do touch files and the file that they want is source file so you can make any directory structure or any files that you want so someone had moved ahead in the lab that's fine okay here's here's a lab that confuses a lot of people we're in lesson nine lesson eight is a lab that you're going to do lesson nine is is something we're going to do together i'm going to remove dash rf nudar if i list long this directory the soft link that pointed to that directory doesn't exist that's why it's blinking red so i'm going to remove that as well i'm going to remove that file now we're going to do something called shell expansion so i'm going to create a bunch of files um so we can uh look at them i'm trying to think of the best way to do this without confusing you i'm going to make a directory called working i'm going to go into that directory i'm going to for i in this is easier to read on the screen so i'm going to use this syntax sequence 1 to 200. i'll explain this in a minute do touch video dollar sign i dot mpg done list long okay guys if i run this command alone sequence one to 200 all that command does is print out the words one to two hundred that's all it does spits out one to two hundred so i'm gonna go back to this command i had it in three lines i'd hit enter here i hit enter here enter here but when i go into history where i hit enter to put a semicolon so it puts it all back into one line so i'm going to do a for loop and the element in the for loop is going to be 1 to 200 because this is just going to spit out 1 to 200. what i'm basically saying is execute this command because i've enclosed it in dollar sign brackets before executing the outer command which is a for loop so the first time through the loop four will be one the second time uh excuse me the first time through the loop i will be one the second time through the loop i will be two then three then four then five all the way to two hundred so basically i'm going to first time through the loop touch video one dollar sign i is referring to this variable and the first time through the loop i will be one so it'll be video one.mpg then videotube.mpg this is it's created a bunch of blank files dot video1.mpg through video 200.mpg uh if i list i can see them all so i'm going to do another loop for i in dollar sign bracket sequence 1 to 200. i'm going to hit the enter key then i'm going to say do everything between do the word do and the word done is going to be part of my loop so i'm going to say touch picture one excuse me dollar sign i dot jpeg done so it's going to create picture one picture two picture three all the way to two hundred if i list my directory i create a bunch of files okay so i can do list p asterisk so that's going to show me all my files starting with p it's going to exp it's this is called shell expansion that's a wild card character i can do any file that starts with picture and has a 1 or 2 as the next character dot jpg now this is any one character so basically it's going to show me picture one and two it's not going to show me 100 or 101 because there's two characters here that i'm not accounting for so if i wanted to see any file that was started with the one or two and add any two characters after it so this will be 100 101 102. this won't show me picture one or two because there's no character after that and ends in jpg this will even include 200 because it fits that criteria it has a 2 and then 2 characters after that and ends in jpg how we doing with that so far i'm looking at the text okay so the next thing i'm going to do is i'm just going to create um a bunch of files just to match what the book is doing touch alpha bravo charlie every once in a while guys in this virtual environment when you type a character might print it a bunch of times so when i hit space command it uh hit a bunch of spaces uh delta echo able baker cath dog easy so i have several files here i want to see all the files that are only four characters long sorry list four characters long i want to see files that are three characters long three characters long okay i want to see what did this do so what is this going to display videos 1 video 1.mpg video2.mpg video3.mpg if i hit enter it's going to show me those three videos i could put this is called the carrot symbol which means not so basically i want to see any video that is has a word video any one character that's not a one two or three and ends in dot pmg so this will show me three four five six uh excuse me four five six seven eight nine it won't show me 10 because 10 has too many characters here what if i did this the same exact thing i'm going to do 4 i in sequence one to two hundred do touch videos dollar sign i dot jpg uh well whatever um now let me do that again mpg done i could do it all in one line okay i press ctrl c to cancel that command list videos excuse me video digit asterisk so that's going to be any file starting with the word video and the next character is a digit not a alphanumeric and then anything at the end so that won't show me any file that has videos so i could say alpha so that's going to show me all the videos plural but not show me anything that that is video than a number this is an interesting one i don't use this often list tilde what is what is that till to normally um do in regards to your home directory does anyone i could do cd tilde and i can go to my home directory so if you do a list tilde and then the user account name it will list everything in that user accounts home directory clear i'm going to go out of my working directory and delete it and this will delete all those files so basically what i did was i went up one level that which brought me back from the working directory to my home directory and then i deleted that directory if i do make now that was shell expansion now i'm going to um that shows you how to filter out certain things and i used um square brackets to do that uh this is not a really good example let me think of a better example now i'm using curly brackets and i'm separating the elements in this so that created week one and these are squiggly brackets two three four and i can see those down right here let me see if this will work make dir week sequence 10 to 100 less long no it didn't really work but it was worth trying let me try something else no it's still not working okay but um so if you want to create multiple elements i could do something like that i could do um i could also do this with the touch command video one two three four five list and it created those five files so if you have to make a bunch of directories or a bunch of touch uh touch a bunch of files then at that point i could um just use that those brackets guys i was testing something here it didn't work i was testing something here and it didn't work i wanted to see if i could do um a double execution so basically anytime you see the dollar sign one bracket and then a dollar sign i mean a dollar sign bracket some command then a dot then another bracket that means execute that first before executing the outer command it didn't work in those cases but i tried okay so now i'm going to play around with the variable um brian equals person echo dollar sign brian so you can set up a variable by saying the variable name and what it equals i could do the date equals and here i'm going to execute this command it's going to replace this with the actual date and save it in that variable echo dollar sign and there's the date so it could be i could have some output of a command be saved in a variable as well and that's what i did right here generally if it's upper case it's an environmental variable set by the system if it's lower case it's something you you created ad hoc if i type env it shows me all my environmental variables so these are variables set by the system when you boot up the machine like my current user or when you log in my current user account is student so now i can echo dollar sign user and get the value for that variable these are all set by the system so if i'm just using a variable um just temporarily for some script that i'm writing i probably would keep it in lower case so my var equals something dollar sign my var sorry echo my var and basically this is just like an ad hoc variable guys when you use a variable you put the dollar sign in front of it when you set it you don't put the dollar sign in front of it and they have some sort of uh elaborate example in the book which is kind of nice um echo two days is date plus percent sign a so again before it runs the echo command it's going to run this command first replace the output of that with tuesday this will be replaced with tuesday then is gonna echo today is tuesday i'm going to create a variable called today echo dollar sign today echo today is today saying if i enclose it in double quotes it still works but if i enclose it in single quotes it doesn't work so double quotes will resolve a variable to its value before echoing what you're doing if i close something in single quotes it's absolute i'm saying this is not a variable i want you to echo dollar sign today so that's an absolute value normally when the shell sees a dollar sign it's going to assume anything after it is going to be part of the variable name until the next space i can interpret by using the escape key normally the shell sees the dollar symbol as the beginning of the variable name but by escaping in front of it i can't highlight um by escaping in front of it i'm going to tell it to interpret the dollar sign differently so now it's just going to interpret that dollar sign as a regular character it's a printable character that's it's not going to interpret it as a as a variable as the beginning of a variable okay guys want to start the quiz which pattern will match only file names ending with b i'm watching the chat yes wild card b ending in b which pattern will match only files beginning with b yes which pattern will match only file names where the b with the first character is not b you can use bang or carrot to indicate not which pattern will match a file name containing a b okay let me ask you this could the b be at the beginning if i choose this as my answer will this match if the file started with b yeah let's look at that i'm gonna that's kind of an interesting thing so i'm gonna touch a file called brian list asterisk b asterisk yeah so it will work for something beginning in b because essentially that wild card character will match anything okay which pattern will match only file names that contain a number yes no you got it right because but you're missing those asterisks it has to be something a number somewhere something which pattern will only which pattern will match only file names that begin with an uppercase letter i didn't go over this but yes it has to begin because i didn't put that asterisk in front of it which pattern will match only file names of at least three characters in length at least yes three characters wild card okay now this is a lab lesson 11 is a lab lesson 12 is just kind of like a reminder of the things that we did in this thing now we're going to move on to um lesson four four is a real easy chapter so guys um if you are in a jam and you need to find something out about a command what do you do how do you go about getting help for command and most most of us generally are going to navigate toward google and i'm going to do man uh i hope this doesn't come up with something okay so i'm looking that man stands for manual page linux was released under this license the gpl license the gpl license was created by richard stallman and richard stallman this is what made lennox what it is you know you can say a lot of things about all the colonel with um yeah that could have been a bad a bad search term but uh you know you can say things about linus torvel and the kernel and the gnu creating all the other stuff around the kernel but this is really what made um lennox linux what and it was created by richard stallman so basically this linux this license agreement basically they call it copy left not copyright because basically when you license something with the gpl you're telling the person who gets the the product the software that they are allowed to take that software they're allowed to make changes they're allowed to give it away to anyone they want but when they do they have to give it away under the same license so uh and the person who originally created the software is also not liable um for any damages done by using that software so what this did was it allowed people to take a piece of software write it give it to the community and at that point they wouldn't be allowed to change the license and make money off your product because at one point in time richard stallman had a piece of software he wrote it he gave it to his friend his friend made some changes then sold it to a company now at that point richard stallman wanted to make additional changes and he couldn't because now it was it was sold um to another company and they owned that product so he wanted to prevent this from happening in the future and he came up with this license the other thing that this license uh did was it said when you release this software not only do you have to give the source code for the software so someone else can make a change uh give me one second okay but not only do you have to give the source code every time you release a piece of software so someone make it can make changes to it you also have to release man pages and that's what this stands for manual pages so basically you need to describe how to um use that piece of software and in that man pages there are multiple sections so you have section one which is user commands section two system calls so you can see if that has any interaction with the the kernel library calls any special files that it needs file formats normally section six will be a little does anyone know what an easter egg is in software they used to like have mine hunter or something built into software so if you go into like word there'd be a little embedded game hidden well that started out here and basically in the main pages they would have a little game seven was miscellaneous stuff eight was um for uh like administrative commands like when we had this this command ip like ipadder there's things that normal users can do with this command and then there's things that the root user can do with this command that would be under section 8 and then section 9 you would have some sort of kernel routines so if i do man uh touch it's going to show me section one which is what a normal user would need for that command to to know how to run that command if i do man 7 touch there is no section for man seven so this section is blank let me do um man ip so by default it shows me section eight i'm hitting q to get out of that and if i do man one ip it doesn't have any section so not every command has a section for everything but when you type man and then a command it tries to show you the most appropriate section but there are only might be one section so according to the gpl they need to release these man pages with every piece of open source software how many people use android phones and are you aware that android is nothing but a linux it's a linux with a graphic front end on it but how many people use the man pages on their phone so even though it says uh you're supposed to release the man pages it is perfectly acceptable when small embedded devices like phones even your iphone is unix and it uses a lot of open source um uh software you know a lot of embedded devices they don't put the man pages in the product itself they're relying on you going to the internet to get the man pages so a lot of man pages are out on the right here it is here are some man pages and there's a bunch of websites that have all the man pages out there that you can go to and so here is a a nice section for um i guess this is the no this is just a description of the man pages but um there's a lot of websites that have the actual band pages out there that you can go to like right here die.net you know talks about the various sections then you can jump into like i and look at all those commands so this is from section three now i'm going to go into this man page guys and i can scroll up using the spacebar i can use the arrow keys and go up and down there's 203 lines here so this is the documentation on how to use the ip command and there's a lot of documentation here if you want to leave the man page you can hit q for quit and if you want to get additional help you can hit the h key and it will show you how to navigate in uh man if i hit q it'll get out of the help queue again will get out of the man they also have the info pages i never guys in in if you look read the book they tell you how to navigate and search and do things like that in the man pages uh they'll so talk about uh the very top what these sections mean like name synopsis option if you go to the very bottom uh you will get um who wrote that piece of software uh how to report a bug if there's a piece of software things like that so there's a lot of things in the man pages um i could do a search for a man page with this word in it let's say i don't know the command but i know it has something to do with the the password there's nothing appropriate let's uh i'm sure there's something with the word password in it you'll come across different versions of man sometimes man will not be compiled with the k option so it won't work so if you if you have one of those distros that that does support the k option um so basically it hasn't sorted it hasn't searched and created that little database so it knows what uh it's called appropriate basically you're searching for a command that has password in it but you'll notice that not every man is compiled with the k option actually functioning you know why because we don't really use demand pages a lot you know they have come out of favor because now we have the internet a lot of times um you'll see that we just look at help or look at the internet and i'll show you how to get to the help if i hit uppercase k it'll do a manual search for anything with the word password in it where if i look at lowercase k that looks in the appropriate database that's what it's called appropriate database the database name is appropriate um it just doesn't have that um database compound and basically they didn't include that in the uh command when they compiled it because when you when red hat made this os they took the source code for man that was released in the community and then recompiled it when they built this distro okay guys lesson two is a lab now the gnu people also created something called the info pages i can go there or i can do this so i'm just going to do p info guys i've never professionally used the info pages uh one second i read a question okay yeah someone said that that was a man page on how to write a man page so here's some sort of um little utility i'm going to press q to quit p info so i'm going to look up information about tar and it's like this little i don't want to say graphic but more interactive info page that allows you to use your arrow keys and jump to the different sections so if i want to use jump to the tutorial section i can highlight tutorial and um jump to that section and then here's more sections how to create how to do things if you want to go back you can go uh escape maybe again i never use this so i'm not sure how to get back i'm sure there's a way give me a second let me look and see if the book has it u yeah uppercase u brings you back to the parent node see right now i'm at the parent um will take me back one level i went too far sorry so if i go into uh tutorial the parent node is the main node we're going to create the parent node is the tutorial so you can uppercase u to go back one level um so it's a way to have a more interactive help screen i guess that's what you'd call it and the next lab is a the next lesson is the lab which you're going to do and the next section is the lab which you can do and that's the end of that lesson guys um also i want to point out something here i had q to get out there's before there was p info there was regular info that you could go to and it's again more car archaic but it had the same um menuing system that you could go to but you just use your arrow highlight the thing hit enter uh again uppercase u will get you back q to quit so there there's info as well but again i'm not real big on p info or info or even the man pages because most of the time i just go and do this tar h if it doesn't support dash h it might support dash h so that's another way to get some help okay guys it's at the top of the hour we're a little bit past so we're going to take a 10 minute break and then the next section is going to be um editing text files this is the the you know the thing that scares people the most so let's take a 10 minute break we're going to come back at 7 32 and i will see everyone in 10 minutes i'm gonna pause the video and okay so before they actually start talking about the vi text editor they start talking about output redirection or actually redirection in general input and output so normally if i run this command the output comes to my screen i can rerun it and redirect it to some file sorry i was repeating characters so if i cut that file the output didn't come to my screen it went to that file we normally just use greater than symbol but in actuality it's a one greater than because that means output redirection greater than a one greater than or just greater than now i could cap this file etsy password when i attack a file the apple comes to my screen so i can redirect that to another file if i can it would be essentially a copy of that file or i can cut two files and join them together and save them in one file etsy password etsy group don't worry about what files i'm i'm cutting it's not really important so now if i cactus file it will have both etsy group and etsy password in the same file if i do cat no i'll do this i'm going to do date into another file if i cut another file it's going to overwrite everything that's um in that file so even though i had etsy password the content from messy password and the contents of etsy group in that file when i did this command it erased the file and overrode it with the date if i do two greater than symbols and i'm gonna cut that file now it will append so one is um append note one is replace two is append what if i did this cat etsy group then i made a mistake and said etsy and i spelled out the full password well etsy group exists that's a real file ft password is not a file so i have two things on my screen right now i have standard out my standard output then i have something called standard error so if i echo dollar sign this is a this is called a shell parameter dollar sign question mark it will tell me the return code of the last command that i ran and it returned a one if it returns a zero that's a normal the command executed no problem if he returns a number anything other than one that's a problem has anyone ever written a c plus plus program and at the very end of your main section you put a return zero well that's what this is reading that return value in your program so what i can do is cat etsy group and etsy password again i'm spelling password wrong i'm going to send standard output to a file called out file now i'm going to do 2 greater than and send my errors to another file so one greater than or just greater than alone is standard output two greater than is standard error so if i cut out file it will show me the contents of etsy group if i cat error errors it will just show me the error code let's say i don't want to save that error code you know i want to connect these files and if i get an error i don't want to see it i can redirect my errors to a device called devno remember that the device directory holds my device drivers i have this weird device called a null device anything you send it gets trashed um back in the day we would call that a bit bucket anything you don't want to see you just drop in your bit bucket so this will save all the output to a file called out file and then any errors it will send to devnow and make them disappear so if i cat out file let me remove this um rm errors so i don't have that so if i run this command again i don't have an errors file because i didn't create it i'm hitting the tab key nothing's there but if i cut my out file i can see it says etsy group i could do something like this and append and that will append to the outfile i could go back to this command and do append here not that one i'm hitting the up arrow to go through my history if i run it again and cut errors you can see it showed the error twice because instead of overwriting i'm appending what if i wanted to send my output and the errors to the same file i can certainly do this i'm going to cut that file here is the error and here is all the other stuff uh let me see something real quick uh a head group it's kind of weird because when i did it that method it kind of corrupted the file because they're missing some things look i mean right here it cut off all this and anyways this is not the preferred method of doing sending the output and the errors standard out and standard error to the same location the preferred method would be um that's going to send my output to that file but normally we don't see that one then i'm going to say 2 redirect to the same place as one you'll see that all the time so now my outfile includes then the out standard out plus standard error or i could do this method if i didn't want to because that's a lot of typing incidentally that method i just showed you was the most common but this works as well this will send output and error to the same location if i wanted to append sorry i could do that if i wanted to append with this method i could do that oh no actually i don't think that'll work i can do this that will append to the file okay so what's the difference between what i just did and cat etsy password pipe to grep for root what's the difference between that redirecting my output and the pipe command does anyone know here i'm redirecting to a file when i do a pipe the output of this command becomes the input for this command so when you pipe you pipe to another process another command when you redirect you direct you redirect to a file so if i did tell uh i'm not signed in as root so i'm limited to what i can do etsy tail dash n one that's going to give me the last line of etsy password i could um now let me try to do something longer if i do i'll just cut etsy password and i pipe it to more so what that's going to do is it's going to the more command does one page at a time it's probably the most not it's probably not the most efficient way to do this but it'll work so i'm going to cap this and that will become the input for the more command and allow me to go one page at a time in reality it probably more efficient to do this but i'm the type of person i just always do that anyways there's a command that allows me to send my output to a file and display it on the screen so i'm going to do t etsy um cat etsy password send it to the t command so what it's going to do is it's going to take the contents of etsy password send it to this file and also display it on my screen in this particular case the output of this command is going to go into the t command the t command is going to split it off into two streams one to a file one to my screen so if i cat some file i can see it has etsy password in it the content of etsy password okay quiz time which answer displays the output to a terminal and ignores all errors i'm looking at the chat window what would you append to a command to look at the output but any errors that you get trash them do you don't know or is no one listening okay good so two greater than is errors i'm going to send it to the bit bucket which command sends the output to a file and sends the errors to a different file d all output will go to file all errors will go to file two which answer sends both output and errors to a file and cr creating it and overwriting its current contents its content this is confusing but it's not right it doesn't really do anything it's not too and it that doesn't really exist this right here will overwrite your current file because it's only one greater than symbol and it's going to send output and error to the same file so d which answer sends output and errors to the same file ensuring existing file content is preserved d is going to append and send to that file to uh to the same place as one which answer discards all messages normally sent to the terminal i didn't kind of go over this but you can figure it out instead of having any output at all it's just going to send it out it's just going to trash it so this will send errors and standard error and standard out to dev null a which answer sends output to both screen and a file at the same time b last one which answer saves output to a file and discards error messages output is going to a file standard error will go to the bit bucket this will send everything to the screen in a file then if this command has any errors send it to there but that's not going to work because the errors were over here on the pipe remember when you pipe the output is sent to become the input of this any errors that you get over here on the output let's look at that so i'm going to cut some file no let me uh echo date into some file so it's not what i wanted but look so if i catch some file it only has the word date in it so i'm going to cap this file date and also cat this file that doesn't exist so that generates some output and some error standard output and standard error so i'm going to pipe it to t now i'm going to pipe it to grep that's not a good one um i'm trying to think of another let's see if i can do echo now i don't want to say t i'll just do this so i'm going to cut this file it will generate some output then it's going to also generate an error i'm going to take the output of this which is only the date command because this is an output and send that to t so the pipe won't send errors across um won't allow errors to go across and become the input here if this generates an error that's where the air is going to be displayed it won't have any effect on anything after the pipe anything here isn't going to get that air at all so the pipe doesn't send standard air going across i hope that makes sense so this isn't really going to but if this command generated an error that will catch the error generated by t it won't catch the error generated on the other side of the pipe so our answer is the top one okay now we're going to deal with vi so let me go back to my machine i guess they do uninstall um maybe it's an alias let me see how they do they handle this okay so they do it with an alias guys back in the day we had a command called vi the eye didn't understand this portion of your keyboard let's see if that'll work uh let me see if i can get my camera to focus on that you see how i have a number pad on my keyboard vi didn't understand that so if you wanted to navigate you had to um use like um i j k to move up and down so if you install ubuntu it installs vi so if you try to hit like uh an up arrow or something it generates a weird error but in red hat systems they don't even install vi at all it automatically installs a program called vim so when you look at the bulk they tell you to run vim but when you do you're really running vi if you're in an ubuntu box that had vi installed by default and then you want and installed vim it will do something called alternatives this is the way ubuntu does it so when you run dim excuse me vi it will actually run an alternative program called vim the way red hat does it is if you run vi it's actually running a command called vim so when i keep referring to vi i'm going to be referring to vim which is vi improved vim will understand the arrow keys you can use up and down it'll use the number pad on the right you'll understand the arrow keys that we have on our keyboard where the old dim doesn't understand that so just be aware that um we're going to be using vim so the book keeps telling us to type vim and the file name well i don't need to do that because we have that alias in place you might not have that in place when you take the test so if you type vi and nothing shows up then you know why because i'm trying to arrange my other windows sorry so i'm going to do vi and a new file file.txt every book kind of has this a little bit different the way they call these modes are a little bit different right now i'm in a mode called command mode anything i type is a command it's not going to be a printable character um so if i want to go into insert mode from command mode i hit a lowercase i so anything that i type now will show up on my screen because i'm in answer mode there's a kind of a lag when i type now to get out of insert mode and go back to command mode press escape but if we really want to get technical what lowercase i does it doesn't just put me in insert mode notice i'm on the t character of that third line okay and also these little tildes right here represents nothing that means there's no blank line at all if there's a if there's no um tilde there that means it's a blank line so this is nothing this is a blank line so i'm right now in command mode i'm going to press a lowercase i and when i type do i type before the t or after on before so in so when you type a lowercase i it inserts you before your current character so right now i'm going to press escape to get out of insert mode so i'm right now in front of l so when if i hit i and i start typing those characters become um before the l i'm gonna hit i hit escape to get out of insert mode to go back to command mode if i hit a lowercase u it undoes it anything i did in the last insert mode is removed okay i'm going to now do a lowercase so let's um so i'm pulling up another thing okay so we did a lowercase i these are things you're going to have to remember these are common ones that i use all the time in vi there's a whole bunch of things that you can use but i'm going to go over the in the book also goes over the very common ones um so i'm going to hit alert i'm on the l key i'm going to hit and i'm in command mode i'm going to hit a lowercase a and then start typing so a lowercase a puts me in insert mode after my current character so they both put me in insert mode this is before my current character after my current character now i'm going to press escape to get out hit you to undo okay so now i'm on the i character i'm gonna hit a shift i that puts me in insert mode before my current character so i'm going gonna press escape undo it so there's really a lag going on here okay i'm on the a character no actually i'll go to the t if i hit an uppercase a it puts me in insert mode at the end of the line so these are common ones i use all the time press escape to get out of insert mode you to undo why why that stands for yank yank yank i'm gonna write it here i don't know where they got the name you know it's like you yanking something pulling so i'm going to i'm on the second line i'm going to do a yy it appears nothing appears on your screen but what i did was i just copied that line go give me one second yeah the book kind of jumps around with the vi stuff and i'm trying to yeah the book doesn't really go into vi at all i mean it's just superficially okay we'll we'll we'll still go through it guys this is important because i use vi all the time yeah the book doesn't really go into depth in vi at all maybe in the second book it does but you still need to know it so guys i did why why i'm going down to the third line so i copied this second line yank yy is yank so i'm going to go down to the third line and hit a lowercase p so what it did was it pasted that line after my current line so i'm going to undo that i'm going to copy the second line again yy i'm going down to the bottom line i'm going to hit an uppercase p and that paste above so lowercase p will paste below in uppercase p it's hard to see in this text editor paste a lowercase p taste paste below uppercase p paste above y y will copy keep in mind during all those commands um if i hit a lowercase p i still say in command mode i don't leave command mode to go into insert mode so yy p or lowercase um p or uppercase p keeps me in command mode now i'm going to take this third line and hit dd go to the very end and hit a lowercase p dd is cut not delete cut it puts it in memory so i can um paste it somewhere else so if you want to cut a line dd a lot of times guys i'll just hit dd and at that point just to keep with um keep with d you know and just keep moving along and never paste it anywhere so a lot of times i use it as as a delete just because i never paste it so if i hit dd then dd again at that point i'll overwrite the first thing i cut so if i hit dd here i'm gonna go to the first line hit dd then dd again if i hit paste the first line is gone p st doesn't stand for pace p stands for put okay a lowercase x i'm still in command mode if i go to this character and hit a lowercase x it keeps me in command mode but it deletes that character so x is really delete one character so now what i'm going to do is show you something called extended command mode so if i hit colon it brings me to the bottom and there's all kind of things i can do down here let's say i hit a forward line a forward slash and i type line that will do search so hit line if i hit n it will go to the next line you know the next occurrence of the word line and then again if i hit shift end it'll go backwards so that's equivalent to find if i hit a question mark then line that does the same thing as backslash as slash but it searches backwards so in extended command mode this and this are same as define command in notepad if i go hit a colon go back to extended command mode and dollar sign s percent sign s one word slash another word will replace will be essentially like find and replace if i do s percent sign s with node g at the end it'll only replace the word line with word on my current line if i use g it'll mean go global saying do do it throughout the document so in a case like that i just replaced line with word so it'll be percent sign s word to replace or words trying to move this over and what you're going to replace it with and the g at the end means global so that's equivalent to find and replace um i'm going to go back to extended command mode i'm going to hit the bank key this will tell me to execute a command in the shell environment to come back to vi so i'm going to say cat etsy um host i'm going to cut a short file it shows me the file that i just added and when i hit enter it goes back to vi let's say i want to take that output of that command and put it in this document so i'm going to go colon read bang cat etsy host hit enter not only will go out and execute a shell command it will come back and insert that text into my document at the very end i don't know if it's at the very end it might be anywhere my cursor's at i'm going to hit colon to go down to extended command mode guys and i can use my arrow keys here to go back to the last commands now it'll start it'll start it right after my cursor it's wherever my cursor is at i'm going to press escape so i know i'm not in insert mode if i cue if i uh colon to go into extended command mode and hit w it will save this file if i hit colon wq it will save the file and quit vi i'm going to go back up and rerun that command again colon q bang will exit the file if you made any changes but you don't want to save the changes you would type qbang and that's like quit but force i'm going to go back into the file sometimes guys when you're signed in as root the system could block you from saving a file but as root you can force it to write to the file because you're root you can do anything you want so i can hit w bang and that will force right i could do w bang q then a force right then quit okay um foreign guys you can go to uh a search engine and type bi cheat sheets and there's hundreds of them out there this one i i look at all the time this green one i look at all the time so if you can go this one guys is very detailed but it's it's almost impossible to read you know they talk about the arrow keys and all the things that it can do like why is yank use undo it's too difficult to read go with this red one it's relatively simple it tells you all the things that you can do with gi delete the current character 5x will delete five characters uh delete to the beginning of line it's extremely powerful right now just get used to using vi doing simple stuff another thing is guys instead of doing colon w q to get out from in command mode i can type uppercase zz that's the same as save and quit so instead of doing colon to get into extended command mode wq i can hit i just deleted so i went back into command mode i just printed the delete key like i had wq here i hit delete delete delete and that brings me back to command mode uppercase zz will do the same as colonwq okay guys this is where i'm going to stop for the day um i i don't know how well i did with that vi you know it was kind of short but we'll see how you play around with it you'll get more practice using vi when you start creating a document so i'm going to do something very simple i'm going to create a document called my script and this is what i want you to do to practice using vi so i'm going to go here and create a script called myscript dot txt no dot sh so want to create a script and then we're going to insert mode shebang that right there hashtag bang we call it shabang so i'm going to start my script with shabang bin bash that lets the shell know when they execute this script to run it in bash if i had shabang bin python it knows to execute that script with python so this is going to be a bash script so echo dollar sign one echo dollar sign two echo dollar sign zero echo dollar sign so i just created a simple script i hit i to go in insert mode and i type that stuff out i'm going to press escape to get out colon wq to right quit now i need to make that script so i can execute it don't worry about what i'm doing right now just run this command and it'll work now let me do them do that differently so i'm gonna run my script after i turn it into execution i'm gonna run my script and put two arguments after my name so i'm going to cap the script these are called shell parameters dollar sign one is automatically assigned to the first argument dollar sign two is automatically assigned the second argument so this says echo the first argument echo the second argument dollar sign 0 says echo the name of the script dollar sign number says echo the number of arguments that i have two so i want you to create a script similar to mine and use vi to do it just give you something to practice with save the script and at that point turn it into an executable script then execute it just to give you something simple to do with vi because as a system administrator we're not going to use vi to write going with the wind we're going to uh write uh text files no raphael sorry for using your name no you don't have to do it right now but whenever you practice vi just get anything you want to type it could be a a text from the book and start playing around with it uh the only way you're going to get familiar with vi is use it so right now i'm going to stop at this lesson which is lesson uh five of chapter lesson five of chapter five we're almost essentially done with this chapter um play around with vi and then we'll meet again on thursday to go over the rest of this stuff guys if we look at the syllabus i kind of have a guideline on what i'm trying to do every week so if i go to the syllabus which is one right here the first week we were a little bit behind this is where i should have been done with the first week so i'm actually getting done with that today it took us a little longer to get started so this is what i want to try to accomplish on thursday it's not that bad uh you know creating users and groups is the longest part um we'll see how far we get permissions are could be a little bit scary but we'll deal with that this is kind of a guide of where i want to be every week so guys i'm going to give you permission denied i'm gonna stop this recording then they answer your question i'm gonna pull up your lab so i'm gonna stop the recording if you wanna go that's fine if you wanna stay and start working on this with me so i can help you with questions we can do that now so i'm going to stop the recording it's going to take like an hour actually it took two or three hours last time once it's done i'll put the link up on the announcements
Info
Channel: Brian Faris
Views: 65
Rating: undefined out of 5
Keywords:
Id: zUIYUW9oswY
Channel Id: undefined
Length: 113min 13sec (6793 seconds)
Published: Thu Oct 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.