Monday, 10 July 2017

Welcome to my second part of NDG Linux Essential course which is preparation for LCPI - 1 exam to becoming Linux System Administrator. I have recently write a first part of NDG Linux Essential - week 6 - part I so make sure to read it first before moving on my second part. In this part I'm about to show you the rest of commands such as cp, mv,  rm, touch, cat, and example for each of this command to get idea what they do and what is their purpose. After this part, I'm about to publish separately final exam for module 6 in .pdf file so that you can see it and experience some of the Linux questions from this course in first hand. Let's begin!

Written by: Amar Tufo 
9. July, 2017

1) cp - copy

We are beginning with command cp which is used for coping files and folders from one location to another on your home folder. In the following sample I'm about to copy a empty file foo.txt from Desktop to directory named foo

Image 1: Coping foo.txt file to foo directory via cp command 
Source:  local /home/amar/Desktop

In short, this image above shows entire process of coping an empty file named foo.txt to foo directory. I have also used ls command to list the foo directory content so that you can see what's inside, in this case, an empty foo.txt file.

2) mv - move or rename

There is a god reason why you need to now how to use mv command. This command allows you to move files and directories or renamed them while moving end so on. In the following sample we are going to move image.png file to foo directory on Desktop. See the image 2 down bellow:

Image 2: Moving image.png to foo directory via mv command
Image source: local /home/amar/Desktop

In short, I have moved image.png file via mv command into foo directory. Now as I have mentioned above, mv command can be used to rename the files and directory as well. In the following sample, I'm about to rename foo directory into image directory using mv command. See the image 2.1 down bellow:

Image 2.1: Renaming foo directory into image directory via mv command
Image source: local /home/amar/Desktop

There you go, now our foo directory named has changed into image directory. Now our image directory has his child file image.png. Pretty amazing, don't you think?

3) rm - remove a file or directory

Well, there is nothing so special about this command and I assumed that most of you are already familiar with this command and how to remove a file via rm command. Just in case you don't know, here is the sample. In the following sample I'm about to remove image directory with it's image.png file from Desktop using only rm  command. See the image 3 down bellow:

Image 3: Removing image directory from Desktop using rm command
Image source: local /home/amar/Desktop

Short note, the following command 'rm -rf -v image' has successfully removed image directory with it's content, image.png file. Only thing that might confuse you is -v argument in front of rm -rf command. It's a verbose and it tells you that image directory was removed, it informs about action that just happened. 

4) touch - change a file timestamps 

One easiest way to create an report.txt file via Terminal is using touch command. Although it changes a file timestamps, this command allows you to create a file as well. In the following sample we are going to create an empty report.txt file on Desktop. See the image 4 down bellow:

Image 4: Creating empty report.txt file on Desktop using touch command
Image source: local/home/amar/Desktop

In the following image 4.1 you are going to see how I modified creation time using touch command. See the image bellow:

Image 4.1: Modifying time creation of report.txt file using touch command
Image source: local/home/amar/Desktop

Here's a short note, in the image 4.1 above I have used the following command touch to create a report.txt file. Such file was created on 18:09:13 | 10 July. Using the touch -m report.txt command, I have updated creation time to most recent on my system clock as you can see, the report.txt file is now created on 18:12:38. That's it. For more about touch command please visit man touch.

5) cat - concatenate files and print on the standard output 

Now, here's a command which you can use to write and read to a file using echo command. Since our report.txt file is empty, in the following sample we are going to fill it with some text via Terminal. See the image 5 down bellow:

Image 5: Writing to report.txt file using echo command
Image source: local/home/amar/Desktop

Short note: In this sample I have write a text 'This is NDG Linux Essential course by: Amar Tufo' into report.txt file using echo command. At the end, I have used cat command to read a report.txt file via terminal and as you can see, the text was successfully written to a file. See the image 5.1 as well:

Image 5.1: Report.txt file fill with simple message using echo command
Image source: /local/home/amar/Desktop

This is, now you know how to write to a file using echo command and how to read it using cat command via terminal. 

___________________ Conclusion: ___________________

We came to an end of my NDG Linux Essential course - week 6 - official reports in two parts. Hopefully now you know how to use some most common Linux commands such as pwd, cd, ls, mkdir, cp, mv,  rm, touch, cat, and I hope as well that you're not gonna stop it here. Linux is a vast and unexplored area for those of you willing to chase a career in Linux weather it's a Linux kernel developer, Linux system administrator or better, Linux app developer. But it's all to you, how much you are willing to learn in order to master Linux and to become a Linux ninja. Let me know in comments down bellow. Share some of your interesting Linux experience, I will be glad to share them via my YouTube channel and social networks. That's it. Thanks for reading and see you next time. 

And remember, choose wisely, choose Linux a system that works!

0 komentari:

Post a Comment


My Twitter news

Follow me on Facebook:

Popular Posts