Creating Files and Directories

Imran Afzal (250k+ students)
A free video tutorial from Imran Afzal (250k+ students)
Bestselling Instructor with over 250,000 students worldwide
4.6 instructor rating • 16 courses • 247,038 students

Learn more from the full course

Linux Crash Course for Beginners - 2021

Linux System Administration and Linux Command Line

05:42:01 of on-demand video • Updated February 2021

  • Linux basic system administration
  • Efficient in basic Linux command line
  • A very well understanding of how Linux works
English [Auto] Creating files and directories in this lesson, we will cover how we can create files and directories, different ways to create files. The first one is the touch the touch command creates a file that is, of course, an empty file. The second way to create a file is if you are copying an existing file and creating a new file at the destination location and the third way to create a file is through. Vickerman now is our editor, which we will cover in detail later in the lessons. But I will cover quickly how we could create a file using V.I. creating directories. The easiest way to create directory in the command is mkdir, which is make directory. So now let's get into our Linux machine and we will use every command listed here as a practice to create our files. OK, the first thing we have to do is to find out what user ID we are logged in as you do. Who am I? And will tell you you are logged in as yourself. And then the second thing you have to know which directory you are in. And I am in my home directory now. I have I will be creating a few files. And as your whole work, I want you to create those files and directories as well. The first way to create a file here is here. I have a list of files that I will be creating. We will use the first command to create a file will be touch, touch space I have here, Jerry hit enter and you hit enter and you get the power back. That means your command worked. Now, how do we know where is that file? You do this myself and you'll see here the directory you have is right here, Jerry. Sorry, did not see the file. Now I want you to create another file. Touch Kramer again, check if it's created. Yes, it is created, Jerry and Kramer, now I use the option Ellis' minus L, which will list all the files and the directories in alphabetical order. Now, if you wanted to list all the files or directories that are created that it was last modified, you will use Ellis' minus LTI or which means give you everything by the timely order and in reverse, meaning the oldest, one of the top and the newest one at the bottom. Then you hit enter. You'll see Jerry was the first one that was created, followed by the Kramer. Next one we are creating is George, how do you verify that file was created to do Ellis L.. These files can be changed or renamed or moved, but will go to the next set of files to create. I want you to use this time to copy command. So I want to use copy. Jerry. And then the destination file, I want you to be Lex Duelist, Marcel TIAR, so what exactly did it copy this Győri file and named it Lex? I want you to do the same thing for Clark, so copy Jerry for Kramer or whichever file and do. Clark. Same thing, copy, Jerry and Lois, let's verify we have all those files. There you go. We got all six files, so now three files we created with Tushka man, three files we created with the copy command. And the rest of the files will create using VEI. Now, remember, V.I. is a very tricky. So I will only create one file and we will cover the Villeda. So the eye space homer so hit enter. Once you hit enter it will bring you to file ed now. Be very careful what you type in here because you will not be able to get out if you really don't know what you are doing. So at this point, I just want you to do shift Colen W as in right. Q As in quite an exclamation point, which is also referred to as bang hit. Enter the file. Homer is created. How do you verify it to address myself. TR And there you go. The Homer file is created. Now the other three files I will create by the touch command. Now you will notice you don't have to run touch command over and over again. You can run the test command just once and do barch space Lesa Space and May or March. So now with this just one command, it will create three files. So hit enter verified all three Fassbach Mar Lisa, all of them are in this directory. Now the next step I want you to do is create directories within your home directory. So just do just to make sure you are in home directory. Then from here you do mkdir space. Cine film. Now, the directory is created because you got you got your back, how do you whereby less Selter and you see at the bottom, that's where the directory is created. And if you notice, some of the Linux distributions also change the color for use of this way, it will be easier for you to identify which one is the file or which one is a directory. Same way I wanted to create another directory mkdir Superman. And again, you can also do the same way. Instead of running one command after the other, you could just run one command and followed by two different directories. So the second actually we have a Simpson. Simpson. And enter, once you hit and Turkey and do this myself. Here are see all three directories at the bottom and you have all your files right here now listed here. So this is the way you create files and directories in your home directory, if you try to create a directory in, let's say, slash or somewhere else where you do not have permission, it would tell you that this directory, you do not have sufficient rights to create a directory. So let's take the example. If you go to CD, slash ETSI and I want to create a file here. Let's call it test one, two, three and hit enter. Going to tell you you do not have permission to create that file in there because we don't warn Slash, who owns the slash route, owns it and you are not rude. Who are you. You are yourself in this case I have. So again you learn three, four commands touch, copy, v.i. to create files and the last command we learn to create directories is mkdir.