Some interview topics

2 comments

If you are preparing for interviews for linux admin jobs you should be familiar with below concepts..

1) Port number of different servers {cat /etc/services}
2) Linux Installation(through FTP,HTTP,NFS)
3) Boot process
4) Diff b/w ext3 and ext2
5) RAID LEVELS and Selection of raid
6) backup methods
7) Package management such as Yum server
8) Kernel Tuning
9) IPTABLES
10) TCP WRAPPERS
11) DIFFERENT RUN LEVELS
12) USER AND GROUP MANAGEMENT
13) QUOTA SETTING(user and group)
14) DIFF B/W CRON AND AT
15) BASIC SHELL SCRIPTING
16) Troubleshooting different issues.
17) Tell me why we should hire you?
18) DAILY ACTIVITES IN YOUR CURRENT COMPANY
19) RECENTLY SOLVED CRITICAL ISSUE
20) LVM (Very Imp)
21) vertias Volume manager
22) cluster basic like HAD , GAB , LLT , HEARTBEAT , CONFIG FILES , RESOURSE , SERVICE GROUPS etc
23 ) kernel panic troubleshooting
24) Process management
25)Configuration part of NFS , NIS , Samba , DHCP , DNS,Apache, Sendmail etc.
26)Remote administration experience.

And many more depending on your job profile. You should know each topics what you mentioned in your resume . If you are not sure about anything , dont mention in your resume and your resume should reflect your skills.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • SAMBA Server Configuration

    0 comments

    SAMBA(SMB server) is a file sharing server. Which is used to share files between Windows, Linux and Unix Systems. SMB(Server Message Block) is a proprietary protocol which is developed by Microsoft

    Lets see how we can configure SAMBA in Linux.

    Step1 : Create a directory where you want to keep data and share with other remote systems(either windows/Solaris/in fact any unix flavor etc).
    #mkdir /share1

    Step2 : Installing Samba server
    #yum install samba

    Step3 : Once we install Samba server, configure it using its main configuration file(/etc/samba/smb.conf)

    Step3(a) : Open smb.conf file and specify the work group where this server belongs

    #vi /etc/samba/smb.conf
    search for workgroup word and specify your work group name
    workgroup = windows-group.

    Why we require this workgroup?
    Ans : When windows user try to access any network resource they first try to access my network places and then search for workgroup then to server. So definitly we have to specify this workgroup entry in smb.conf file.

    Step3(b) : So now we have to give a name to this samba server, search for "server string" with out quotes then provide the samba server name(here that name is linux-share)

    server string = linux-share

    Step3(c):Now specify the share details, which folder you want to share. To whom you want to share? Goto last line of the smb.conf file specify your shared folder details as follows.
    [myshare]

    comment = "This is my Linux data want to share with my windows users"
    path = /share1
    valid users = user1 user2
    writable = no
    privatable = no
    browsable =yes.

    After giving this seven entries just save and exit the file.

    Let me explain each and every thing what we used here.
    a.[myshare] --This is my share name, so when ever any user accessed my samba server through network this will be visible as folder shared.
    b.comment -- This is just a comment, which will help to know what is this share for.
    c.path -- This is used to specify which folder on my samba machine to share.
    d.valid users --This will specifies which user is having access on this folder.
    e.writable --This will specify whether users are able to write or not, In this example the can just read the folder and copy.
    f.Privatable --This will indicate whether this folder is private or not.
    g.browsable -- This is used to specify whether the folder content is browsable or not.

    Step4 : Now create passwords for the users who are going to access this samba share remotely.

    #smbpasswd -a user1
    #smbpasswd -a user2

    Please specify the passwords for this 2 users and this passwords will be stored in /etc/samba/smbpasswd

    Step5 : check for the syntax for your smb.conf file if in case you did any mistake

    #testparm

    Step6 : Restart the samba service

    #service smb restart

    Step7 : Permanently on the smb service, So that after rebooting the system too our server will start running.

    #chkconfig smb on

    Please check my other post how to mount or see the SAMBA shares
    here

    Please comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Find The RAM Utilization/Usage For A Service Or Server Or Process Or User?

    0 comments

    This is a long time question in my mind. I used to try all sorts of commands to find what is the RAM utilization by a service. The commands are as follows.
    1.#ps -ef
    2.#top
    3.#free
    4.#cat /proc/meminfo

    But none of these tools gives RAM utilization statistics for perticular user or service.

    To serve this purpose there is a built in command in linux called pmap(process map). Let us have a look in to pmap usage.

    Syntax:
    #pmap pid-value


    Example:
    # pmap 1015
    1015: cron
    00110000 100K r-x-- /lib/libselinux.so.1
    00129000 4K r---- /lib/libselinux.so.1
    0012a000 4K rw--- /lib/libselinux.so.1
    0012b000 36K r-x-- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
    00134000 4K r---- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
    00135000 4K rw--- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
    00148000 4K r-x-- [ anon ]
    00149000 1272K r-x-- /lib/tls/i686/cmov/libc-2.10.1.so
    00287000 8K r---- /lib/tls/i686/cmov/libc-2.10.1.so
    00289000 4K rw--- /lib/tls/i686/cmov/libc-2.10.1.so
    0028a000 12K rw--- [ anon ]
    002aa000 44K r-x-- /lib/libpam.so.0.82.1
    002b5000 4K r---- /lib/libpam.so.0.82.1
    002b6000 4K rw--- /lib/libpam.so.0.82.1
    004af000 76K r-x-- /lib/tls/i686/cmov/libnsl-2.10.1.so
    004c2000 4K r---- /lib/tls/i686/cmov/libnsl-2.10.1.so
    004c3000 4K rw--- /lib/tls/i686/cmov/libnsl-2.10.1.so
    004c4000 8K rw--- [ anon ]
    004cf000 108K r-x-- /lib/ld-2.10.1.so
    004ea000 4K r---- /lib/ld-2.10.1.so
    004eb000 4K rw--- /lib/ld-2.10.1.so
    00d0f000 8K r-x-- /lib/tls/i686/cmov/libdl-2.10.1.so
    00d11000 4K r---- /lib/tls/i686/cmov/libdl-2.10.1.so
    00d12000 4K rw--- /lib/tls/i686/cmov/libdl-2.10.1.so
    00db5000 40K r-x-- /lib/tls/i686/cmov/libnss_files-2.10.1.so
    00dbf000 4K r---- /lib/tls/i686/cmov/libnss_files-2.10.1.so
    00dc0000 4K rw--- /lib/tls/i686/cmov/libnss_files-2.10.1.so
    00e7e000 24K r-x-- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
    00e84000 4K r---- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
    00e85000 4K rw--- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
    08048000 32K r-x-- /usr/sbin/cron
    08050000 4K r---- /usr/sbin/cron
    08051000 4K rw--- /usr/sbin/cron
    082e4000 132K rw--- [ anon ]
    b784a000 8K rw--- [ anon ]
    b7859000 16K rw--- [ anon ]
    bfb47000 84K rw--- [ stack ]
    total 2088K

    When we see the output of this comand it will give details as follows
    1.
    First column will show memory location
    2.second column will show RAM utilization of each file opend by this process
    3.Third column will show rw permission.
    4.Last one will show what are the files opened by this process
    5.And last line of this output will show total size used, here it is 2088K

    Usage1 : To find how much RAM a process is taking
    #pmap pid

    Usage2 : To find how much RAM used by an application
    #pmap `pgrep firefox'
    Let me explain, `` quotes are used to submit a command which will allow to submit PID value for firefox.

    Usage3 : To find how much RAM utilized by Mysql server
    #pmap `pgrep mysqld` grep total

    Usage4 : To find how much RAM used by a particular user
    #pmap `ps -ef grep krishna awk '{print $2}'` grep total
    Where krishna is user name.

    Please comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Surendra's DIG Notes

    0 comments

    In this post i am going to teach How to use DIG and DIG by examples.

    DIG is one of the most important tool in debugging DNS server related issues.


    Some points to be noted about DIG.

    1. DIG full-form/abbreviation is Domain Information Groper

    2. DIG can work on command line or as well in batch mode

    3. DIG supports IDN convections too.

    4. DIG is more advanced than older tools such as nslookup and host commands.
    5. DIG output have so much information than any other tool, such as Question/Answer/Authority sections(which we are going to discuses in this post)


    Usage1 : Using DIG in basic form.
    #dig hostname


    Example :
    [root@ts6741 ~]# dig www.google.com
    ; <<>> DiG 9.3.3rc2 <<>> www.google.com
    ; (1 server found)
    ;; global options: printcmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52434
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
    ;; QUESTION SECTION:
    ;www.google.com. IN A
    ;; ANSWER SECTION:
    http://www.google.com/. 43200 IN A 200.99.187.2
    ;; AUTHORITY SECTION:
    http://www.google.com/. 43200 IN NS ns2.google.com.
    http://www.google.com/. 43200 IN NS ns3.google.com.
    http://www.google.com/. 43200 IN NS ns1.google.com.
    ;; ADDITIONAL SECTION:
    ns1.google.com. 43200 IN A 222.54.11.86
    ns2.google.com. 43200 IN A 220.225.37.222
    ns3.google.com. 43200 IN A 203.199.147.233
    ;; Query time: 1 msec
    ;; SERVER: 222.54.11.86#53(222.54.11.86)
    ;; WHEN: Wed Nov 18 18:31:12 2009
    ;; MSG SIZE rcvd: 152
    [root@ts6741 ~]#




    Here important points to know

    1. DIG version in Green (9.3).

    2. Question section in blue (Here it will show what you asked DIG to show up?).

    3. Answer secession in red (which will show you the answer for the query you asked).

    4. Authority section in brown (Which will show you who given the answer).

    5. Addition Section in light blue (It will show you if any additional info that DNS server provided).

    6. Total Query time in light green (Which will show how much time it takes to provide the answer).

    7. Server info in light brown (This will show what the port DNS server is working).

    8. Query execute date and time in dark red.




    Usage2 : Using DIG for reverse lookup entries
    #dig –x ipadd


    Example :
    #dig –x 192.56.78.1

    Usage3 : Digging with specified DNS server. Let me put it in this way. My dns server is not working properly and I want to test some server details, for this DIG will allow you to provide a DNS sever so that DIG will get information about the required system from that DNS server. We can provide DNS server by using @ symbol as shown below.
    #dig @ns-server hostname

    Example :

    #dig @223.125.43.67 http://www.google.com/

    Note : Here in this example my dig will not check /etc/resolve.conf file for default DNS server entry, it will just request details of http://www.google.com/ from a outside world DNS server ie 223.125.43.67





    Usage4 : To dig a DNS server on a perticular port,where DNS server is running .
    #dig @223.125.43.67 -p 2345 www.google.com


    Note:here 223.125.43.67 is the DNS server and port 2345 where that DNS service is running.



    Usage5 : To check the trace of the path.
    #dig http://www.google.com/ +trace

    Usage6 : To get mail server details
    #dig mx www.google.com

    Note : This will provied all the mail servers in google.com


    Usage7: To get Name server details
    #dig ns http://www.google.com/




    Note :
    This will provide all the Name Server records.

    Please comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • NMAP With Examples

    0 comments

    NMAP is one of the most important tool. Which checks which ports are open on a machine.

    Some important to note about NMAP
    1. NMAP abbreviation is network mapper
    2. NMAP is used to scan ports on a machine, either local or remote machine (just you require ip/hostname to scan).
    3. NMAP is can be installed on windows, Sun Solaris machines too.
    4. NMAP can be used to scan large networks, remember I am saying large networks.
    5. NMAP can be used to get operating system details, uptime, software used for a service and its version no, vender of network card and uptime of that system too(Don’t worry we will see all these things in this post.
    6. Please do not try to use NMAP on machines which you don’t have permission.
    7. Can be used by hackers to scan for systems for venerability.
    8. Just a funny note : You can see this NMAP used by trinity in Matrix-II, when she tries to hack in to electric grid super computer.

    Note : NMAP man pages one of the best man pages I have come across. It is explained in such a way that even new user can understand it easily and one more thing it is even having examples in to how to use NMAP in different situations, when you have time read it. You will get lots of information.

    Example1 : Using NMAP in normal way, i.e. to scan a particular system for open ports
    #nmap hostname


    Example2 : Scanning for a single port on a machine
    #nmap –p 22 hostname
    This will scan for 22 port is open on a host or not. And here –p indicates port.

    Example3 : For scanning only ports
    #nmap –F hostname
    -F is for fast scan and this will not do any other scanning like IP address, hostname, operating system, and uptime etc. It’s very much fast as it said in man pages.

    Example4 : For scanning only TCP ports
    #nmap –sT hostname
    Here s is for scanning and T is for only scanning of TCP ports

    Example5 : For scanning only UDP ports
    #nmap –sU hostname
    Here U indicates UDP port scanning

    Exmaple6 : Scanning for ports and to get what is the version of different services running on that machine
    #nmap –sV hostname
    V indicates version of each network service running on that host

    Example7 : To check which protocol is supported by the remote machine
    #nmap –sO hostname

    Example8 : To scan a system for operating system and uptime details
    # nmap -O hostname
    -O
    is for operating system scan along with default port scan

    Example9 : Scanning a network
    #nmap networkID/subnetmask
    For the above command you can try in this way
    #nmap 192.168.0.0/24

    Some sites to refer (not for practical examples, but for to get good concept):
    nmap.org : official site for our NMAP
    en.wikipedia.org/wiki/Nmap
    Please Comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Use IPtables to Block ICMP (Internet Control Message Protocol) Requests?

    0 comments

    How to use IPtables to block ICMP (Internet Control Message Protocol) requests?
    Ans : To do this we have understand why we require this thing should be done.
    When Hackers try to hack in to any machine first thing they will do is a basic ping test.

    Code :
    #ping target-machine

    If this is succeed they will come to a conclusion that system is up and they can go forward and they can do DDOS attacks or try to find some other open ports using NMAP command.

    Code :
    #nmap target-machine
    So if you are exposing a machine to outer world from your network, first disable incoming ping requests to your machine as follows.

    So this can be done by two ways through IPtables
    1. Reject the ICMP packets.
    2. Drop the ICMP packets.

    In the above mentioned methods best thing is to drop the ICMP packets, by doing this we are not giving any clue to hacker whether the system is alive or not. Where as if we do reject definitely hacker will come to know that ICMP packets are blocked and the system is live.

    Step1 : Executing following command to drop all the incoming ICMP packets
    #iptables –A INPUT –p icmp --icmp-type echo-request –j DROP
    Let me explain this command
    -A is to append this rule to already existing one.
    INPUT specifies that it’s a

    Step2 : Save this changes to IPtables file (/etc/sysconfig/iptables), restart the IPtables service and check your IPtables status whether your IPtables chain is updated or not.
    #service iptables save
    #service iptables restart
    #iptables –L

    How to allow icmp ping request in case you want them,First we have to remove the rule which we created for blocking the icmp ping.
    #iptables –D INPUT –p icmp --icmp-type echo-request –j DROP

    Then execute the following commands
    #iptables –A INPUT –p icmp --icmp-type echo-request –j ACCEPT
    #service iptables save
    #service iptables restart

    Some points to be noted
    What are the methods used by hackers using this ICMP ping?
    Though these are old denial-of-service attack (DoS attack), worth to learn them
    Ping flood
    Smurf attack
    Ping to death

    Please comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • SNORT(IDS/IPS) Configuration and Implemenation

    0 comments

    Lets start how to install SNORT which is An Intrusion detection system (IDS) and an Intrusion Prevention System (IPS). We tested installation of SNORT on RHEL5.
    Step1 : Download following packages
    libpcap-1.0.0.tar.gz
    pcre-8.00.tar.gz
    libnet-1.0.2a.tar.gz (This is optional package if you want SMB popup alerts on window’s machines.)
    snort-2.8.5.1.tar.gz
    acid-0.9.6b23.tar.gz
    Note : Don’t try to install SNORT through rpm packages, try to install them from source packages because there will be so many dependencies. And install the above packages in the same order to resolve dependencies.
    Step2 : Untar packages one by one.
    #tar xvfz packagename.tar.gz
    Step3 : Change the directory to libpcap-1.0.0 and Just run ./configure shell script, this will check system attributes and generate make file, which is used to install libpcap package as following.
    #cd libpcap-1.0.0
    #./configuration
    #make
    #make install
    Note : If anything goes wrong please search that error message in google..
    Step4 : After installing libpcap install pcre package for doing regular expression query in checking the packet capture to match multiple entries. First change the directory to pcre-8.00 then start executing following commands
    #cd ../pcre-8.00
    #./configure
    #make
    #make check
    #make install
    Step5 : Now install libnet package..
    #cd ../libnet-1.0.2a
    #./configure
    #make
    #make check
    #make install
    Step6 : Now install the important package in our game of implementing IDS/IDP ie our SNORT package. Just follow below commands to install SNORT. You have to be careful in this step because we can install SNORT in standalone system or a complete system with DB/web server/acid support. If you are planning to install SNORT in standalone just execute ./configure after changing to snort-2.8.5.1 directory. But here I am going to build a complete SNORT system will all the capabilities. Before that we should know what are the content of snort source directory. Please get some knowledge on it and read the required readme files in doc/ folder.
    Note : Before installing SNORT do the following things (Before installation you can do this).
    1. Make sure that you copy etc/ content in source directory to /etc directory
    2. Create /var/log/ snort directory for snort logging activity (remember we have to mention this path in main configuration file, in our case it will be /etc/snort/etc/snort.conf.
    3. Create /etc/snort/rules directory for creating rules files for snort.
    #mkdir /etc/snort
    # cp -ar ./etc /etc/snort/
    #mkdir /var/log/snort
    # mkdir /etc/snort/rules
    Now start installing SNORT
    # ./configure --with-mysql --with-snmp --enable-smbalerts --enable-flexresp
    #make
    #make check
    #make install
    Hmm..! good we are done with the installation of SNORT
    So in the next post I will show you how to configure, integrate SNORT with Mysql and ACID.
    Please Comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Uninstall A Source Package?

    0 comments

    In Linux we can install packages in so many ways such as:
    #rpm –ivh packagename.ver.arch.rpm
    This is to install from rpm package manager

    #yum install packagename
    This is installing through yum which will use rpm package manager internally
    #apt-get install packagename
    This is for installing .deb packages

    #sh file.sh
    This is from a shell script.
    #./configure;make;make check;make install
    This is to install from source package.
    Etc. but when we want to uninstall above packages we will use package removing commands as below
    #rpm –e packagename
    For uninstalling an rpm package, which are installed through rpm/yum

    #yum remove packagename
    Uninstalling through yum... Etc...
    But what about uninstalling source package? How to uninstall a source package?
    This can be done in two ways
    Way1 : If we have still the source code with us in our system, then it’s very much easy to uninstall as shown below
    #cd sourcefolderpath
    #make uninstall
    This will completely install the package/software

    Way2 : If you don’t have source code with you. This is really hard way to do it, we have to go to so many locations/folders where that package created supported files. Some common locations for a package files is as follows
    /etc/packagename
    /var/log/packagename
    /usr/local/packagename
    /bin/
    /sbin/
    /usr/bin/
    /usr/sbin/
    /usr/share/doc/packagename

    Etc.. so we have to go to each folder and have to remove all the files whose name contains packagename.
    Note : If you install any package through source package, rpm –e or yum remove commands will not help us in removing the package installed through source package.
    Please comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Log DNS Server Activity?

    0 comments

    How to log DNS server activity?
    Ans : Sometimes you require DNS server activity to be logged to a file for future reference to analyze the activity on DNS server and whether DNS server is properly resolving accurately or not. rndc is the command to use for DNS server activity logging. Let’s have a look how to log DNS server activity. In order to log DNS server entries just execute below command (you have to do this one as root user)
    #rndc querylog
    Note : When you execute the above command DNS server activity is logged on to server /var/log/messages file.

    Example output of the clipped log file
    bash-2.05b# /usr/sbin/rndc querylog
    bash-2.05b# tail -f /var/log/messages
    Nov 18 18:00:16 ns1.abc.in named[29413]: query logging is now on
    Nov 18 18:00:18 ns1.abc.in named[29413]: client 194.158.122.34#43071: query: abc.co.in IN MX
    Nov 18 18:00:18 ns1.abc.in named[29413]: client 194.158.122.6#43587: query: smtp.abc.co.in IN A
    Nov 18 18:00:19 ns1.abc.in named[29413]: client 82.8.211.193#19305: query: MX2.abc.co.in IN A
    Nov 18 18:00:20 ns1.abc.in named[29413]: client 200.49.130.26#4111: query: abc.co.in IN MX
    Nov 18 18:00:21 ns1.abc.in named[29413]: client 212.24.128.8#46547: query: abc.co.in IN MX
    Nov 18 18:00:22 ns1.abc.in named[29413]: client 200.75.51.132#26540: query: MX2.abc.co.in IN A
    In order to stop DNS logging activity please execute below command
    #rndc querylog
    Note : If you observe this command it is same as for starting the log activity, it is similar way how walky-talky works.. You have to press same button for both on/off operations.
    Example output of how it is stopped
    bash-2.05b# /usr/sbin/rndc querylog
    bash-2.05b# tail -f messages
    Nov 18 18:08:53 ns1.abc.com named[29413]: client 200.12.232.4#60450: query: abc.co.in IN MX
    Nov 18 18:08:59 ns1.abc.com named[29413]: client 212.54.35.233#39027: query: ns1.abc.co.in IN A
    Nov 18 18:08:59 ns1.abc.com named[29413]: client 212.54.35.233#10163: query: ns1.abc.co.in IN A
    Nov 18 18:09:00 ns1.abc.com named[29413]: client 88.156.63.9#3661: query: abc.co.in IN MX
    Nov 18 18:09:00 ns1.abc.com named[29413]: client 89.2.2.146#44622: query: abc.co.in IN MX
    Nov 18 18:09:05 ns1.abc.com named[29413]: client 203.199.147.5#14678: query: cmex01.clairmail.local.intranet.abc.co.in IN A
    Nov 18 18:09:06 ns1.abc.com named[29413]: client 117.98.17.34#1766: query: abc.co.in IN MX
    Nov 18 18:09:06 ns1.abc.com named[29413]: client 203.119.8.106#28142: query: abc.co.in IN MX
    Nov 18 18:09:11 ns1.abc.com named[29413]: client 217.171.113.9#4861: query: MX2.abc.co.in IN A
    Nov 18 18:09:11 ns1.abc.com named[29413]: query logging is now off
    Some FAQ’s:
    1.Is it advaisable to restart a production DNS server?
    Ans : No, Never try to restart a production DNS server with out prior notice from your higher officials.
    2.Then how can I update any changes I made to DNS server?
    Ans :
    You can use rndc command to update the changes to dns server.
    3.I want to update DNS server zone file entries to DNS server without restarting the named/bind server?
    Ans :
    We can do it by using rndc command
    #rndc reload
    4.I want to reload named.conf file with out restarting DNS server?
    #rndc refresh.
    Please Comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Take The Backup Of MBR(Master Boot Recorder)

    2 comments

    1.How to take the backup and restore MBR? Why do you require to take the backup of your MBR?
    Ans :
    MBR (Master Boot Recorder) is a vital part of your hard disk which contains booting information, without it its difficult to boot the system. Suppose you have windows and Linux duel boot on your machine and as you know windows is more prone to virus attacks. So it’s always better to backup your MBR to be in safe place.


    2. How to take backup of your MBR?
    Ans :
    Using dd command (dataset definition). Here are the steps to take backup of you MBR and keep it in safe place to restore your system if it get corrupted.
    #dd if=/dev/hdx of=/safe/location bs=512 count=1


    Let me explain the above command how it will work.
    “If”
    in the command is nothing but to specify Input File, here we are specifying our input file as hard disk(if the hard disk is /dev/hda it is primary master, so for general purpose I given 'x'). “of” in the command is nothing but to specify Output File, here we are specifying our output file as /safe/location. Then “bs” this is nothing but block size to write in to hard disk. And then “count” nothing but how many times you want to write date this many block sizes. Here in this example count=1 that means first 512 bytes of the hard disk is copied to the specified location.


    3.How to restore the MBR?
    #dd if=/safe/location of=/dev/hdx bs=512 count=1


    Note : Please replace “hdx” with your hard disk name.
    This is bit complex,
    Is there any other way to restore MBR?
    Yes, if you have Linux or Windows bootable CD, we can easily restore your MBR if you forgot to take backup(And this method is very much easy to do restoration of MBR when compared to previous method).


    Method1 : With Redhat Linux bootable CD.
    For this you have to boot your system to rescue mode, then mount your file system to rescue mode and execute below command to restore your MBR
    #grub-install /dev/hdx


    Note : Please replace hdx with your hard disk name. After that you just reboot your system. Your system will be live and working.

    Method2 : With Windows XP bootable CD.
    Step1 : Boot the system with XP bootable cd
    Step2 : Press f8 to go to repair mode in Windows
    Step3 : Once you got the c drive prompt just type below command
    Fixmbr
    This command will fix the MBR record.


    Some FAQ’s
    1. What is the MBR size?
    Ans :
    MBR size is just 512 bytes.


    2.What MBR conations?
    Ans :
    Mainly MBR can be divided in two parts
    a.Boot loader information block(which is of 448 bytes)
    b. Partition table information(which is of just 64 bytes)


    3.How many partition we can create on a hard disk?
    Ans :
    Totally we can create four partitions as below
    a.Four primary parathions.
    b.Three primary and one extended partition.
    c.Two primary and one extended parathion.
    d.One primary and one extended parathion.


    Note : In extended parathion we can create logical partitions up to 24 in number.

    4.Why we cannot create more then 4 partition as mention above?
    Ans :
    In MBR, the partition table info is just stored in 64 bytes, and one parathion information to store in MBR requires 16 bytes of space. So at most you can create only 4 partitions as mention above.


    Please Comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • EXT2 VS EXT3 File Systems

    3 comments

    The differences between Ext2 and Ext3 file systems are as follows.











    Sl.No

    EXT2

    EXT3

    Journling

    No journling

    Has journling

    Speed of file system(read-write)

    Bit faster

    Bit slower then ext2 file-system

    Data corruption

    File system may be corrupted due to unplanned reboots

    Prevents file-system corruption

    Way to recover data

    Require fsck to recover data after unplanned reboot

    Does not require(automatic file recovery is done at booting time)

    Online file system growth.

    By default there is no Online file system growth.

    Online file system growth

    Commands to format

    mkfs.ext2 or mke2fs

    mkfs.ext3 or mke2fs -j

    Max file size(if block size is 1kB)

    2GB

    16GB

    De-fragmentation

    Easy and done with e2defrag

    There is no data security when doing de-fragmentation.

    Data accommodation

    More data can be accommodated in a give space

    Less date is written when compare to ext2 in a give space due to journling.


    Some FAQ's:

    1. What is Journaling?
    Ans : In general, Journaling file systems avoid file system corruption by maintaining a journal. The journal is a special file that logs the changes destined for the file system in a circular buffer. At periodic intervals, the journal is comitted to the file system. If a crash occurs, the journal can be used as a checkpoint to recover unsaved information and avoid corrupting of file system metadata.

    2.How many file systems supported by linux? and what are they?
    Ans : As of now(09-Nov-2009)
    Linux will supports : Btrfs, cifs, davfs, ext, ext2, ext3, ext4, exofs, hpfs, JFS minix, msdos, ncpfs, NiLFS(2), ntfs, nfs, proc, smbfs, iso9660, sysv, hpfs, affs, ufs, umsdos, vfat, xia, xfs, ZFS.
    Note : Please add some more file systems which you people know in the comment section. So that i will update the post with new file systems.

    3.What is the maxium size of a paration we can create using ext2 and ext3?
    Ans : 4TB paratation
    can be created in each ext2 and ext3 file system respectively.

    4.What is the maxium size of a file we can create in ext2?
    Ans :
    The maximum size what we can create is 2GB to 2TB. It depends on the block size we taken when we are formating. If the block size is 1KB we can not create a file more than 2GB in ext2 file system.

    5.What is "ext" in ext2 and ext3?
    Ans :
    When linux first implemented the default file system is minixfs, in subsequent years it was replaced its sucesser file system called extended filesystem. So the naming convention. So ext2 is second version of extended file system. Same explanation is given to ext3 and ext4.

    6. Some points about ext4
    a.
    It supports 64 bit storage limits, where as ext, ext2, ext3 are 32Bit storage limits and minix is 16Bit storage limit.
    b.Have backward compatibility and performance is improved from lower version.
    c.Extents are introduced (An extent is a range of contiguous physical blocks, improving large file performance and reducing fragmentation. A single extent in ext4 can map up to 128MB of contiguous space with a 4KB block size).

    And there are many more advantages please see the below links for more info about all the file systems..
    http://en.wikipedia.org/wiki/Ext4
    http://en.wikipedia.org/wiki/Ext3
    http://en.wikipedia.org/wiki/Ext2
    http://en.wikipedia.org/wiki/Extended_file_system
    http://www.ibm.com/developerworks/library/l-journaling-filesystems/index.html
    http://www.oracle.com/technology/pub/articles/calish_filesys.html
    http://www.cyberciti.biz/tips/understanding-unixlinux-file-system-part-i.html Please comment your thoughts regarding this post. To give feed back click here.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Linux Virtual File System

    0 comments

    Can we create a file system (i.e. formatting a drive/partition) with in a file system?
    Looks little bit strange is int it? So follow me I will show you how to create a virtual partition and file system within a partition.

    Step1 : Create a empty file with /dev/zero with size equal to 50Mb.
    #dd if=/dev/zero of=/temp/vf0 count=102400

    Note :

    1. By default "dd" command(dataset definition) uses block of 512bytes so the size will be 102400*512=52 428 800=~50MB
    2. /dev/zero is a device files which will be used create a file which conations "0" i.e. an empty
    file.

    Clipped output:
    [root@test6 ~]# dd if=/dev/zero of=/temp/vf0 count=102400
    102400+0 records in
    102400+0 records out
    [root@test ~]# ls -lh /temp/vf0
    -rw-r--r-- 1 root root 50M Nov 7 12:08 /temp/vf0

    Step2 : Create ext3 file system for this virtual partition.
    #mkfs -t ext3 /temp/vf0

    Here it will ask "do you want to format the file or not"?, just say yes.

    Step3 : Now we have to create a mount point (nothing but a directory) and mount the created partition.
    # mkdir /virtdrive
    # mount -o loop=/dev/loop0 /temp/vf0 /virtdrive

    Note:

    /dev/loop is special hardware device used to mount ISO files and virtual file systems. In Linux there are total 8 loop devices numbering from 0 to 7. So you can mount only 8 ISO files/virtual file systems by default.

    Step4 : Edit /etc/fstab file to mount permanently, so that it be auto mounted at boot time too. Specify following entry in fstab file.
    /temp/vf0 /virtdrive ext3 rw,loop=/dev/loop0 0 0

    Step5 : Specify the fstab changes to kernel.
    #mount -a

    Step6 : Conform Weather mounting happen perfectly or not.

    Way1 :
    #cat /etc/mtab

    Way2 : Change the directory to mount point you have to see lost+found folder
    [root@test ~]# cd /virtdrive/
    [root@test virtdrive]# ls
    lost+found
    [root@test virtdrive]#


    Please comment your thoughts regarding this post:-)

    Reblog this post [with Zemanta]

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page

     

    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here