5/02/2016

Creating Directories in Linux

In this post we are going to discuss [1] how to create a directory, [2] create multiple directories at once, [3] create a directory inside a directory which does not exist.

Create a directory
#mkdir <directory name> command will create a directory. You can check it by issuing ls command.

I created a directory called dirA, then its seen by ls cmd.

Create multiple directories at once
#mkdir <directory name1> <directory name2> . . . . .  command will create multiple directories at once in the same directory. Note the directory names are seperated by space.

I created 3 directries namely dirB, dirC and dirD.

Create a directory inside another that does not exist

#mkdir -p <non existing directory>/<directory name> command will create a directory inside non existing directory. Note the directories are seperated by / forward slash.


I created dirF inside dirE which does not exist. Verify it by ussuing ls command.



Summary
#mkdir a
#mkdir a b c d
#mkdir -p a/b
tags: create directory, mkdir, mkdor -p, multiple directories, linux, unix, fedora, unbuntu, rhel7, redhat, rhcsa, rhce, system adminsitrator, system engineer, india

5/01/2016

Absolute path / Relative path

We have seen how the directories and files are organized in Linux in last post. Today we are going to learn how we refer a particular file or directory in 02 ways.



Absolute path
Always begines at / and ends at a single file specifying all directories and subdirectories between them.

for example, the absolute path for message file is
/var/log/messages

Relative path
A path related to your working directory.

for example, the relative path for message file for a user in var directory is
log/messages


Summary

Absolute path: starts from root
Relative path: starts from working directory 
tags: absolute path, relative path, linux, ubuntu, fedora, redhat, rhcsa, system admin, engineer, programing, cd, india


The file system hierarchy

In Linux, all files are stored inside directories and directories are structured in a tree system which is call File System Hierarchy. 

The main directory is root. which is reffered as / mark. and the branches are directories and sub directories.

under root there are certain directories named bin, boot, dev, etc, home, root, run, sbin, tmp, usr and var.



Directories and contents

/etc          configuration files
/tmp        temporary files kept for 30 days
/root        home directory for administrator
/home     regular personal, user data and configuration files
/dev        h/w configuration files
/boot       files needed in boot process
/run         runtime data for processes started after the boot
/var         variable data which are unchanged between boots (cache,logs)
/usr         installed s/w, shared libraries

Summary

All directories are stored in a tree format. Root is at the top of all. There are fixed special directories, which are used to store certain types of files.
tags : file system hierarchy, /boot, /bin, /dev, /etc /root, /usr, /var,  linux, ubuntu, fedora, redhat, rhcsa, system admin, engineer, programing, cd, india

 

How to see the commands executed most recently

When we are configuring something through command prompt, we may want to know what we have done or  up to what level we have gone so far. There is a specific way you can see them. 

The history command displays the list of previously executed commands. Each has a reference number that is just a number in the sequence in which it invoked.


after typing history command, the output will be like this.



Another point here is you can call a command by a reference number without typing the actual command. call ls | wc - l > a.txt by a number 863. You must put ! mark in front of the reference number.


Now you see the command is called by a number.

Summary

1. history is used to list commands executed recently.
2. Can call a command from the list by the reference number !number
tags: commands executed most recently, history,  linux, ubuntu, fedora, redhat, rhcsa, system admin, engineer, programing, cd, india