NDG Linux Essential - week 6 - part I


Welcome to my 6-th week of my NDG Linux Essential which cover working with files and directories. As noted previously on my recent articles related to my NDG Linux education, this course is a preparation for LCPI - 1 exam for becoming Linux System Administrator. Unlike the previous NDG Linux essential weeks, the article for week 6 of my NDG education is going to be published in two parts due to complexity of this week and subjects which it covers. I have completed it on my NDG dashboard but since this module it's self is somewhat bit complex that the previous one, it requires to write a separate report in two part. In short, I have worked with commands such as  pwd, cd, ls, mkdir, cp, mv,  rm, touch, cat, the following commands are the most common used commands when using Terminal. Final word in this intro is that the both article are going to be covered in video for my YouTube channel where I shall briefly comment it as well as my final exam.  

Written by: Amar Tufo
8. July 2017

NDG Linux Essential module 6 is successfully completed and as I have noted above, I had final exam of 10 questions to complete this week which is also finished and will be included at the end of this article. I don't know how much are you familiar with Linux terminal but this was one my favorite module of Linux education, working with Terminal and the following commands such as: pwd, cd, ls, mkdir, cp, mv,  rm, touch, cat and etc. Without knowing this commands you can't navigate trough Linux Terminal. I shall show you each command in example just to get idea of what each command does. 

1) pwd - currenty working directory

pwd command is useful since it allows you to see your current working directory. Once typed in Terminal, it gives you the following output:


Image 1: pwd command shows the current working directory in this case it's /home/amar
Image source: local/home/amar/Desktop

2) ls - list a content 

Once you find out you're current working directory, you may wanna list the directories that your home folder holds and here we are using ls command. Don't underestimate ls command, this is one hell of command which is very powerful since it have lot of options which will be demonstrated in this article.


Image 2: listing content of /home/directory using ls command
Image source: local/home/amar/Desktop

Let assume that you wanna show all hidden files and folders that begin with .gconf, in this sample you wanna show the hidden folders as well as .gconf folder of you're /home directory. You are gonna use command ls -a which will look like this.


Image 3: Listing hidden files/directories using ls -a command
Image source: local/home/amar/Desktop

What if you need to sort the files by it's size. Than you will use the ls -lS command to sort the files. Take a look at image 4.


Image 4: Listing files by it's file size using ls -lS command
Image source: local/home/amar/Desktop

In this figure you need to note on two major things; First I have used a absolute path to access Desktop using cd /home/amar/Desktop and then I have listed the file contents on my Desktop using ls -lS command which sorted the files by it's size. In this case, the biggest file on my list is movie.mp4.  Also you need to note on the numbers of my movie.mp4 file (498787589). What are these numbers. They're the size of movie.mp4 but they are very difficult to read so we need to sort them by human readable size. We can achieve that by using the ls -lSh command which will sort the files by human readable size (in MB for example). 


Image 5: Listing files by it's human readable size using ls -lSh command
Image source: local/home/amar/Desktop

Here's a few notes on image 5 when it comes to sorting files using ls -lSh command. Note on the image above where it was estimated the contents size on my Desktop total 864 MB instead of 883868. Now, note down bellow that numbers in front of my movie.mp4 file have changed as well where it writes 476 MB which is estimated file size instead of 498787589. Now you can read the files sizes in bits, bytes, kilobytes, megabytes, and gigabytes as well. All you have to do is to enter this very useful ls -lSh command. 

3) cd - navigate to directory

When it comes to cd command there is nothing so special to mention about this command only it let's you to navigate to certain directory. Only thing here to note is the absolute and relative path. I have already mention what absolute path is and how to access certain directory using absolute path. This is absolute path: cd /home/amar/Desktop


Image 6: Accessing Desktop using absolute path cd /home/amar/Desktop
Image source: local/home/amar/Desktop

Note

Absolute path begins from (/) directory.
Relative path begins from present working directory.


Image 7: Accessing ndg_lab directory on Desktop using relative path
Image source: local/home/Desktop

Short note:  In this case (image 7) I have set Desktop as my present working directory and I wanted to access ndg_lab subdirectory on Desktop. I have achieve this using the following command and this is:

cd /home/amar/Desktop/ndg_lab

And this is how you access to certain directory using relative path. 

4) mkdir - make a directory

This command simply creates a new directory on Desktop or in your home directory.


Image 8: Creating YouTube directory on Desktop using mkdir command
Image source: /local/home/amar/Desktop


____________ Final words for part 1______________

Ok. This is all for my part I of NDG Linux Essential - week 6 -. In the second part I shall cover the remaining commands such as cp, mv,  rm, touch, cat, since writing this article in a single part would be way to big to write and to read as well. I will also publish my final exam for module 6 of NDG Linux Essential course as a separate article so that you can see the exam for you're self. This is all for today. Make sure to follow me on my LinkedIn as I have make an amazing articles from Linux education as well as my YouTube where you can find some useful tutorials on basic Linux commands and etc. 
Share:

No comments:

Post a Comment

My Twitter news

Popular Posts

Recent Posts

Unordered List

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  • Aliquam tincidunt mauris eu risus.
  • Vestibulum auctor dapibus neque.

Pages

Theme Support

Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.