Thursday, March 25, 2010

Quick Understanding Linux Cron in under 3 Minutes

What is Cron?
In Layman Languages, cron is a Task scheduler used in Linux operating System (but with Great Powers if used with it Complete functionality) developed by Paul Vixie. You can schedule a specific task to be run every minute,hour,day,month.

Majorly cron is used to automate jobs daily without human intervention or manual running of command. Cron can be configured using configuration files which resides in "/etc", changes to which can be done only by the Administrator. Cron also has the feature to run commands using particular user.
Crontab entries


| --------------------------------------------------------------    Minutes (00 - 59)
|    ------------------------------------------------------    Hours (00 - 24)
|    |    ----------------------------------------------    Day of Month (01 - 30)
|    |    |    --------------------------------------    Month (01 - 12)
|    |    |    |    ------------------------------  Day of Week (0 - 6) (Sunday = 0)
|    |    |    |    |    ----------------------    User to the Run the Command
|    |    |    |    |    |        ------    Command / Script to be Executed
|    |    |    |    |    |        |

*    *    *    *    *    root    /home/linuxmaza.com/htdocs/scripts/Stats_Update.sh

If you are a lazy System Adminstrator and Dont want to write the whole entry, cron has several special entries which are shortcuts for specifying a Complete entry.
You can specify entries as below

Entry       ||    Description          ||    Equivalent To
=====================================================
@reboot     Run once, at startup.     None
@yearly     Run once a year     0 0 1 1 *
@annually     (same as @yearly)     0 0 1 1 *
@monthly     Run once a month     0 0 1 * *
@weekly     Run once a week     0 0 * * 0
@daily         Run once a day         0 0 * * *
@midnight     (same as @daily)     0 0 * * *
@hourly     Run once an hour     0 * * * *

Operators in Cron
There are way of specifying multiple date and time in a field which can be overcomed using Operators in cron.

  • The comma (',') operator specifies a list of values, for example: "1,3,4,7,8" (Spaces between the values are not accepted)

  • The dash ('-') operator specifies a range of values, for example: "1-6", which is equivalent to "1,2,3,4,5,6"

  • The asterisk ('*') operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to 'every hour' (depending on other values entered in other fields).

  • The Forward Slash ('/') operator is used to SKIP a given number of values. "Say the value we used is 5" "For Example, "*/5" in the hour time field is equivalent to "0,5,10,15,20" and so on.


Cron Advantages :
1. Can Handle Multiuser
2. Cron enables users to schedule jobs to run automatically at a certain time or date.
3. Automate daily System Administration tasks
4. Operators in Cron saves time and confusion while creating many crons.
5. Support for Special entries using (@reboot, @yearly, @monthly, @weekly, @hourly, @midnight, @daily).


Some Examples
1. If you want to run a task every Hour

0 * * * * root w > /var/log/mysystemstats.log
OR
@hourly root w > /var/log/mysystemstats.log

Above entry would run the "w" command at the start of every hour and redirect the output to "/var/log/mysystemstats.log"

2. Scheduling a cron job running every 15 minutes to delete apache Logs

15 * * * * echo " " > /var/log/httpd/access_log

3. Run a job every 5 hours
* 0,5,10,15,20 * * * echo " " > /var/log/httpd/access_log

Sunday, March 21, 2010

Script to Check IP on SPAM Sources and getting EMAIL and SMS alerts.

As a System Administrators "The Key to a good performing Server is Good IP Reputation"

Maintaining a MAIL Servers or Web Servers is big time for System Admins,there is always a big fear for your IP getting Blacklisted on different SPAM sources due to which mails originated from your server either are not accepted or deffered by the Recipient Server.It would of great help if we get timely EMAIL as well as SMS alerts of IP getting blacklisted. This would make servers perform well as BOUNCES do use system resources which impact on system overall performance (Explaining Which in this article is OUT OF SCOPE.)

You can get this by Paying a Handsome amount of money to a Service Provider or DO MY way. I have written a Shell script using which you can get timely alerts as your IP gets blacklisted. You can put the script in crontab to run every Hour or so.

To START with Copy the script onto you system

# mkdir dnsbl && cd dnsbl

# vim dnsbl_check.sh


Copy the Below Script

#!/bin/bash

# Date: Mar 20,2010
# Author: Ashwin Muni
# Purpose: Check the IP Against Major SPAM Sources.

## Uncomment to Debug
# set -x

# Variables
tmp_file='/tmp/dnsbl'

#IN_DNSBL=127.0.0.[2-6]
#IN_DNSBL=127.0.0.
IN_DNSBL='127.0.0.2|127.0.0.3|127.0.0.4|127.0.0.5|127.0.0.6|127.0.0.7|127.0.0.8|127.0.0.9|127.0.0.10|127.0.0.'
DIG=`which dig`
MAIL_ADMIN="test@example.com ashwin@linuxmaza.com"

###################################################

# SCRIPT START

> $tmp_file

echo "Below IPs are Listed" >> $tmp_file

if [ "$#" == 1 ]; then

for i in `cat rbllist.txt`; do
IP_REV=`echo $1 | awk -F\. '{ print $4"."$3"."$2"."$1 }'`
$DIG $IP_REV.$i | grep $IN_DNSBL

if [ $? == '0' ]; then
#echo "$1 Listed on $i"
echo -e "\033[31m \033[1m PROBLEM : Listed on $i \033[0m \033[22m"
echo "################################ Attention : $1 Listed on $i" >> $tmp_file
else
echo -e "Not Listed on $i : \033[32m \033[1m OK \033[22m \033[0m "
echo "$1 Not Listed on $i" >> $tmp_file
fi
done

echo -e "\033[31m \033[1m ===================$1 is LISTED ON BELOW SPAM SOURCES====================== \033[0m \033[22m"

cat $tmp_file | mail -s "DNSBL REPORT FOR $1" $MAIL_ADMIN

else

echo -e "\t\t\t\t\033[31m \033[1m Enter Proper Arguments:\n Script Usage :\n /bin/sh $0 IP.ADD.RE.SS \033[0m \033[22m"

# EOF

################################################


Save the file Using ":wq"

Make necessary changes in the Script like the System Admin email address to sent Emails.

You will need the SPAM sources to check which you can find Here MAJOR SPAM SOURCES

Copy all the SPAM Sources and paste it in a txt file named "rbllist.txt"

# vi rbllist.txt


Should show you all the Major SPAM Sources for Checking your IPs.

Note: The script and the rbllist.txt should exist in the Same directory.

Once done we will give executable permission to the script which allows us to run it.

# chmod 755 dnsbl_check.sh


OR

# chmod +x dnsbl_check.sh


Now Run the Script

#./dnsbl_check.sh 100.200.100.200


You can put the script in crontab to run it regularly.

MAJOR SPAM Sources where your IPs can get blacklisted which could affect your service.

MAJOR SPAM Sources where your IPs can get blacklisted which could affect your service. Most of the Players in the market like Yahoo, Google, Hotmail use this for stopping huge SPAM to their servers. Many appliances do the same to STOP SPAM.

SPAM Sources

3y.spam.mrs.kithrup.com
access.redhawk.org
all.rbl.kropka.net
all.spamblock.unit.liu.se
assholes.madscience.nl
blackholes.five-ten-sg.com
blackholes.intersil.net
blackholes.mail-abuse.org
blackholes.sandes.dk
blackholes.uceb.org
blackholes.wirehub.net
blacklist.sci.kun.nl
blacklist.spambag.org
bl.borderworlds.dk
bl.csma.biz
block.dnsbl.sorbs.net
blocked.hilli.dk
blocklist2.squawk.com
blocklist.squawk.com
bl.redhatgate.com
bl.spamcannibal.org
bl.spamcop.net
bl.starloop.com
bl.technovision.dk
cart00ney.surriel.com
cbl.abuseat.org
dev.null.dk
dews.qmail.org
dialup.blacklist.jippg.org
dialup.rbl.kropka.net
dialups.mail-abuse.org
dialups.visi.com
dnsbl-1.uceprotect.net
dnsbl-2.uceprotect.net
dnsbl-3.uceprotect.net
dnsbl.ahbl.org
dnsbl.antispam.or.id
dnsbl.cyberlogic.net
dnsbl.kempt.net
dnsbl.njabl.org
dnsbl.solid.net
dnsbl.sorbs.net
dsbl.dnsbl.net.au
duinv.aupads.org
dul.dnsbl.sorbs.net
dul.ru
dun.dnsrbl.net
dynablock.njabl.org
dynablock.wirehub.net
fl.chickenboner.biz
forbidden.icm.edu.pl
form.rbl.kropka.net
hil.habeas.com
http.dnsbl.sorbs.net
http.opm.blitzed.org
intruders.docs.uu.se
ip.rbl.kropka.net
korea.services.net
l1.spews.dnsbl.sorbs.net
l2.spews.dnsbl.sorbs.net
lame-av.rbl.kropka.net
list.dsbl.org
mail-abuse.blacklist.jippg.org
map.spam-rbl.com
misc.dnsbl.sorbs.net
msgid.bl.gweep.ca
multihop.dsbl.org
no-more-funn.moensted.dk
ohps.bl.reynolds.net.au
ohps.dnsbl.net.au
omrs.bl.reynolds.net.au
omrs.dnsbl.net.au
opm.blitzed.org
op.rbl.kropka.net
orbs.dorkslayers.com
orid.dnsbl.net.au
or.rbl.kropka.net
orvedb.aupads.org
osps.bl.reynolds.net.au
osps.dnsbl.net.au
osrs.bl.reynolds.net.au
osps.dnsbl.net.au
osrs.bl.reynolds.net.au
osrs.dnsbl.net.au
owfs.bl.reynolds.net.au
owfs.dnsbl.net.au
owps.bl.reynolds.net.au
owps.dnsbl.net.au
pdl.dnsbl.net.au
probes.dnsbl.net.au
proxy.bl.gweep.ca
psbl.surriel.com
pss.spambusters.org.ar
rbl.cluecentral.net
rblmap.tu-berlin.de
rbl.rangers.eu.org
rbl.schulte.org
rbl.snark.net
rbl.triumf.ca
rdts.bl.reynolds.net.au
rdts.dnsbl.net.au
relays.bl.gweep.ca
relays.bl.kundenserver.de
relays.dorkslayers.com
relays.mail-abuse.org
relays.nether.net
relays.visi.com
ricn.bl.reynolds.net.au
ricn.dnsbl.net.au
rmst.bl.reynolds.net.au
rmst.dnsbl.net.au
rsbl.aupads.org
satos.rbl.cluecentral.net
sbl.csma.biz
sbl.spamhaus.org
sbl-xbl.spamhaus.org
smtp.dnsbl.sorbs.net
socks.dnsbl.sorbs.net
socks.opm.blitzed.org
sorbs.dnsbl.net.au
spam.dnsbl.sorbs.net
spam.dnsrbl.net
spamguard.leadmon.net
spam.olsentech.net
spamsites.dnsbl.net.au
spamsources.dnsbl.info
spamsources.fabel.dk
spamsources.yamta.org
spam.wytnij.to
spews.dnsbl.net.au
t1.bl.reynolds.net.au
t1.dnsbl.net.au
ucepn.dnsbl.net.au
unconfirmed.dsbl.org
vbl.messagelabs.com
vox.schpider.com
web.dnsbl.sorbs.net
whois.rfc-ignorant.org
will-spam-for-food.eu.org
wingate.opm.blitzed.org
xbl.spamhaus.org
zombie.dnsbl.sorbs.net
ztl.dorkslayers.com

Check you IP if is blacklisted using a script SPAM-IP Reputation Check Script

Sunday, March 7, 2010

Top Linux Admin Interview Questions and answers asked in TOP IT industries : Question Bank 06

Linux Admin Interview Questions and Answers


Questions consists of Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 06


# What command can you use to review boot messages?

# What file defines the levels of messages written to system log files?

# What account is created when you install Linux?

# While logged on as a regular user, your boss calls up and wants you to create a new user account immediately. How can you do this without first having to close your work, log off and logon as root? Choose one:
a. Issue the command rootlog.
b. Issue the command su and type exit when finished.
c. Issue the command su and type logoff when finished.
d. Issue the command logon root and type exit when finished.

# Which file defines all users on your system? Choose one:
a. /etc/passwd
b. /etc/users
c. /etc/password
d. /etc/user.conf

# There are seven fields in the /etc/passwd file. Which of the following lists all the fields in the correct order? Choose one:
a. username, UID, GID, home directory, command, comment
b. username, UID, GID, comment, home directory, command
c. UID, username, GID, home directory, comment, command
d. username, UID, group name, GID, home directory, comment

# Which of the following user names is invalid? Choose one:
a. Theresa Hadden
b. thadden
c. TheresaH
d. T.H.

# In order to prevent a user from logging in, you can add a(n) ________at the beginning of the password field.

# The beginning user identifier is defined in the _________ file.

# Which field is used to define the user’s default shell?

# Bob Armstrong, who has a username of boba, calls to tell you he forgot his password. What command should you use to reset his command?

# Your company has implemented a policy that users’ passwords must be reset every ninety days. Since you have over 100 users you created a file with each username and the new password. How are you going to change the old passwords to the new ones? Choose one:
a. Use the chpasswd command along with the name of the file containing the new passwords.
b. Use the passwd command with the -f option and the name of the file containing the new passwords.
c. Open the /etc/passwd file in a text editor and manually change each password.
d. Use the passwd command with the -u option.

Friday, March 5, 2010

Top Linux Admin Interview Questions and answers asked in TOP IT industries : Question Bank 05

Linux Admin Interview Questions and Answers

Questions consists of Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 05


# As the system administrator you need to review Bob’s cronjobs. What command would you use? Choose one:
a. crontab -lu bob
b. crontab -u bob
c. crontab -l
d. cronq -lu bob

# In order to schedule a cronjob, the first task is to create a text file containing the jobs to be run along with the time they are to run. Which of the following commands will run the script MyScript every day at 11:45 pm? Choose one:
a. * 23 45 * * MyScript
b. 23 45 * * * MyScript
c. 45 23 * * * MyScript
d. * * * 23 45 MyScript

# Which daemon must be running in order to have any scheduled jobs run as scheduled? Choose one:
a. crond
b. atd
c. atrun
d. crontab

# You want to ensure that your system is not overloaded with users running multiple scheduled jobs. A policy has been established that only the system administrators can create any scheduled jobs. It is your job to implement this policy. How are you going to do this? Choose one:
a. create an empty file called /etc/cron.deny
b. create a file called /etc/cron.allow which contains the names of those allowed to schedule jobs.
c. create a file called /etc/cron.deny containing all regular usernames.
d. create two empty files called /etc/cron.allow and /etc/cron.deny

# You notice that your server load is exceptionally high during the hours of 10 am to 2 noon. When investigating the cause, you suspect that it may be a cron job scheduled by one of your users. What command can you use to determine if your suspicions are correct? Choose one:
a. crontab -u
b. crond -u
c. crontab -l
d. crond -l

# One of your users, Bob, has created a script to reindex his database. Now he has it scheduled to run every day at 10:30 am. What command should you use to delete this job. Choose one:
a. crontab -ru bob
b. crontab -u bob
c. crontab -du bob
d. crontab -lu bob

# What daemon is responsible for tracking events on your system?

# What is the name and path of the default configuration file used by the syslogd daemon?

# You have made changes to the /etc/syslog.conf file. Which of the following commands will cause these changes to be implemented without having to reboot your computer? Choose one:
a. kill SIGHINT `cat /var/run/syslogd.pid`
b. kill SIGHUP `cat /var/run/syslogd.pid`
c. kill SIGHUP syslogd
d. kill SIGHINT syslogd

# Which of the following lines in your /etc/syslog.conf file will cause all critical messages to be logged to the file /var/log/critmessages? Choose one:
a. *.=crit /var/log/critmessages
b. *crit /var/log/critmessages
c. *=crit /var/log/critmessages
d. *.crit /var/log/critmessages

# You wish to have all mail messages except those of type info to the /var/log/mailmessages file. Which of the following lines in your /etc/syslogd.conf file would accomplish this? Choose one:
a. mail.*;mail!=info /var/log/mailmessages
b. mail.*;mail.=info /var/log/mailmessages
c. mail.*;mail.info /var/log/mailmessages
d. mail.*;mail.!=info /var/log/mailmessages

# What is the name and path of the main system log?

# Which log contains information on currently logged in users? Choose one:
a. /var/log/utmp
b. /var/log/wtmp
c. /var/log/lastlog
d. /var/log/messages

# You have been assigned the task of determining if there are any user accounts defined on your system that have not been used during the last three months. Which log file should you examine to determine this information? Choose one:
a. /var/log/wtmp
b. /var/log/lastlog
c. /var/log/utmp
d. /var/log/messages

# You have been told to configure a method of rotating log files on your system. Which of the following factors do you not need to consider? Choose one:
a. date and time of messages
b. log size
c. frequency of rotation
d. amount of available disk space

# What utility can you use to automate rotation of logs?

# You wish to rotate all your logs weekly except for the /var/log/wtmp log which you wish to rotate monthly. How could you accomplish this. Choose one:
a. Assign a global option to rotate all logs weekly and a local option to rotate the /var/log/wtmp log monthly.
b. Assign a local option to rotate all logs weekly and a global option to rotate the /var/log/wtmp log monthly.
c. Move the /var/log/wtmp log to a different directory. Run logrotate against the new location.
d. Configure logrotate to not rotate the /var/log/wtmp log. Rotate it manually every month.

# You have configured logrotate to rotate your logs weekly and keep them for eight weeks. You are running our of disk space. What should you do? Choose one:
a. Quit using logrotate and manually save old logs to another location.
b. Reconfigure logrotate to only save logs for four weeks.
c. Configure logrotate to save old files to another location.
d. Use the prerotate command to run a script to move the older logs to another location.

Top Linux Admin Interview Questions and answers asked in TOP IT industries : Question Bank 04

Linux Admin Interview Questions and Answers

All Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 04

# You enter the command cat MyFile | sort > DirList & and the operating system displays [4] 3499 What does this mean? Choose one
a. This is job number 4 and the PID of the sort command is 3499.
b. This is job number 4 and the PID of the job is 3499.
c. This is job number 3499 and the PID of the cat command is 4.
d. This is job number 4 and the PID of the cat command is 3499.

# You attempt to log out but receive an error message that you cannot. When you issue the jobs command, you see a process that is running in the background. How can you fix this so that you can logout? Choose one
a. Issue the kill command with the PID of each running command of the pipeline as an argument.
b. Issue the kill command with the job number as an argument.
c. Issue the kill command with the PID of the last command as an argument.
d. Issue the kill command without any arguments.

# You have been given the job of administering a new server. It houses a database used by the sales people. This information is changed frequently and is not duplicated anywhere else. What should you do to ensure that this information is not lost? Choose one
a. Create a backup strategy that includes backing up this information at least daily.
b. Prepare a proposal to purchase a backup server
c. Recommend that the server be made part of a cluster.
d. Install an additional hard drive in the server.

# When planning your backup strategy you need to consider how often you will perform a backup, how much time the backup takes and what media you will use. What other factor must you consider when planning your backup strategy? _________

# Many factors are taken into account when planning a backup strategy. The one most important one is how often does the file ____________.

# Which one of the following factors does not play a role in choosing the type of backup media to use? Choose one:
a. How frequently a file changes
b. How long you need to retain the backup
c. How much data needs to be backed up
d. How frequently the backed up data needs to be accessed

# When you only back up one partition, this is called a ______ backup. Choose one
a. Differential
b. Full
c. Partial
d. Copy

# When you back up only the files that have changed since the last backup, this is called a ______ backup. Choose one
a. Partial
b. Differential
c. Full
d. Copy

# The easiest, most basic form of backing up a file is to _____ it to another location.

# When is the most important time to restore a file from your backup? Choose one
a. On a regular scheduled basis to verify that the data is available.
b. When the system crashes.
c. When a user inadvertently loses a file.
d. When your boss asks to see how restoring a file works.

# As a system administrator, you are instructed to backup all the users’ home directories. Which of the following commands would accomplish this? Choose one
a. tar rf usersbkup home/*
b. tar cf usersbkup home/*
c. tar cbf usersbkup home/*
d. tar rvf usersbkup home/*

# What is wrong with the following command? tar cvfb / /dev/tape 20 Choose one
a. You cannot use the c option with the b option.
b. The correct line should be tar -cvfb / /dev/tape20.
c. The arguments are not in the same order as the corresponding modifiers.
d. The files to be backed up have not been specified.

# You need to view the contents of the tarfile called MyBackup.tar. What command would you use? __________

# After creating a backup of the users’ home directories called backup.cpio you are asked to restore a file called memo.ben. What command should you type?

# You want to create a compressed backup of the users’ home directories so you issue the command gzip /home/* backup.gz but it fails. The reason that it failed is that gzip will only compress one _______ at a time.

# You want to create a compressed backup of the users’ home directories. What utility should you use?

# You routinely compress old log files. You now need to examine a log from two months ago. In order to view its contents without first having to decompress it, use the _________ utility.

Top Linux Admin Interview Questions asked in TOP IT industries : Question Bank 3

Linux Admin Interview Questions and Answers

Questions consists of Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 03


# When typing at the command line, the default editor is the _____________ library.

# You typed the following at the command line ls -al /home/ hadden. What key strokes would you enter to remove the space between the ‘/’ and ‘hadden’ without having to retype the entire line? Choose one
a. Ctrl-B, Del
b. Esc-b, Del
c. Esc-Del, Del
d. Ctrl-b, Del

# You would like to temporarily change your command line editor to be vi. What command should you type to change it?

# After experimenting with vi as your command line editor, you decide that you want to have vi your default editor every time you log in. What would be the appropriate way to do this? Choose one
a. Change the /etc/inputrc file
b. Change the /etc/profile file
c. Change the ~/.inputrc file
d. Change the ~/.profile file

# You have to type your name and title frequently throughout the day and would like to decrease the number of key strokes you use to type this. Which one of your configuration files would you edit to bind this information to one of the function keys?

# In your present working directory, you have the files maryletter memo1 MyTelephoneandAddressBook What is the fewest number of keys you can type to open the file MyTelephoneandAddressBook with vi? Choose one
a. 6
b. 28
c. 25
d. 4

# A variable that you can name and assign a value to is called a _____________ variable.

# You have installed a new application but when you type in the command to start it you get the error message Command not found. What do you need to do to fix this problem? Choose one
a. Add the directory containing the application to your path
b. Specify the directory’s name whenever you run the application
c. Verify that the execute permission has been applied to the command.
d. Give everyone read, write and execute permission to the application’s directory.

# You telnet into several of your servers simultaneously. During the day, you sometimes get confused as to which telnet session is connected to which server. Which of the following commands in your .profile file would make it obvious to which server you are attached? Choose one
a. PS1=’\h: \w>’
b. PS1=’\s: \W>’
c. PS1=’\!: \t>’
d. PS1=’\a: \n>’

# Which of the following environment variables determines your working directory at the completion of a successful login? Choose one
a. HOME
b. BASH_ENV
c. PWD
d. BLENDERDIR

# Every time you attempt to delete a file using the rm utility, the operating system prompts you for confirmation. You know that this is not the customary behavior for the rm command. What is wrong? Choose one
a. rm has been aliased as rm -i
b. The version of rm installed on your system is incorrect.
c. This is the normal behavior of the newest version of rm.
d. There is an incorrect link on your system.

# You are running out of space in your home directory. While looking for files to delete or compress you find a large file called .bash_history and delete it. A few days later, it is back and as large as before. What do you need to do to ensure that its size is smaller? Choose one
a. Set the HISTFILESIZE variable to a smaller number.
b. Set the HISTSIZE to a smaller number.
c. Set the NOHISTFILE variable to true.
d. Set the HISTAPPEND variable to true.

# In order to display the last five commands you have entered using the history command, you would type ___________.

# In order to display the last five commands you have entered using the fc command, you would type ___________.

# You previously ran the find command to locate a particular file. You want to run that command again. What would be the quickest way to do this? Choose one
a. fc -l find fc n
b. history -l find history n
c. Retype the command
d. fc -n find

# Using command substitution, how would you display the value of the present working directory? Choose one
a. echo $(pwd)
b. echo pwd
c. $pwd
d. pwd | echo

# You need to search the entire directory structure to locate a specific file. How could you do this and still be able to run other commands while the find command is still searching for your file? Choose one
a. find / -name filename &
b. find / -name filename
c. bg find / -name filename
d. &find / -name filename &

# In order to create a file called DirContents containing the contents of the /etc directory you would type ____________.

# What would be displayed as the result of issuing the command ps ef? Choose one
a. A listing of the user’s running processes formatted as a tree.
b. A listing of the stopped processes
c. A listing of all the running processes formatted as a tree.
d. A listing of all system processes formatted as a tree.

# What utility can you use to show a dynamic listing of running processes? __________

# The top utility can be used to change the priority of a running process? Another utility that can also be used to change priority is ___________?

# What key combination can you press to suspend a running job and place it in the background?

# You issue the command jobs and receive the following output: [1]- Stopped (tty output) pine [2]+ Stopped (tty output) MyScript How would you bring the MyScript process to the foreground? Choose one:
a. fg %2
b. ctrl-c
c. fg MyScript
d. ctrl-z

Top Linux Admin Interview Questions asked in TOP IT industries : Question Bank 2

Top Linux Admin Interview Questions and Answers

Questions consists of Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 02


# What command is used to remove the password assigned to a group?

# You changed the GID of the sales group by editing the /etc/group file. All of the members can change to the group without any problem except for Joe. He cannot even login to the system. What is the problem? Choose one:
a. Joe forgot the password for the group.
b. You need to add Joe to the group again.
c. Joe had the original GID specified as his default group in the /etc/passwd file.
d. You need to delete Joe’s account and recreate it.

# You need to delete the group dataproject. Which two of the following tasks should you do first before deleting the group?
A. Check the /etc/passwd file to make sure no one has this group as his default group.
B. Change the members of the dataproject group to another group besides users.
C. Make sure that the members listed in the /etc/group file are given new login names.
D. Verify that no file or directory has this group listed as its owner.
Choose one: a. A and C b. A and D c. B and C d. B and D

# When you look at the /etc/group file you see the group kmem listed. Since it does not own any files and no one is using it as a default group, can you delete this group?

# When looking at the /etc/passwd file, you notice that all the password fields contain ‘x’. What does this mean? Choose one:
a. That the password is encrypted.
b. That you are using shadow passwords.
c. That all passwords are blank.
d. That all passwords have expired.

# In order to improve your system’s security you decide to implement shadow passwords. What command should you use?

# What file contains the default environment variables when using the bash shell? Choose one:
a. ~/.profile
b. /bash
c. /etc/profile
d. ~/bash

# You have created a subdirectory of your home directory containing your scripts. Since you use the bash shell, what file would you edit to put this directory on your path? Choose one:
a. ~/.profile
b. /etc/profile
c. /etc/bash
d. ~/.bash

# Which of the following interprets your actions when typing at the command line for the operating system? Choose One
a. Utility
b. Application
c. Shell
d. Command

# What can you type at a command line to determine which shell you are using?

# You want to enter a series of commands from the command-line. What would be the quickest way to do this? Choose One
a. Press enter after entering each command and its arguments
b. Put them in a script and execute the script
c. Separate each command with a semi-colon (;) and press enter after the last command
d. Separate each command with a / and press enter after the last command

# You are entering a long, complex command line and you reach the right side of your screen before you have finished typing. You want to finish typing the necessary commands but have the display wrap around to the left. Which of the following key combinations would achieve this? Choose One
a. Esc, /, Enter
b. /, Enter
c. ctrl-d, enter
d. esc, /, ctrl-d

# After typing in a new command and pressing enter, you receive an error message indicating incorrect syntax. This error message originated from.. Choose one
a. The shell
b. The operating system
c. The command
d. The kernel

Top Linux Admin Interview Questions asked in TOP IT industries

Hey Guys, AFRAID of interviews

DONT Worry prepare the following questions before Interview. I have managed to prepare some questions sets. Practice this and i'm sure you would crack a L1/L2/L3 Linux Administrator Job Easily. All the questions are taken from the top IT brands interviews.

Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Questions BANK 01

# You attempt to use shadow passwords but are unsuccessful. What characteristic of the /etc/passwd file may cause this? Choose one:
a. The login command is missing.
b. The username is too long.
c. The password field is blank.
d. The password field is prefaced by an asterick.

# You create a new user account by adding the following line to your /etc/passwd file. bobm:baddog:501:501:Bob Morris:/home/bobm:/bin/bash Bob calls you and tells you that he cannot logon. You verify that he is using the correct username and password. What is the problem? Choose one:
a. The UID and GID cannot be identical.
b. You cannot have spaces in the line unless they are surrounded with double quotes.
c. You cannot directly enter the password; rather you have to use the passwd command to assign a password to the user.
d. The username is too short, it must be at least six characters long.

# Which of the following tasks is not necessary when creating a new user by editing the /etc/passwd file? Choose one:
a. Create a link from the user’s home directory to the shell the user will use.

b. Create the user’s home directory
c. Use the passwd command to assign a password to the account.
d. Add the user to the specified group.

# You create a new user by adding the following line to the /etc/passwd file bobm::501:501:Bob Morris:/home/bobm:/bin/bash You then create the user’s home directory and use the passwd command to set his password. However, the user calls you and says that he cannot log on. What is the problem? Choose one:
a. The user did not change his password.
b. bobm does not have permission to /home/bobm.
c. The user did not type his username in all caps.
d. You cannot leave the password field blank when creating a new user.

# When using useradd to create a new user account, which of the following tasks is not done automatically. Choose one:
a. Assign a UID.
b. Assign a default shell.
c. Create the user’s home directory.
d. Define the user’s home directory.

# You issue the following command useradd -m bobm But the user cannot logon. What is the problem? Choose one:
a. You need to assign a password to bobm’s account using the passwd command.
b. You need to create bobm’s home directory and set the appropriate permissions.
c. You need to edit the /etc/passwd file and assign a shell for bobm’s account.
d. The username must be at least five characters long.

# You have created special configuration files that you want copied to each user’s home directories when creating new user accounts. You copy the files to /etc/skel. Which of the following commands will make this happen? Choose one:
a. useradd -m username
b. useradd -mk username
c. useradd -k username
d. useradd -Dk username

# Mary has recently gotten married and wants to change her username from mstone to mknight. Which of the following commands should you run to accomplish this? Choose one:
a. usermod -l mknight mstone
b. usermod -l mstone mknight
c. usermod -u mknight mstone
d. usermod -u mstone mknight

# After bob leaves the company you issue the command userdel bob. Although his entry in the /etc/passwd file has been deleted, his home directory is still there. What command could you have used to make sure that his home directory was also deleted? Choose one:
a. userdel -m bob
b. userdel -u bob
c. userdel -l bob
d. userdel -r bob

# All groups are defined in the /etc/group file. Each entry contains four fields in the following order. Choose one:
a. groupname, password, GID, member list
b. GID, groupname, password, member list
c. groupname, GID, password, member list
d. GID, member list, groupname, password

# You need to create a new group called sales with Bob, Mary and Joe as members. Which of the following would accomplish this? Choose one:
a. Add the following line to the /etc/group file: sales:44:bob,mary,joe
b. Issue the command groupadd sales.
c. Issue the command groupadd -a sales bob,mary,joe
d. Add the following line to the /etc/group file: sales::44:bob,mary,joe
Linux Admin Interview Questions and Answers, Linux Administration questions, Linux Networking questions, MYSQL questions, bash, postfix questions, sendmail questions, ftp server questions

Checking if MYSQL is 32Bits or 64Bits?

Do you know MYSQL installed on your system is MYSQL 32Bit or MYSQL 64Bit.


You can achieve this in Different Ways. The best command i found was "file"

Find the MYSQLD location

# which mysqld
/bin/mysqld


# file /bin/mysqld
/bin/mysqld: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped


FOR 64 Bit this would show

# file /bin/mysqld
/usr/sbin/mysqld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped


The other way to find is using mysql to find it
MYSQL on 32 Bit System

mysql> SHOW GLOBAL VARIABLES LIKE 'version_compile_machine';
+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| version_compile_machine | i686 |
+-------------------------+-------+
1 row in set (0.00 sec)


MYSQL on 64 Bit System
mysql> show variables like 'version_compile_machine';
+-------------------------+--------+
| Variable_name | Value |
+-------------------------+--------+
| version_compile_machine | x86_64 |
+-------------------------+--------+


We can also check if the mysqld binary are linked to which library
MYSQL on 32bit System
[root@localhost ~]# ldd /bin/mysqld
linux-gate.so.1 => (0x00df0000)
libpthread.so.0 => /lib/libpthread.so.0 (0x007cf000)
libdl.so.2 => /lib/libdl.so.2 (0x007c9000)
librt.so.1 => /lib/librt.so.1 (0x007fd000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x0490d000)
libnsl.so.1 => /lib/libnsl.so.1 (0x0032e000)
libm.so.6 => /lib/libm.so.6 (0x007a0000)
libc.so.6 => /lib/libc.so.6 (0x0065a000)
/lib/ld-linux.so.2 (0x00637000)


MYSQL on 64 Bit System
# ldd /usr/local/mysql/libexec/mysqld
linux-vdso.so.1 => (0x00007fff6d5ff000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007ff3650d3000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007ff364ebc000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007ff364bb0000)
libdl.so.2 => /lib/libdl.so.2 (0x00007ff3649ac000)
librt.so.1 => /lib/librt.so.1 (0x00007ff3647a3000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x00007ff36456b000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00007ff364353000)
libm.so.6 => /lib/libm.so.6 (0x00007ff3640d0000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007ff363eb9000)
libc.so.6 => /lib/libc.so.6 (0x00007ff363b66000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff3652ef000)


Another Method is using "ELFREAD"
MYSQL on 32 Bit System

[root@localhost ~]# readelf -h /bin/mysqld
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x81805a0
Start of program headers: 52 (bytes into file)
Start of section headers: 39507760 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 9
Size of section headers: 40 (bytes)
Number of section headers: 44
Section header string table index: 41


MYSQL on 64 Bit System

[root@localhost ~]# readelf -h /bin/mysqld
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x4e5a30
Start of program headers: 64 (bytes into file)
Start of section headers: 7548008 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 9
Size of section headers: 64 (bytes)
Number of section headers: 32
Section header string table index: 31