Cloud Network

Networking | Support | Tricks | Troubleshoot | Tips

Buymecoffe

Buy Me A Coffee

Wednesday, August 27, 2014

Linux Booting Process and Its Init and Shutdown Command

August 27, 2014
Linux Booting Process and Its Init and Shutdown Command
Linux Booting Process

BIOS initilization
Boot Loader
Kernel initilization
Init


Boot Loader

stage 1 resides in MBR its small 512bytes 
(446 bytes of programme code, 64bytes of Partition table and 2 magic no (valid mbr)
stage 2 loaded from boot partition
for linux to boot min require
label
kernal location
root filesystem location
initial ram disk

Grub
/etc/grub/grub.conf (have these settings)

Kernal initilization
 device detection, loads device drivers, mount filesystems read only, then load init.
/etc/inittab
specifies runlevel
0    :    hault ( do not set init default to this)
1    :    single user mode
2    :    multi user mode without networking
3    :    multi-user mode with networking
4    :    unused
5    :    X11 (Graphical)
6    :    reboot
id:5:initdefault
/etc/rc.d/rc.sysinit

(selinux,kernal parameters (sysctl.conf),swap partitions, hostname, filesystem checking and remounting
RAID, LVM ,disk quotas)

/etc/rc.d/rc
/etc/rc.d/rc?.d/  (runlevel specific services )
/etc/rc.d/rc.local


1. Linux boot process.

The following are the 6 high level stages of a typical Linux boot process.

1.1. BIOS
  • BIOS stands for Basic Input/output System
  • Performs some system integrity checks
  • Searches, loads, and executes the boot loader program.
  • It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it depends on your system) during the BIOS startup to change the boot sequence.
  • Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.
  • So, in simple terms BIOS loads and executes the MBR boot loader.
1.2. MBR
  • MBR stands for Master Boot Record.
  • It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda
  • MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st 446 bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes.
  • It contains information about GRUB (or LILO in old systems).
  • So, in simple terms MBR loads and executes the GRUB boot loader.
1.3. GRUB
  • GRUB stands for Grand Unified Boot loader.
  • If you have multiple kernel images installed on your system, you can choose which one to be executed.
  • GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.
  • GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem).
  • Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is sample grub.conf of CentOS.
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.el5PAE)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
initrd /boot/initrd-2.6.18-194.el5PAE.img
  • As you notice from the above info, it contains kernel and initrd image.
  • So, in simple terms GRUB just loads and executes Kernel and initrd images.
1.4. Kernel
  • Mounts the root file system as specified in the “root=” in grub.conf
  • Kernel executes the /sbin/init program
  • Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid.
  • initrd stands for Initial RAM Disk.
  • initrd is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware.
1.5. Init
  • Looks at the /etc/inittab file to decide the Linux run level.
  • Following are the available run levels
    • 0 – halt
    • 1 – Single user mode
    • 2 – Multiuser, without NFS
    • 3 – Full multiuser mode
    • 4 – unused
    • 5 – X11
    • 6 – reboot
  • Init identifies the default init level from /etc/inittab and uses that to load all appropriate programs.
  • Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run level
  • If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what 0 and 6 means, probably you might not do that.
  • Typically you would set the default run level to either 3 or 5.
1.6. Runlevel programs
  • When the Linux system is booting up, you might see various services getting started. For example, it might say “starting sendmail …. OK”. Those are the runlevel programs, executed from the run level directory as defined by your run level.
  • Depending on your default init level setting, the system will execute the programs from one of the following directories.
    • Run level 0 – /etc/rc.d/rc0.d/
    • Run level 1 – /etc/rc.d/rc1.d/
    • Run level 2 – /etc/rc.d/rc2.d/
    • Run level 3 – /etc/rc.d/rc3.d/
    • Run level 4 – /etc/rc.d/rc4.d/
    • Run level 5 – /etc/rc.d/rc5.d/
    • Run level 6 – /etc/rc.d/rc6.d/
  • Please note that there are also symbolic links available for these directory under /etc directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.
  • Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.
  • Programs starts with S are used during startup. S for startup.
  • Programs starts with K are used during shutdown. K for kill.
  • There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.
  • For example, S12syslog is to start the syslog deamon, which has the sequence number of 12. S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog program will be started before sendmail.

2. Software Package Administration

2.1 Querying software packages

To list the installed software:

rpm -qa | less
rpm -qa {software-name}
yum list | less
yum list {software-name}

For Debian use

dpkg --list
dpkg --list | less
dpkg --list | grep apache


2.2: Installing software packages

Note: Please note that you need to log in as root to install the software using rpm command:

Installing RPM in Redhat/Fedora/CentOS

RPM is nothing but a package management system. To install an rpm file, open a terminal and then type the following command:

$rpm -ivh xyz.rpm
$dpkg -i xyz.deb (debian packages)

Installing Packages from repositories (yum/apt)

$yum install {package-name-1}
e.g $yum install httpd

$apt-get install <package_name> (for debian)
e.g $apt-get install http

Installing package from source (tar.bz,tar.bz2)

1) Extract the package using

$tar –xzvf xyz.tar.bz (.tar.bz)
$tar –xjvf xyz.tar.bz2 (.tar.bz2)

2) Go to the extracted directory $cd xyz/

3) $./configure

4) $make

5) $make install


2.3 Upgrading the software package

$rpm -Uvh xyz.rpm
$yum update <Package_name>
$apt-get update <Package_name> (for debian)


2.4 Removing the software package

$rpm -e {software-name}
$yum remove {software-name}
$apt-get remove {software-name}



3. User and Group Administration

3.1 Creating and deleting users from the systems

Note: Please note that you need to log in as root to do this task

Creating:

$useradd <user_name>

If you want to assign a particular Home directory to the user you can do that using this command.

$useradd <user_name> -d /home/<user_name>

Command line options for useradd are detailed below:



Add a new user to primary group

$useradd –g <Group-name> <User-name>

Add a new user to secondary group

$useradd -G <Group-name> <User-name>

Deleting:

$userdel <user_name>

This will remove the user. But if you want to remove all the files and its home folder then use

$userdel –r <user_name>


3.2 Creating and deleting groups

To add a group to the system, use the command groupadd:

$groupadd <group-name>

Command line options for groupadd are detailed below:


To remove a group from the system, use the command groupdel:

$groupdel <group-name>

3.3 Modifying users/group profile.

Changing the password

$passwd <user-name>

Changing the home directory of user

$usermod –d <path_of_new_home_directory> <user_name>

To change the directory as well as move the contents use –m option

$usermod –m –d <path_of_new_home_directory> <user_name>


Adding existing user to a group

$usermod -a -G <Group-name> <User-name>

Changing existing primary group

$usermod –g <Group-name> <User-name>

Changing the user name

$usermod –l <new-name> <old-name>


3.4 Linux files responsible for User managements

/etc/shadow store all the Linux password in MD5 encryptions format
/etc/passwd store all user related information's
/etc/group store all group related information's

4. File permissions/ownerships in Linux

4.1 Changing the permissions of a file
Linux have three user classes as follows:
  • User (u): The owner of file
  • Group (g): Other user who are in group (to access files)
  • Other (o): Everyone else
You can setup following mode on each files. In a Linux set of permissions is called as mode:
  • Read (r)
  • Write (w)
  • Execute (x)
However, above three modes or permission have different meaning for file and directory:
Linux Read mode permissions
  • Read access on a file allows you to view file
  • Read access on a directory allows you to view directory contents with ls command
Write mode permissions
  • Write access on a file allows you to write to file
  • Write access on a directory allows you to remove or add new files
Execute mode permissions
  • Execute access on a file allows to run program or script
  • Execute access on a directory allows you access file in the directory


Octal representation
-rwx-rwx-rwx
1st rwx is for user
2nd rwx is for group
3rd rwx is for other
So if you want to give permissions use the below table
u g o
r w x r w x r w x
1 1 1 1 1 1 1 1 1  Permissions for read, write and execute

Now convert 111 in decimal which is equal to 7

Similarly for read only

u g o
r w x r w x r w x
1 0 0 1 0 0 1 0 0  Permissions for read only
Hence 4

777 (all can read write and execute)
666 (all can read and write)
700 (owner can read, write and execute)
600 (owner can read and write)

chmod command :
$chmod 777 <file-name>
Or
$chmod u+x <file-name> - give user execute priviliges
$chmod g+rx <file-name> - gives group read and execute permission

Recursive (-R)
$ chmod -R g+rwx /u01 – gives group read write and execute to all the files in /u10 directory

4.1 Changing the ownership of a file

drwxr-xr-t 3 root root 4096 Jul 12 2001 admin
-rwxr-xr-x 1 msp ocadmin 1282580 Jun 13 11:14 asn1c-0.9.21.tar.gz

Here in the above e.g. admin is owned by user root and group root and asn1c-0.9.21.tar.gz is owned by user msp and rroup ocadmin

chown command :

$chown <user-name>:<group-name> <file-name>

e.g. $chown abdul:admin xyz.txt

If you want to change the ownership of all the files in a specific directory use –R option

e.g. $chown –R abdul:admin /abc


5. Disk Partitioning and Mounting File System

Thanking You
Hope U Like it.....

Windows Server 2008

Notepad

Python 3.4.1

Nagios 4

Oracle Linux 7
How to Install Linux Mint 17

The Color Code of Both Straight and Crossover Cable

August 27, 2014
The Color Code of Both Straight and Crossover Cable
Colour Coding of CrossOver Cable

Colour Coding of Straight Cable

RJ 45 Plug 
STRAIGHT CABLE Color Code        

 One End                 Other End
Orange Light      -      Orange Light          
Orange              -       Orange
Green Light       -       Green Light
Blue                  -         Blue
Blue Light          -       Blue Light
Green                -        Green
Brown Light       -       Brown Light
Brown               -        Brown

CROSSOVER CABLE Color Code

One End             Other End
WhiteGreen     -      WhiteOrange
Green              -      Orange
WhiteOrange   -      WhiteGreen 
Blue                -       Blue
WhiteBlue       -       WhiteBlue
Orange            -       Green 
WhiteBrown    -       WhiteBrown
Brown            -         Brown


Thanking You
Hope u Like it....

Ubuntu 14.04

Lamp Installation in Ubuntu

Root Password Reset in Ubuntu

Linux Mint 17

Own Blogger Website
Install Free BSD

Basic Router Command and Its Protocol, WLAN

August 27, 2014
Basic Router Command and Its Protocol, WLAN

Basic Router Command
The following are some important commands that can be used to edit and review command history buffer. It will be useful to practice these commands.

<ctrl> A : Move to the beginning of the command line
<ctrl> E : Move to the end of the command line
<ctrl> F : Move forward one character, same as using "Right Arrow".
<ctrl> B : Move backward one character, same as using "Left Arrow".
<ctrl> P : Repeat Previous command, same as using "Up Arrow".
<ctrl> N : Repeat Next (more recent) command, same as using "Down Arrow".
<esc> B : Moves to beginning of previous word.
<esc> F : Moves to beginning of next word.
<ctrl> R : Creates new command prompt, followed by all the characters typed at the last one.
   

Keyboard Shortcut                          Action

Up Arrow     Displays your previous commands.  (command history)
TAB Key            Completes a partially typed CLI commands.
CTRL+Z             Takes you back to Privileged EXEC Mode.
CTRL+A             Places the cursor at the beginning of a line.
CTRL+E             Places the cursor at the end of a line.
CTRL+R             Redisplays the current command line.
CTRL+W            Erases a word (behind the cursor).
CTRL+U             Erases an entire line.


Here is a summary of Cisco IOS router command prompts:

Router> - User EXEC mode
Router# - Privileged EXEC mode
Router(config)# - Global configuration mode
Router(config-if)# - Interface level configuration mode
Router(config-router)#-Routing engine levelwithinconfigurationmode
Router(config-line)# - Line level (vty, tty, async) within configuration mode


Router#show cdp neighbors

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater



There are two types of configuration files on a router:

Running config - The configuration currently running on the router. Stored in RAM.
Startup config - Saved configuration stored in NVRAM.

To save the running configuration to the startup configuration use the following command.

Router# copy running-config startup-config

or

Router# copy run start


 The various states of an interface :-


Ethernet0 is up, line protocol is up - The interface is functioning correctly.

Ethernet0 is down, line protocol is down - This message usually represents a physical interface problem. The cable may be disconnected. This can also occur if this interface is connected to another router whose interface has been shutdown.

Ethernet0 is up, line protocol is down - The Physical layer connectivity is not the issue. The line protocol being down is either a clocking issue (keepalives) or a mismatch of the frame types being used on connected devices.

Ethernet0 is administratively down, line protocol is down - The interface has been manually shutdown using the shutdown command.

                 WLANs
802.11b           2.4GHz, 11Mbps
802.11n           2.4GHz or 5GHz, 300Mbps
802.11a           5GHz, 54Mbps
802.11g           2.4Ghz, 54Mbps

WEP   ---    Original IEEE wireless security standard.Easily hacked.
WPA   ---    Wireless security standard created by the Wi-Fi 
Alliance. Uses a dynamic key for greatly improved Security over WEP.
Interoperable with different vendors products.
CSMA/CA  ---  Network access method used in wireless networking & uses a proactive algorithm to avoid collisions.
WPA-2   ---   Ratified by the IEEE in 2005 who named it IEEE 802.11i & Uses AES encryption.


                       Protocols

What is the difference between TCP and IP?
IP is a connectionless protocol, it is used for network addressing and is a routed protocol.
TCP is a connection-oriented protocol used for reliable transmission by the Transport layer.

Finds a hardware address from a known IP address?
Address Resolution Protocol (ARP)

RIPv2
Distance vector, 120 admin distance, hop count metric, classless

OSPF
Link state, 110 admin distance, bandwidth metric, classless

IGRP
Distance vector, 100 admin distance, metric bandwidth and delay, classful, Cisco proprietary

Protocol responsible for network addressing and routing through an internetwork
Internet Protocol (IP)

Gather useful information about neighbour devices such as hardware and protocol information
Cisco Discovery Protocol (CDP)

Connectionless protocol at the Transport layer
User Datagram Protocol (UDP)

Layer 2 protocol used to prevent network loops
Spanning Tree Protocol (STP)

RIP
Distance vector, hop count metric, 120 admin distance, classful

Protocol used by a host computer to request its IP address
Reverse Address Resolution Protocol (RARP)

                  
                   Internal Router Components

What is NVRAM(Non-volatile random access memory)?
Stores config and config register

What is ROM ?
Holds POST, bootstrap and mini-IOS

What is Power on self test (POST) ?
Checks hardware and interfaces on start-up
Config register
Controls how router boots

What is Flash ?
 That's Stores in IOS

Mini-IOS
Small IOS used for maintenance

RAM(Random Access Memory)
Holds routing tables and running config

ROM(Read Only Memory) that Stored in ROM, brings up router on boot
Bootstrap

ROM monitor is Used for testing and troubleshooting



Thanks
Hope You Like :)
CloudNetwork: Basic Router Command.

Ubuntu 14.04

Linux Mint 17

Python

Nagios

Oracle Linux 7
Reset Root Password

How to Fix "The ADMIN Password Entered is Invalid" in Oracle DB 11g R2

August 27, 2014
How to Fix "The ADMIN Password Entered is Invalid" in Oracle DB 11g R2
Oracle Database 11g R2

The Criteria of Password Doesn't Meet Means.
You should not includ any Character in this box (!@$%&*) that means Oracle 
recommended to avoid that type of password. you can use only small character.

Thanking You
Hope U Like it.........

Fedora 20 in Virtual box

Roboform in linux

Ubuntu server 12.04

Nagios 4.0.7

Oracle Linux 7
Free BSD 10

Monday, August 25, 2014

How to Fix "no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory" in Ubuntu 14.04

August 25, 2014
How to Fix "no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory" in Ubuntu 14.04
Error :-   no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
This Message is Related to Samba Password Syncing. To Resolve it Follow Below Steps. 
Step1:- sudo su (logging as a Root)
Step2:- pam-auth-update (Press Enter)
PAM Configuration
Step3:- Deselect the Samba Password Synchronization

 Thanking You
Hope U Like it......

Ubuntu 14.04

Linux Mint 17

Ubuntu Root Password Reset

Lamp in Ubuntu 14.04

Redhat Linux 7 server
Gentoo Linux 12.1

Thursday, August 21, 2014

How to fix “System Program Problem Detected” Error on Ubuntu 14.04

August 21, 2014
How to fix “System Program Problem Detected” Error on Ubuntu 14.04

System Program Detected Error

Remove crash report files

The apport system creates crash report files in the /var/crash directory. These crash report files cause the error message to appear everytime Ubuntu boots

Step1 :- cd /var/crash 
Step2 :- ls (Just Remove all below crash)
_opt_google_chrome_chrome.1000.crash
_usr_lib_chromium-browser_chromium-browser.1000.crash
_usr_sbin_ulatencyd.0.crash
_usr_share_apport_apport-gtk.1000.crash 
Step3 :- sudo rm /var/crash/* 

Turn off apport. 

After removing the old crash reports, if you still get the same error message, then you can completely turn off apport to get rid. Edit the configuration file at /etc/default/apport.

Step4 :- gksudo gedit /etc/default/apport
# set this to 0 to disable apport, or to 1 to enable it
# you can temporarily override this with
# sudo service apport start force_start=1
enabled=1
Step5 :- enabled=0
Step6 :- sudo restart apport 
Thanking You
Hope U Like it........

 

 

Reset Root Password in linux

Linux Mint 17

pendrive bootable for ubuntu

Nagios 4.0.7

Oracle Linux 7
Fedora 20

How to Fix "Oracle is Not in the Sudoers File" in Ubuntu 14.04

August 21, 2014
How to Fix "Oracle is Not in the Sudoers File" in Ubuntu 14.04
ubuntu is not in the sudoers file
Error :- oracle is not in the sudoers file.  This incident will be reported.
 you can fix this error not only in ubuntu 14.04 but also in ubuntu 12.04 / 12.10.

Ans :- To give the sudo permission to a oracle we need to add the user to the file /etc/sudoers file.


Step1 :- sudo su (logging as a Root)
Step2 :- sudo nano /etc/sudoers or sudo vi /etc/sudoers
Step3 :- Add Line
Add Line            


 oracle ALL = (ALL)ALL (under the user privilege specification section)
Step4 :- Save and Exit
Note :- In place of Ubuntu you can right any name, just replace it

Thanking You
Hope U Like it............

Oracle Linux 7

Fedora 20 in Virtual box

Nagios 4.0.7

Roboform in linux

Ubuntu server 12.04
Zimbra Desktop 7