Having the GUI (Graphical User Interface) is fantastic for every user. You can navigate around with such visually appealing user interface, where you look for the things you need. Yet this is not really thus convenient when you are an IT guy or any one contributing in the IT sector.
There are many times then you will have to rely on command line than GUI and times when you won’t have a GUI at your disposal and you solely have to rely on command line, for instance, a server and some operating system.
Yet, if you have spent some time learning about various manipulations with files through the command line, you have noticed how many possibilities there are for computer users. With this methods at your disposal, let’s try out manipulations right away! Follow these little challenges and get a good taste of how all of these working inside the command line.
Practise using the command line interface on Windows
- Go to your user directory if you are not already there. Make a folder of any name you want, for our example let’s say the folder name is ‘Nissan’. Do this by running the following command C:\Users\ user > md Nissan.
- Run the dir command and see if the folder is created. If it is then run cd Nissan. Now you should be inside the Nissan directory where our path would look something like this C:\Users\user\Nissan >
- Use your GUI now and navigate to the Nissan folder. Do you see it? Now create a new text file there with the name skyline.txt
- Get on to the command line again, now if you are in the same directory, if not navigate to the Nissan folder again, now type copy<space>skyline.txt<space>d:\ (note that, if you do not have a D: letter drive, you should simply type in the existing name of the drive).
- Hit enter and you should have a message like ‘1 file(s) copied’ which simply means it is done.
- Now type d: and hit enter. You shall now end up in the d: drive.
- Run the dir command and see if the text is there. You should see it there.
You can always close the command line by typing exit or hitting the close button. It is absolutely fine to close it like this.
Practise your skills on macOS and Linux
Now let’s try it on or see how it is performed on macOS and Linux. Also this is a good time to use the wildcard scenario. Let’s say we have 200 files packed inside a directory called Nissan. We wanna target 50 of the files which has .txt extension in the end and want to move these files to ~/NewCars/brand folder.
- Type cd NewCars/brand to get into the right folder where we want to move our files.
- Type mv<space>*.txt<space>~/Nissan.
- Hit enter.
Of course, you won’t see any message at all unlike Windows here. In order to verify, you can run the ls command to see if the files are being copied or not.
Notes on the exercises
Note that on the first exercise/ challenges on the Windows, I set you to create the folder via command line and made you go back to the folder via GUI and create a txt file there and again instructed you to get on the CLI and navigate your way into the folder. This is first, to get you used to and familiar to the command line usage, secondly, it is different and difficult to go through the process of creating a file with it’s format like that inside the Windows. Note that how well you will be doing and mastering these commands and their usage depends solely on how much you are practicing these commands or playing around with them.