MODULE 2.0-BASIC LINUX COMMANDS, CREATING DIRECTORIES

This tutorial will focus on some of the basic Linux commands and most especially the basic Linux commands on how to create directories. Creating directories is one of the day to day activities of a Linux administrator.

Let’s understand some basic concepts

Types Of Users In Linux

There are basically two types of users in Linux, they are the root user and other users

1. The root user

The root user is a superuser. A root user has access and privileges to all kinds of files on the system. A root user virtually owns the system because a root user has access to everything on the system. There is only one root user in Linux with the username “root”. When you are logged in as a root user, you can easily tell by the “#” sign.

2. Other users

This is the opposite of a root user. Other users are ordinary users, though, some ordinary users may be given root privileges. This user does not have the kind of high privileges a root user has on the system.

There are some certain actions ordinary users can’t perform and certain files ordinary users can’t write to except given the right privileges to. There can be many ordinary users on a Linux system. When you are logged in as an ordinary user, you can easily tell by the “$” sign.

At this point, we will start with the basic commands by learning how to confirm or know who you are on the Linux machine, to do that, you use the command “whoami”

 # Whoami 

From the output of the command, you can see who the person/user is. The username of the person that runs the command above is “tomisinuno” and you can tell that the user is an ordinary user with the $ sign.

You will also notice that anytime a user logs in, the naming style is always “username@hostname”

There is also the system user which are user accounts used by services or processes. We will get to understand more about it as we go on in this course.

Other Basic Linux Commands

some other basic Linux commands are below

# mkdir

This command is used to make directories.

What is a directory In Linux

Compare directory as a folder on a windows machine. A folder is where you put in other folders or files. Right? It’s called a directory in Linux.

I remember attending a kick-off meeting of a project I was going to execute, things went well in the meeting, but in the middle of the project, some things didn’t go as planned so everywhere was hot, a lot of pressure was in the air due to the fact that it was a core banking deployment and deadlines must be met.

I mentioned a folder in my course of explanation and the next thing I heard was “why mentioning folder in a Linux project”. The gentle man said, “Are you not a Linux guy?”, why mentioning folder? Lol. If i remember correctly, I immediately changed my terms and was cautious of using the term directory instead of folder. I kept wondering in my mind why one would keep to such kind of details. could it have been the pressure or could it have been as a result of the fact that he was unhappy with Microsoft?

Well, In Linux world, It’s called a directory and have it at the back of your mind that a directory is also a folder. In the course of this series (Linux Fundamentals / Learn Linux from scratch), I may use the two words interchangeably but it means the same thing.

Now that we know what a directory is, Let’s make one.

Login to your system and run the command,

# mkdir HR_DEPARTMENT 

Now, you have successfully made the HR_DEPARTMENT directory

# ls

This command is used to list the contents in a directory. To see the “HR_DEPARTMENT directory created, one will need to list the content.

To list the content, run the command,

# ls 

You can see the content, i.e, the directory we just created in the user’s home directory

# pwd

pwd means present/print working directory. This command is used to verify the current path a user is.

NOTE: anytime one login, by default, your present working directory (pwd) is your home directory

To see the present path you are presently in, run the command,

# pwd

You can see that you are actually in a directory before you created the HR_DEPARTMENT directory. In my case, I am in “/home/tomisinuno” directory. As we go on, you will know the difference between a directory and a mount point. I may come back to say this exact statement to clarify things. Put it at the back of your mind so when you see it. We already talked about “/home” in our previous lesson.

How Does The Linux Command Work

The Linux command is separated into three parts

1. Command:

2. Option (- is used to specify options)

3. Argument.

For instance, I can say,

wash. (Wash) in this scenario is the command

I can also say, wash properly. (Properly) is the option

Or say, wash properly the blue shirt. (The blue shirt) is the argument.

Let’s be practical. Following our previous example,

run the command,

# ls -l HR_DEPARTMENT 

ls = command

-l = option

HR_DEPARTMENT=argument.

From the screen-shot above, you can see that the total is 0 because there is no file nor any directory in the HR_DEPARTMENT yet.

Options in Linux

There a lot of options associated with a Linux command. An easier way to get to see and use options in Linux if you can’t remember them offhand is to use “- – help” after the command.

For example, to get the options of the “ls” command, run the command,

 # ls  --help 

Another way to see and use options in Linux is by using the manual page. Linux has manual pages for almost every command used in Linux.

To be realistic, you can’t remember all the Linux commands and options. There are over 1000 commands not to talk of options. But the good thing is there are “keyword” search and manual pages in Linux. Hence, nothing to worry about. I will talk about the keyword search with man in another module.

To get the manual page of any command, we use the “man” command.

For example, to see the manual page for the “ls” command, run the command,

# man ls 

Use the enter or space bar key to continue scrolling down, to quit, press the “q” key.

Basic Linux Commands

Continuing With The Basic Linux Commands

continuing with the basic Linux commands, other basic Linux commands we have are below

# rmdir

This command is used to remove an empty directory.

# rm –r

This command is used to remove a non-empty directory.

# pwd

This command is used to print/present working directory.

# cd

This command is used to navigate from one directory to the other

# cd ..

This command is used to navigate a directory one step backward.


Using Basic Linux Commands With Examples

1. remove the HR_DEPARMENT directory

# rmdir HR_DEPARTMENT 

2. create IT_DEPARTMENT directory

# mkdir IT_DEPARTMENT 

3. change directory to IT_DEPARTMENT

# cd IT_DEPARTMENT 

4. create the NETWORK_TEAM and STORAGE_TEAM directory in the IT_DEPARTMENT directory.

# mkdir NETWORK_TEAM
# mkdir STORAGE_TEAM 

5. change directory to storage team and create the EMC_STORAGE_TEAM directory and NEXUS_STORAGE_TEAM directory.

6. go back to the NETWORK_TEAM directory and create CISCO_SWITCH_TEAM and DELL_SWITCH_TEAM

Can you see the process I went through before I could go back to the NETWORK_TEAM directory?

What if I were to go back to IT_DEPARTMENT directory, will I keep doing cd..?

At this point, you should know that you can always change directory to any path even if the directory is long from Africa to Australia as far as you know the path.

In our examples, you will notice that I always do “pwd” to know my present working directory. If you know your present working directory, you can also always know how to navigate yourself to wherever you want to.

Therefore, form the STORAGE_TEAM directory, to change directory to IT_DEPARTMENT, for now, we do

 # cd /home/tomisinuno/IT_DEPARTMENT 

Now from the IT department, create the IT_DIRECTORS directory

# mkdir IT_DIRECTORS 

I believe we can now create directories in Linux, to make things easier in this lesson, beginners should sketch the architecture.

See below the architecture of what we have been doing.

NOTE: The graphical user interface (GUI), a friendly interface, just like windows can also be used for all of these operations. Unfortunately, most customers, especially the enterprise servers running critical applications won’t give you the GUI platform to work with. Even in the windows environment sometimes, you will be left to work with the command line and (PowerShell).
So, we are gonna master the CLI first before mastering the GUI which will just be like reading A, B, C.

Class Activity 2.0

1. Again, using the architecture above, create the directories. This time around, to differentiate it from the former, add the letter “S” to all the directories you will be creating.

2. from the IT_DEPARTMENTS directory, change directory to
• NEXUS_STORAGE_TEAMS
• CISCO_SWITCH_TEAMS
• IT_DIRECTORSS

Cheers!!!

NEXT MODULE: CREATING FILES USING THE BASIC LINUX COMMAND

Your feedback is welcomed. If you love others, you will share with others.

2 Comments

Leave a Reply

Your email address will not be published.


*