Wednesday, July 31, 2013

Linux basic commands for a beginner

To See System Information:

who -b -shows last rebooted time
cal – Show this month's calendar
uptime – Show current uptime
w – Display current logged in users
whoami – tells ur user id
uname -a – Show kernel information
less /proc/cpuinfo – CPU information
less /proc/meminfo – Memory information
df – Show local partitions 
du – Show directory space usage
date – Show the current date and time
free – Show memory and swap usage details
ls - to list the files in current directory
ls -a - to list the hedden files
less var/log/messages - to see system log messages
mail - to see mails

To get help for unkonuwn Commands

man -k keyword – Display man pages containing keyword
man command – Show the manual for command
man -t man | ps2pdf - > man.pdf  – Make a pdf of a manual page
which command – Show full path name of command
time command – See how long a command takes
which <commnad> – will gives the full path of command

To Find and search:

grep <word>  <filename>– Search for a word in the filename
command | grep <word> – Search for a particular word in the output of command

ex: who | grep <username>

find / -name filename – It will search for file called filename in / directory

find / -name ”*filename*” –  It will search for file containing the string filename in / directory.

File Permissions

chmod 777 <filename>– read, write, execute for all
chmod 755 <filename>– rwx for owner, rx for group and world



For more options, see man chmod.

commands related to directory levels:

cd dir – Change directory to dir
cd – Change to home
mkdir dir – Create a directory dir
pwd – Show current directory
rm name – Remove a file or directory called name
rm -r dir – Delete a directory dir
rm -f file – remove a file forcefully
rm -rf dir – Force remove an entire directory dir and all it’s included files and subdirectories 

cp file1 file2 – Copy file1 to file2
cp -r dir1 dir2 – Copy dir1 to dir2
cp file /home/dirname – Copy the file called filename to the /home/dirname directory

mv file /home/dirname – Move the file called filename to the /home/dirname directory
mv file1 file2 – Rename or move file1 to file2; 

ln -s file link – Create symbolic link link to file
touch file – Create a 0kb file or update file
cat > file – Places standard input into file
cat file – Display the file called file

more file – Display the file called file one page at a time, proceed to next page using the spacebar
head file – Display first 10 lines of file
head -20 file – Display the first 20 lines of the file called file
tail file – Output the last 10 lines of file
tail -20 file – Display the last 20 lines of the file called file
tail -f file – Output the contents of file as it grows, starting with the last 10 lines


ifconfig – List IP addresses for all devices on the local machine
ping host – Ping host and output results
dig domain – Get DNS information for domain
dig -x host – Reverse lookup host
nslookup <hostname>-to check IP address
netstat -ar - to see gate way and netmask

 Remote Login

ssh <hostname> – To logged into to another server.

User Administration

adduser accountname – Create a new user call accountname
passwd accountname – Give accountname a new password
su – Log in as superuser from current login
exit – Stop being superuser and revert to normal user

Process Management

ps – Display your currently active processes
top – Display all running processes
kill <pid> – Kill process id pid
killall proc – Kill all processes named proc (use with extreme caution)
bg – Lists stopped or background jobs; resume a stopped job in the background
fg – Brings the most recent job to foreground
fg n – Brings job n to the foreground

Shutdown and restart

shutdown -h now – Shutdown the system now and do not reboot
halt – Stop all processes - same as above
shutdown -r 5 – Shutdown the system in 5 minutes and reboot
shutdown -r now – Shutdown the system now and reboot
reboot – Stop all processes and then reboot - same as above
startx – Start the X system
init 1 - to switch to rum level 1

Apache Web server status codes and error codes

Successful Client Requests
200 OK
201 Created
202 Accepted
203 Non-Authorative Information
204 No Content
205 Reset Content
206 Partial Content

Client Request Redirected
300 Multiple Choices
301 Moved Permanently
302 Moved Temporarily
303 See Other
304 Not Modified
305 Use Proxy

Client Request Errors

400 Bad Request
401 Authorization Required
402 Payment Required (not used yet)
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable (encoding)
407 Proxy Authentication Required
408 Request Timed Out
409 Conflicting Request
410 Gone
411 Content Length Required
412 Precondition Failed
413 Request Entity Too Long
414 Request URI Too Long
415 Unsupported Media Type

Server Errors
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supporteda

Linux system administrator interview questions and answers for experienced

1. Ping  uses which protocol ?

ICMP, The Internet Control Message Protocol (ICMP) is one of the core protocols of the Internet Protocol Suite. It is used by the operating systems of networked computers to send error messages indicating, for example, that a requested service is not available or that a host or router could not be reached. ICMP can also be used to relay query messages.)

2. What is Syslogd?

Syslogd provides a kind of logging that many modern programs use. Every logged message contains at least a time and a hostname field, normally a program name field, too, but that depends on how trusty the logging program is.

main configuration file for syslogd is /etc/syslog.conf

3. What is Cname?

A CNAME(Canonical Name record) Record is a type of resource record in the Domain Name System (DNS) that specifies that the domain name is an alias of another, canonical domain name. Here "canonical" usually means: a more generally accepted or standard name.

4. Dns port number & protocol ?

DNS primarily uses User Datagram Protocol (UDP) on port number 53 to serve requests. DNS queries consist of a single UDP request from the client followed by a single UDP reply from the server.
The Transmission Control Protocol (TCP) is used when the response data size exceeds 512 bytes, or for tasks such as zone transfers. Some resolver implementations use TCP for all queries.

5. what is the Run levels configuration file & how to shift run levels?

A run level is a state of init and the whole system that defines what system services are operating. 

The following table defines how most Linux Distributions define the different run levels. However, run-levels 2 through 5 can be modified to suit your own tastes.

Run level numbers

0 Halt the system.
1 Single-user mode (for special administration).
2 Local Multiuser with Networking but without network service (like NFS)
3 Full Multiuser with Networking
4 Not Used
5 Full Multiuser with Networking and X Windows(GUI)
6 Reboot.

Configuration file: /etc/inittab 

to shift to different run levels use: init 1 (to shift to run level 1)

6. Dmesg command purpose?

dmesg obtains its data by reading the kernel ring buffer. A buffer is a portion of a computer's memory that is set aside as a temporary holding place for data that is being sent to or received from an external device, such as a hard disk drive (HDD). A ring buffer is a buffer of fixed size for which any new data added to it overwrites the oldest data in it.

dmesg can be very useful when troubleshooting or just trying to obtain information about the hardware on a system. Its basic syntax is

dmesg [options]

The output of dmesg is maintained in the log file /var/log/dmesg, and it can thus also be easily viewed by reading that file with a text editor, such as vi or gedit, or with a command such as cat, e.g.,

less /var/log/dmesg 

7. How to find our User login details ?

On a Linux (on Solaris/FreeBSD or any other UNIX) machine, many users will be sharing the same server.

Users will uses putty or ssh (secure and highly recommended) to login remotely.

use who comand . you can see loggedin users list.
command: who  or w

if u want to check for a particular user : who | grep <user id>

8. Purpose of nsswith.conf file ?

nsswitch.conf - System Databases and Name Service Switch configuration file


Various functions in the C Library need to be configured to work correctly in the local environment. Traditionally, this was done by using files (e.g., `/etc/passwd'), but other nameservices (like the Network Information Service (NIS) and the Domain Name Service (DNS)) became popular, and were hacked into the C library, usually with a fixed search order.

The Linux libc5 with NYS support and the GNU C Library 2.x ( contain a cleaner solution of this problem. It is designed after a method used by Sun Micro systems in the C library of Solaris 2. We follow their name and call this scheme "Name Service Switch" (NSS). The sources for the "databases" and their lookup order are specified in the /etc/nsswitch.conf file.

9. How to check errors in Ifconfig –a command and what information will you see in ifconfig –a ?

The following ifconfig command with -a argument will display information of all active or inactive network interfaces on server. It displays the results for eth0, lo, sit0 and tun0.

[root@testmachine ~]# ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:2A
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
          RX packets:2344927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2220777 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293839516 (280.2 MiB)  TX bytes:1043722206 (995.3 MiB)
          Interrupt:185 Memory:f7fe0000-f7ff0000

lo        Link encap:Local Loopback
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:5022927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5022927 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2175739488 (2.0 GiB)  TX bytes:2175739488 (2.0 GiB)

sit0      Link encap:IPv6-in-IPv4
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:  P-t-P:  Mask:
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

10. How To check the disk usage fot tmp directory?

du -sh /tmp

11. What is the diff b/w soft link and hard link? 

A hard link will creates another file with a link to the same underlying inode.

When you delete a file it removes one link to the underlying inode. The inode is only deleted (or deletable/over-writable) when all links to the inode have been deleted.

A symbolic link is a link to another name in the file system.

Once a hard link has been made the link is to the inode. deleting renaming or moving the original file will not affect the hard link as it links to the underlying inode. Any changes to the data on the inode is reflected in all files that refer to that inode.

Note: Hard links are only valid within the same File System. Symbolic links can span file systems as they are simply the name of another file.

12. How to change the Path in environmental variables  for /temp dir is make it temporary and permanent

Ans: will Post soon.

13. Diff b/w AD and LDAP

14. Diff b/w Terminal Service and VPN? 

15. Do you have knowledge on load balancer?

16. How you are fit in pxe and xen virtualisation?

17. How to resolve  grub reload issue to get data recovery?

18. Raid concepts what is raid 5, 1,0,1+0,0+1?

19. What is rds in vmware esxi?

20. How to monitoring running processes and how to kill particular heavy load process?

21. Diff b/w ssh and telnet? 

22. Similarity and Diff b/w AD and Ldap ?

23. What is scheduling service in windows like cron in linux?

24. What is Fault tolerance?

25. Kernal panic errors and resolving methods?

26. Type of Grub issues and fix methods ?

Monday, July 29, 2013

How to increase File size in Apache webserver

How to increase File size in Apache web server ??

Problem: User can not able to open the webpage. Getting the following error.

Fatal error: Allowed memory size of 134217728 bytes exhausted 


Go to the webserver and do edit the following files.

hostname# vi /etc/php5/apache2/php.ini

memory_limit = 128M    ; Maximum amount of memory a script may consume (128MB)

upload_max_filesize = 10M, Change it to 50M

increase these both columns.

hostname# /etc/init.d/apache2 status
Checking for httpd2:                                               running

hostname# /etc/init.d/apache2 restart

Syntax OK
Shutting down httpd2 (waiting for all children to terminate)  done
Starting httpd2 (prefork)                                                  done

hostname# /etc/init.d/apache2 status
Checking for httpd2:                                                        running

Then open the webpage, it will open.

Monday, July 1, 2013

How to create a bootable USB flash drive in windows


DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt 

  --------  -------------  -------  -------  ---  --- 
  Disk 0    Online          900 GB      0 B 
  Disk 1    Online         7836 MB      0 B   <- The 8 GB USB drive

DISKPART> select disk 1

Disk 1 is now the selected disk.

DiskPart succeeded in cleaning the disk.

DISKPART> create partition primary
DiskPart succeeded in creating the specified partition.

DISKPART> format fs=fat32 quick
100 percent completed
DiskPart successfully formatted the volume.

DISKPART> active
DiskPart marked the current partition as active.

Leaving DiskPart...


Loading kdump warning: elf Note name is not null terminated

Got a New error while Booting Linux Machine. Dont know the reason.. Need to find out root cause.

 Error Name and Details:

Loading kdump warning: elf Note name is not null terminated

Warning : ELF Note name is not null terminated
Warning : ELF Note name is not null terminated

Linux machine is taking almost 1 to 2 hrs time to boot. some times more. 


It is taking too much time for came up, so i rebooted server and enter into maintenance mode.From there i went to init 3 mode. then it works for me.

checking/updating cpu microcode

Error Name : checking/updating cpu microcode

when: While Loading Linux OS

Time to take update: 3 to 5 Min, depends on CPU.

It is due to The microcode in the CPU is not physically updated, the new code is just loaded into memory . And it will Take 5 min to update.

/etc/init.d/microcode.ctl, which will updates automatically the CPU microcode for both 32 and 64 bit operating systems. This one fixes the Bugs in older version.

Configuration file: /etc/init.d/microcode.ctl