amazon

Tuesday, April 26, 2011

Interview Preparation - 13


188. How you will schedule jobs using cron jobs how you will set?
Ans ) Crontab -l======> list the crons
crontab -e =====> edit and modify
The crontab File Entry Format

       A crontab file contains entries for each cron job. Entries are separated by newline characters. Each crontab file entry contains six fields separated by spaces or tabs
       in the following form:

       minute  hour  day_of_month  month  weekday  command_with_complete_path

ex : To run the calendar command at 6:30 a.m. every Monday, Wednesday, and Friday, enter:

            30 6 * * 1,3,5 /usr/bin/calendar
189. What are the regular commands is UNIX in use?
Ans)  in our day to day activity we use the following commands in UNIX:
To find out the running processes the command is                    : Ps – ef| grep java
To find out the disk space the command is                              : du
To find out the file system the command is                             :df
To find out the network performance/port info command is       :net stat
To find out the CPU utilisation the command is                         : topas/osstat
To kill the running process the command is                             : kill -9 <PID>
To generate heap/thresd dump the command is                       :kill -3 <PID>
To  change the privileges of the file/folder the command is        : chmod
To  change the owner of the file/folder the command is             :chown
To  list the file the command is                                             : ls
To create DIR(folder) the command is                                    :mkdir                                        Start the server                                                   : startserver.sh server1
how to see dynamic l ogs                                   : trail –f  log file name

To TAR the files ,folders we use the following command
Tar –xvf  <file name with path>     --
Tar – uvf                                    --adding one or two files two folder
Tar – cvf                                    -- total folder
To schedule the job in cron command is as follwos
Crontab –l ( to list all the scheduled jobs)
Crontab –e ( to edit the  scheduled job)

190. What information you get with the command “ps–ef|grep httpd” ?
Ans) we get the all webserver instance information’s with process id.

191. How you will check the web server status
 Ans)  by using the following command we can check the all instances of the webserver
                   $ ps – ef| grep httpd
                  

192. If you want to know detailed information for a particular port when you know only port number then how you will check?
Ans) we need to follow the steps mentioned below to know the detailed information about the process running on the particular port
          $ netstat –Aan|grep <Port_no>
          Socket will be listed, using that socket we can get SID
          $rmsock  <socket_no>  <protocol>
Ex:     $netstat –Aan|grep 944
f10002000fc4398
 $rmsock  f10020000fc4398  tcpcb
          the socket oxfc4008 is being by process 626888(java)
$ps –ef| grep 626888

193. What is the command to find the process in the sun Solaris environment?
Ans)   psrinfo –v (need to cross verify)

194. How you will check the application status?
Ans) ps –ef |grep appservername( from admin console à enterprise applications)
chmod.............. changes permissions on a file
passwd ............. change your password
telnet(host)...... connect to another Internet site
ftp (host) ......... connects to a FTP site
ls –a....hidden files
ps...process status
pid………… process ID
Cron….To schedule job
uname -a…………..verified the version
symlink………………make a new name for a file
useradd……………….. Create new user accounts or update default account
usermod……………Modify user account information
users………Print login names of users currently logged in, print on a single line a blank-separated list of user names of users currently logged in to the current host.
alias……….Create an alias, aliases allow a string to be substituted for a word when it is used as the first word of a simple command. 
ifconfig –a------NIC Card
if config…………. ip address
vi------------file editor
apachect1 start-----------start command in IHS server
install.exe---------how to install web sphere application server
pctlinux.bin-----------how to create the profile in Linux
pwd----------current working directory.
Genplugincfg.sh--------------------regenerating the plug-in configuration file
ln –s source_file myfile ---------------symbolink
tail –n 25 filename-------------display the last no of files
head –n 5 filename-------------file first 5 lines
ps –aux------ How to trace any process background processing
Vmstat (Or) top-------------process utilization, CPU utilization, ram utilization
free, free -m or top doesn't seem to give you total physical RAM, the value is minus kernel size and some other stuff. The only way I've found to get total physical RAM so far is with this:

dmesg | grep ^Memory:


The second value is the physical RAM size. It'll also tell you what other junk is subtracted from that to give you what you get with "free”
grep-----------search for information in a file or files
How to check all open ports on linux machine and block unsed ports????????
netstat -t
#nmap -v localhost for tcp
#nmap -sU localhost for udp]
netstat---------Displays generic net statistics of the host you are currently connected to
netstat –i --------------Show the state of the interfaces that are used for TCP/IP traffic.
netstat –an--------Shows all connections to the server including the source and destination ips and ports if you have proper permissions.
netstat -an |grep :80 |wc –l---------- Display the amount of active connections on port 80. Removing the pipe and wc command would display each connection.
netstat –natp----------Display active Internet connections
To Get Statistics of Protocols:
netstat –s----The Sample output of above command:
IP:5193 incoming packets delivered  4813 requests sent out
Tcp:4033 segments received  4813 segments send out
               Icmp:41 ICMP messages received 178 ICMP messages sent

netstat -anp | grep 834----------To check for port 834 using netstat, use the following command.
nmap -sT -O localhost -----------The following command issued from the console determines which ports are listening for TCP connections from the network:
netstat –nr-------- When you invoke netstat with the –r flag, it displays the kernel routing table in the way we've been doing with route. On vstout, it produces:

netstat –rn---------Displays routing table for all ips bound to the server.
chgrp - -----change a file's group ownership
su ---------temporarily become the super user
du | sort –nr-------Displays a list of directories and how much space they consume, sorted from the largest to the smallest.
find . -type f -print | wc –l ---------------- Displays the total number of files in the current working directory and all of its subdirectories.
ls -lt | head--------------Displays the 10 newest files in the current directory.
sort----------Sorts standard input then outputs the sorted result on standard output.
Write a command to find all of the files which have been accessed within the last 30 days.
find / -type f -atime -30 > December. files
This command will find all the files under root, which is ‘/’, with file type is file. ‘-atime -30′ will give all the files accessed less than 30 days ago. And the output will put into a file call December.files
What command is used to remove the password assigned to a group?
gpasswd -r

The gpasswd command is used to change the password assigned to a group. Use the -r option to remove the password from the group.

195. What command can you use to review boot messages?
"dmesg"


196. Which command to?
grep
Web Sphere Application Server products require that you log on as root on a Linux or UNIX operating system to install. Set the umask to 022 for security purposes after logging on as root before you install:
umask 022
Set file permissions to 755 after installation, as in the following example for one file:
chmod 755 setupCmdLine.sh

197. How to Hide the FTP Version?
Stop httpd service. (OR)
can stop vsftpd service.

198. What does nslookup do? Explain its two modes.
    Nslookup is used to find details related to a Domain name server. Details like IP addresses of a machine, MX records, servers etc. It sends a domain name query packet to the corresponding DNS.
Nslookup has two modes. Interactive and non interactive. Interactive mode allows the user to interact by querying information about different hosts and domains.
Non interactive mode is used to fetch information about the specified host or domain. 
Interactive mode:
Nslookup [options] [server] 

199. How do find all failed login attempts via ssh?
Check network connectivity
Check correct ipaddress
Ping ipaddress
(OR) who' or ‘w’ is the command used to find the users who logged in the system and their attempts, with the help of some options
(OR) The correct way to find out fail ssh login attempts are

tail -f /var/log/secure | grep Failed
(OR)
"lastb" is the command to find all failed login attempts

200. What is the difference between Telnet and SSH?
Telnet ->
Its just getting (Telenet) a connection to the server.
Its not more secure. Anybody can use it.
It can be easly hacked.It can be easily read by anybody in
that network

SSH -> secured shocket shell
Its more secure than Telnet .
This has an encrption and decrption of the data /usr/pwd
None can hack this. It is the good way to transfer the data

201. What is the difference between fork and thread? And parent and child process in fork system call?
for () creates a new process which copy of parent only PID is different. Thread create within process except stack it shares memory

Example: global variable seterrno is shared by multiple threads

202. What file defines the levels of messages written to system log files?
kernel.h

To determine the various levels of messages that are defined on your system, examine the kernel.h file.

203. What is LILO?
LILO stands for Linux boot loader. It will load the MBR, master boot record, into the memory, and tell the system which partition and hard drive to boot from.
hat are Pipes? Explain use of pipes.
A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin) to another. UNIX shell has a special syntax for creation of pipelines. The commands are written in sequence separated by |. Different filters are used for Pipes like AWK, GREP. 
e.g. sort file | lpr ( sort the file and send it to printer)
Uses of Pipe
Several powerful functions can be in a single statement
Streams of processes can be redirected to user specified locations using > 
Creating a tar file:
tar -cvvf file.tar myfile.txt
In the above example the system would create a tar named file.tar in the directory you currently are in. Wildcards could also be used in this command, for example: tar -cvvf file.tar *.txt would compress all txt files in the current directory.
tar -cvvf home.tar home/
In the above example command the system would create a tar file named home.tar in the directory you currently are in of the home directory.
Extracting the files from a tar file:
tar -xvvf myfile.tar
In the above example command the system would uncompress (untar) the myfile.tar file in the current directory.
tar -xvvzf myfile.tar.gz
In the above example command the system would uncompress (untar) the myfile.tar.gz file in the current directory.
Note: There is no "untar" linux / unix command.
Creating a tarred file that is compressed with bzip
tar -cjvf test.tbz home/
Adding the j option to the tar command enables tar to compress files and/or directories using bzip. In the above example the home directory and all its subdirectories are added to the compressed test.tbz file.

204. Deleting files created before two days ago

Dear All:

I want to build a shell that delete files created two or more days ago ... I think it could be built using a special command with ls or grep, I'd apreciate any help from you guys

I have a lot of log files from november, december, january and this tool will help me a lot

The files are in different directories, but all of them under my $HOME directory
                                       (OR)
You could use the find command to look for files modified or accessed 2 days ago and remove them. You can do a man find to get more details. Here is an ex:
syntax:
find <directory_name> -name <filename> -mtime +2 -exec rm {} \;

find /ora_export -name "exp*" -mtime +2 -exec rm {} \;

The above command looks for filenames starting with exp which were created/modified 2 days ago and removes them.
You could put it in a shell program also.
mtime means modified time
atime means access time
you could use the one applicable to you.
 what are the backup utilites on red hat linux 4.0?
"dump" utility is used to take backup.
cpio,tar,dump is used to take backups

205. When you install RedHat what is the kernel mode ? What are kernel compilation / upgrade?
I guess the Kernel mode will be kernel itself and the user processes will not be able to use the resources that the Kernel is using. This is done to protect the kernel from user programs. Kernel compilation is installing a new kernel or adding custom modules to the same kernel. Kernel up gradation is upgrading it to a different version altogether.