File System Hierarchy of Linux



What is File System Hierarchy Standard?
The File system Hierarchy Standard (FHS) defines the directory structure and directory contents in Linux. It is maintained by the Linux distributor.

All files and directories appear under the root directory /.




Example:



/ -Top Level Directory

It is the main directory of Linux operating system. All directories work under the top level directory
and it contains the all data base of Linux operating system.

/root –Root Directory

It is a home directory of root user. It contains all database of root user.





/home –User Home Directories

It is the home directory of all normal user. It contains the all Information about all normal user. Whenever you create a user then a directory of user is created automatically under the home directory.

/boot –Static files of the boot loader Directory

It contains the all information about all booting files, boot loader and kernel.

/etc–Host specific system configuration

It contains the all information about all configuration files of server and services.

/bin -Essential User Command Binaries 

It contains the all information about all those command which  can be run by normal user such as mkdir, clear, ls etc

/sbin-System Binaries

It contains the all information about all those command which can be run only root user and restricted for the normal user Such as fdisk, useraddetc

/usr-User Utilities and Applications

It contains the all information about all application software programme which you have installed in your computer.

/dev-Device Files

It contains the all information about all hardware devices which you have attached in your computer.
such as : /dev/hda
/dev/cdrom

/media –Removable Media

It contains the all information about all removal devices such as CD-ROM, Pen drive etc.

/proc–Process Information
 
The procfile system is a special file system in linux operating systems that presents information about processes and other system information. It doesn't contain 'real' files but run time system information (e.g.system memory, devices mounted, hardware configuration, etc)

/var–Variable Directory

Files whose content is expected to continually change during normal operation of the system—such as logs, spool files, and temporary e-mail files.

/tmp-Temporary Files


It contains the all information about all temporary files which are create automatically in the computer and after reboot system all the data will be lost.

/opt –Add-on Application software package

It contains all the information about all third party software which you have installed in your computer.

/mnt–Mounted file system

It contains the all information about all removal devices in temporary such as external HDD, Pen drive etc.

Head Command in Linux

In this article we will learn about Head command in Linux which is most use in log check and read top selected line as per requirements.The head command reads the first ten lines of a any given file name.

Command 1:- The basic syntax of head command is:

#head [options] [file(s)]

For example, the following command will display the first ten lines of the file named ‘head auth.log‘.





If more than one file is given, head will show the first ten lines of each file separately. For example, the following command will show ten lines of each file.




Command 2:- If it is desired to retrieve more number of lines than the default ten, then ‘-n‘ option is used along with an integer telling the number of lines to be retrieved.

For example, the following command will display first 3 lines from the file ‘auth.log‘ file.



In fact, there is no need to use ‘-n‘ option. Just the hyphen and specify the integer without spaces to get the same result as the above command.



Command 3:-The head command can also display any desired number of bytes using ‘-c‘ option followed by the number of bytes to be displayed.

For example, the following command will display the first 45 bytes of given file.

# head -c45 /var/log/yum.log

Jan 10 00:06:49 Updated: openssl-1.0.1e-16.el




Tail Command in Linux


In this article we will learn about Tail command in Linux which is most use in log check and read top selected line as per requirements.The tail command allows you to display last ten lines of any text file. Similar to the head command, tail command also support options ‘n‘ number of lines and ‘n‘ number of characters.


Command 1:- The basic syntax of tail command is:


# tail [options] [filenames]

For example, the following command will print the last ten lines of a file called ‘auth.log‘.





If more than one file is provided, tail will print the last ten lines of each file as shown below.



Command 2:- You can also print the last few lines using the ‘-n‘ option as shown below.





without putting "n" in command, it command will give same result as shown below.



Command 3:-You can also print the number of characters using ‘-c’ argument as shown below.

# tail -c5 access.log 

ymantec.com:443 - NONE/- text/html

MKDIR command in Linux


Linux/Unix mkdir or “make directory” command is used for creating directories/folders on the filesystem. This is a simple and frequently used Linux command.




Command 1 :-
To Create a new Directory

Use mkdir followed by new directory name to create directory in current location.

$mkdir test






Command 2 :- To create multiple Directories

Creating multiple directories in current directory in single command. Below command will create three directories test1, test2, test3 in current directory.

$mkdir test1 test2 test3

Command 3 :- To create directory at specific location

Create directory to other location without changing current directory. Type full path of directory like below.

$ mkdir /var/www/folder1/public

Command 4 :- Create Directory with Intermediate Directory

The above command will failed with mesage “mkdir: cannot create directory `/var/www/folder1/public’: No such file or directory”, if any of intermediate directory does not exist. In that situation use -p option to tell mkdir to create intermediate directories if not exists.

$ mkdir -p /var/www/folder1/public

Command 5 :-Create A Directory with Specific Permission

During creation of directories, you can set specific permissions using -m option. This is similiar to use chmod command.

$ mkdir -m 644 test1
$ mkdir -m a=rwx test1
$ mkdir -m u=rw,g=r,o=r test1


Command 6 :- Create Multiple Directories at Specific Location

This is very lesser known option for creating multiple directories on different location with single command. This will create directories named one, two, three in test1 directory.

$ mkdir -p test1/{one|two|three}

How To Reset Root Password On CentOS 7


In this Article we will learn that how to reset root password on CentOS 7. The way to reset the root password on centos7 is totally different to Centos 6. Let me show you how to reset root password in CentOS 7.


Step 1 – In the boot grub menu select option to edit.

Step 2 – Select Option to edit (e).








Step 3 – Go to the line of Linux 16 and remove rhgb quiet and then type init=/bin/sh.




Step 5. mount -o remount,rw / and then check through df -h command

Step 4 – Now press Control+x to start on single user mode.



Step 5 – Reset the password.

passwd root

Step 6 – Update selinux information

touch /.autorelabel

Step 7 – reboot

exec /sbin/init



Now you have successfully reset root password of Centos 7.

Hope this article help you to fix issue.

Linux Network Configuration in Linux/Centos


Today we will see in this post that How to set up network configuration in Linux/centos such as How to assign Static ip address, How to assign gateway, how to assign DNS, How to change hostname in linux. It's very easy to assign static ip address, DNS, Gateway and Host name. Please read full articles if you face any problem regarding this articles so please leave comments or drop email within 24 hours you will get reply by our team.

Please leave comment if article good and share it also.



To check hostname in Linux/Centos:

[root@localhost ONS]# hostname

To change hostname temporary in Linux/Centos:

[root@localhost ONS]# hostname newhostname

To change hostname permanent in Linux/Centos:

[root@localhost ONS]# vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=localhost.local --------> please change localhost.local into newhostname.local (according to your requirement)

To restart network service in Linux/Centos:

[root@localhost ONS]# service network restart



To check ip address in Linux/Centos:

[root@localhost ONS]# ifoconfig

To assign static ip address temporary in Linux/Centos:

[root@localhost ONS]# ifconfig eth0 192.168.1.250 netmask 255.255.255.0

To assign static ip address permanent in Linux/Centos:

[root@localhost ONS]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

View this detail

DEVICE="eth0"
BOOTPROTO="DHCP" 
HWADDR="00:0C:29:56:4E:9E"
MTU="1500"
NM_CONTROLLED="yes"
ONBOOT="yes"

Change some configuration:

DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:0C:29:56:4E:9E"
IPADDR=192.168.1.253
NETMASK=255.255.255.0 or PREFIX=24
MTU="1500"
NM_CONTROLLED="yes"
ONBOOT="yes"

To restart network service in Linux/Centos: 

[root@localhost ONS]# service network restart

To assign Gateway ip address in Linux/Centos: 

[root@localhost ONS]# vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=localhost.local
GATEWAY=192.168.1.1

To assign DNS ip address in Linux/Centos:

[root@localhost ONS]# vim /etc/resolv.conf

nameserver 192.168.1.1 or 8.8.8.8

To restart network service in Linux/Centos: 

[root@localhost ONS]# service network restart

Note: Please don't forgot to restart service of network because it will update own recent changes.

Hope this will help to all of you and resolved your all query if you have any query or question so you may ask on email our email account (onlinenetworkssolution@gmail.com) or leave comment on page.

Most useful basic Linux/Centos command


Today we will see in this post that basic command in Linux/Centos. It's very easy to create, change, modify and delete files and directory. Please read full articles if you face any problem regarding this articles so please leave comments or drop email within 24 hours you will get reply by our team.

Please leave comment if article good and share it also.



Please follow all command of linux:

To create a directory(dir):

[root@localhost ONS]# mkdir ram

To enter in any directory:

[root@localhost ONS]# cd ram

To come out from directory:

[root@localhost ONS]# cd ..

To come in top level directory from any directory:

[root@localhost ONS]# cd /

To check the current working directory:

[root@localhost ONS]# pwd


To clear the screen:

[root@localhost ONS]# clear

To check the list of files and directory:

[root@localhost ONS]# ls

To check the list of files and directory permission:

[root@localhost ONS]# ls -l

To delete a blank directory:

[root@localhost ONS]# rmdir ram

To remove directory with his subdirectory:

[root@localhost ONS]# rm -r ram

To check the terminal:

[root@localhost ONS]# tty

To check how many users login on computer:

[root@localhost ONS]# who

To check currently login user on your prompt:

[root@localhost ONS]# whoami

To Eject the CD/ROM and DVD/ROM:

[root@localhost ONS]# eject

To insert the CD/ROM and DVD/ROM:

[root@localhost ONS]# eject -t

To mount the CD/ROM and DVD/ROM:

[root@localhost ONS]# mount /dev/dvdrom /mnt

To dismount the CD/ROM and DVD/ROM:

[root@localhost ONS]# unmount /dev/dvdrom /mnt


Hope this will help to all of you and resolved your all query if you have any query or question so you may ask on email our email account (onlinenetworkssolution@gmail.com) or leave comment on page.