Linux: Open the programs menu and search for “Terminal”. So don’t let the prospect of using the command line for the first time intimidate you. The commands you will learn in this lesson are very straightforward. You’ll soon see that this isn’t as difficult as you may think. In this introductory lesson to the command line, you’ll learn how to navigate around your computer and how to manipulate files and directories (also known as folders) directly from the comfort of the command line. It has a syntax of its own to learn, but since you’ll be entering the same commands dozens of times, you’ll quickly pick up the commands you need most. The command line is like our base of operations, from which we can launch other programs and interact with them. While there’s no need for you to reenact the scene above, working with the command line is a critical skill for you to learn as a developer. That black screen or window is the command line interface (CLI), where you’re able to enter commands that your computer will run for you. We have this image of developers staring intently at a black screen with white or green text flashing across as they wildly enter incomprehensible commands to hack into the corporate mainframe (no doubt while guzzling soda and wiping neon orange Cheetos dust off their keyboard). These are some of the basic stuff you need to know when you are just starting with the command line.Feeling scared of the command line? You’re not alone. You probably want to learn about deleting folders as well. That's all you need to know about making a folder in the Ubuntu command line. You can force mkdir to create folders with specific permissions: mkdir -m 755 new_dir I hope you are familiar with the concept of file permissions in Linux. This is a bit advanced topic for you at this stage. :~$ mkdir -p dir1/dir2/dir3īonus Tip: Create directories with specific permissions It creates the parent directory if it doesn't exist already. The -p option of the mkdir command can be used here as well. Imagine that you have to create a certain directory structure that has a directory inside it. :~$ lsįile2.txt my_dir new_dir Create nested directories This way, your script won't fail because the mkdir command doesn't return any errors. With this, you won't see any errors if there already exists a directory of the same name. This is where the -p option of mkdir comes into play. If a folder by that name already exists, your script will fail because of the error it shows. And in the script, you have to create a certain folder. Imagine you are writing a script that will be used on other systems and by other users. Mkdir: cannot create directory ‘new_dir’: File exists If you try to create a folder that already exists, you'll get an error "mkdir: cannot create directory ‘new_dir’: File exists". This is a common problem when you are writing scripts. :~$ mkdir new_dir/another_new_dirĬreated directory only when it doesn't exist already I'll create a new folder under this new_dir folder from the same position. I have a new_dir folder in my current location. If you want to create the folder in some other folder location, you'll have to provide the absolute or relative path to the location. The above two examples create new directories in the same location as your current one.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |