Some interview topics
2 comments 11/29/2009 09:53:00 AM Posted by Surendra Kumar AnneLabels: INTERVIEWS
If you are preparing for interviews for linux admin jobs you should be familiar with below concepts..
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.
SAMBA Server Configuration
0 comments 11/29/2009 02:21:00 AM Posted by Meghana M BhombhoreLabels: File Share Servers
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:-)
How To Find The RAM Utilization/Usage For A Service Or Server Or Process Or User?
0 comments 11/25/2009 10:30:00 AM Posted by Surendra Kumar AnneLabels: Administration, Process-Mgmt
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:-)
Surendra's DIG Notes
0 comments 11/24/2009 09:39:00 AM Posted by Surendra Kumar AnneLabels: DNS Servers, How-To's, Server Troubleshooting, Tutorials
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)
#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 ~]#
#dig –x ipadd
#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
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
#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.
Usage6 : To get mail server details
#dig mx www.google.com
Note : This will provied all the mail servers in google.com
Note : This will provide all the Name Server records.
Please comment your thoughts regarding this post:-)
NMAP With Examples
0 comments 11/23/2009 05:37:00 AM Posted by Surendra Kumar AnneLabels: How-To's, Network Monitoring, Tutorials
- NMAP abbreviation is network mapper
- NMAPis used to scan ports on a machine, either local or remote machine (just you require ip/hostname to scan).
- NMAPis can be installed on windows, Sun Solaris machines too.
- NMAPcan be used to scan large networks, remember I am saying large networks.
- NMAPcan 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.
- Please do not try to use NMAP on machines which you don’t have permission.
- Can be used by hackers to scan for systems for venerability.
- 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.
Example1 : Using NMAP in normal way, i.e. to scan a particular system for open ports
#nmap –p 22 hostname
This will scan for 22 port is open on a host or not. And here –p indicates port.
#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
How To Use IPtables to Block ICMP (Internet Control Message Protocol) Requests?
0 comments 11/23/2009 05:30:00 AM Posted by Surendra Kumar AnneLabels: Basic-Security, Network Monitoring, Security
#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
#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
SNORT(IDS/IPS) Configuration and Implemenation
0 comments 11/19/2009 10:48:00 PM Posted by Surendra Kumar AnneLabels: Advanced Servers, Basic-Security, Network Monitoring, Security
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
#tar xvfz packagename.tar.gz
#cd ../libnet-1.0.2a
#./configure
#make
#make check
#make install
How To Uninstall A Source Package?
0 comments 11/19/2009 07:28:00 AM Posted by Surendra Kumar AnneLabels: Administration, Package-Mgmt
#yum install packagename
This is installing through yum which will use rpm package manager internally
This is for installing .deb packages
#sh file.sh
This is from a shell script.
This is to install from source package.
#yum remove packagename
Uninstalling through yum... Etc...
This can be done in two ways
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.. so we have to go to each folder and have to remove all the files whose name contains packagename.
How To Log DNS Server Activity?
0 comments 11/18/2009 05:16:00 AM Posted by Surendra Kumar AnneLabels: DNS Servers, Network Monitoring, Server Troubleshooting
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
Example output of the clipped log file
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
Ans : No, Never try to restart a production DNS server with out prior notice from your higher officials.
Ans : You can use rndc command to update the changes to dns server.
Ans : We can do it by using rndc command
#rndc reload
#rndc refresh.
How To Take The Backup Of MBR(Master Boot Recorder)
2 comments 11/13/2009 07:53:00 AM Posted by Meghana M BhombhoreLabels: Administration, Basic-Security, Basics, Boot Troubleshooting, How-To's
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:-)
EXT2 VS EXT3 File Systems
3 comments 11/10/2009 05:25:00 AM Posted by Meghana M BhombhoreLabels: Disk-Mgmt
The differences between Ext2 and Ext3 file systems are as follows.
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.
Linux Virtual File System
0 comments 11/07/2009 06:20:00 AM Posted by Meghana M BhombhoreLabels: Administration, Disk-Mgmt, How-To's, Tutorials
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:-)