 Hey guys right now we are gonna have a look at file management from the command line and pretty much everything is a file in Linux We have normal files. We have directories. We have storage devices. We have links and so much more now looking inside the current directory I'm gonna do a directory listing right now, and I've got a couple of files of a year everything is a file in Linux So you can see that there are there are some obvious Colorization differences so looking at file a over here or file one over here and then compared to file two You can see that they are very different looking Similarly, you could see that compared to my program one in my program two They are very different and directory a and directory B are very different and if you want to get more information about a file you could use ls-l and Valuable clue of a year when you do a long listing is the value of the first bit So if it's a D it tells me that it's a it's a directory And you could see that even though it's called directory B It's a normal file because when you have When you when you have the value of the first bit of this just a dash it means that it's a normal file So you could see that file one is indeed a normal file unlike file two, which is a directory now moving on over here We have my program one and my program one Again, it's a normal file and at the bottom of a year my program two is a link file A link is a special kind of file that points to another file So I can access my program one under two names my program one and also my program two as you can see via Points to my program one other than that we also have block files block files are special files that represent real physical storage devices So let me go and show you an example of a block file So I'm going to do a directory listing against dev VDA look at the value of the first bit of a yet says B This tells me again the type of file Apart from that guys, we have the file command that could help you determine The file type so in Linux extensions don't matter So if you come across a file in your Linux file system that ends in dot exe your system doesn't care about the fact that it ends in dot exe The file content determines the file type So to help us in that case we have the file command So I'm going to run the file command against the file one. You could see it's an ASCII text file Let's go and do it against file two and over here tells us that it is in fact a directory Let's go and run it against my program one and you can see right now. It's a shell script It's an ASCII text executable and compared that to to file two over here You could see that it is a symbolic link to program one Now some of the more basic file management commands are as follows just some of them and there are so many MKDR you use this to create a directory So if you're wondering how I created the directory Directory a and file to which we know now as a directory you can make use of the MKDR command So I'm going to go and organize my work I'm going to create a documents directory and you can see that I did make use of an uppercase D And that is because file names in Linux are case sensitive So if I try to type in CD against documents right now You'll see that it won't be able to find it because it's not called documents with a lower case D And this is where I find that tab completion really helps because you don't have to go and type out every single character and also tab completion for me allows me to Avoid typos to avoid spelling mistakes So what I could do is that one more directory that I'm going to create is data with a capital D now if I type in CD to change directory and I'm going to use a capital D over here And I hit tab nothing's going to happen because we don't have sufficient uniqueness I'm going to make this more unique right now by putting in an O afterwards now I'm way too lazy to type out the remaining characters. So all that I'm going to do at this stage is I'm going to work more efficiently I'm going to tab complete it because we have enough uniqueness So you can see that it has tab completed to the documents directory So let's go into that directory right now So what I would like to do at this stage guys is that I want to copy a file into this directory So in Linux we have the CP command so I'm going to say CP and now you have to specify what you want to copy and where you want to copy it to So I'm going to copy a file called Etsy fs tab and I'm going to copy that to my current directory And again, I've got a dot of a year a period represents your current directory So I'm saying let's go and copy the fs tab file that is inside of the Etsy directory And where we're going to copy it to is right here inside of this directory So let's can hit enter over there And now we can do a directory listing and you can see that I've got the fs tab file copied If you wanted to delete a file you could make use of the RM command So simply RM and then the name of the file and there you go. It's deleted. It's a non interactive deletion It's not going to prompt you whether you are sure and there's also no Recycle bin or trash bin for you to go and recover your files. So once something has been deleted. It's gone Let's go back to my home directory the directory that I'm originally placed in when I logged in Is the home directory? So let's go type in CD right now And if you want to find out the directory that you're working in type in PWD, which is for print working directory So a directory listing one more is what we are going to be doing and you can see that we have the data directory Now let's go and use the RM command to delete that directory So I say RM DI or RM data and you can see over here that it says can't remove data It is a directory and we have another command called RM DI or which is used to delete directories However, it can only be used if a directories empty So let's go and use RM DI or against data and again We're going to tab complete this and it can see transaction was successful The job is done because in the absence of any kind of feedback assume that the command completed successfully So this stage guys the data directory has been deleted now We're going to try and do the same thing right now with the documents directory So RM DI are and we're going to try and delete documents right now and it says, okay Well, that is fine because again, it was empty if you have a directory with content and this can populate a directory right now So we're going to copy my program one and we're going to copy that into a directory called file to remember file To is a directory. So let's go and verify the contents of the file to directory We can see that my program one is inside of that So let's can use the RM DI or command right now to go and delete file to and you can see that it says can't do that Why not because it's the directory is not empty. So are you telling me that what I have to do is? Go into the directory clear out its contents and then go ahead and delete the directory Well, pretty much. That's what it's telling you. However, you can make use of another command You could make use of the RM command in that particular case Now remember I told you that options influence how the command is executed now in this case We have a very common option that a lot of commands make use of it's called our R stands for recursive Which means that we're going to apply the instruction to an object and all of the objects below it In other words, we're going to apply that to a directory and all of the files below that directory So let's go and try and delete file to in this way So guys, what's going to happen right now is that it's going to delete file to however file to has got contents All of the contents are going to be deleted as well Now it's only fair that I show you how I created this link over here the special file Where the value of the first bit is an L and that is the L in command the L in command is used to create links So what I'm going to do is create a link that points to my program one and the link has been called my program three So again just to speed things up and to avoid any typos. I made use of tab completion over there So if you think that I typed out every single character, oh, you're sorely mistaken so let's go and have a look at the contents of that directory and you could see that in This case I created a link now How I know it's a link is because I know that the link count has been increased because we have two types of links The link that I just created right now is called a hard link The other kind of link that I could create is a symbolic link also commonly known as a soft link now The cool thing about these symbolic links is that they could point to files on other file systems They can also point to directories and very often we could use that just to sort of Truncate the path to make it a lot easier to To access certain files in certain directories instead of having these long paths So let's go and create a symbolic link right now and we're going to say L end dash s and We are going to be creating a symbolic link that points to My program one and it's going to be called my program three or My program four rather So now when we do a directory listing you can see that it does indeed my program four It does indeed have an L as the value of the first bit as opposed to my program three now both are links And I know how to tell the difference. Let me just go and give you a bit of a clue over there Yeah, that number as opposed to the one at the bottom, which is my program four Which is a symbolic link and again, you can see the value of the first bit and there's I mean There's a strong visual indicator of a year that my program four points to my program one as opposed to my program three No strong visual indicator there So guys, there are lots of commands that I could show you right now as to how we would go by doing file management It's way beyond the scope of this particular video However, we have lots of learning material available for you. So I would encourage you to explore just that