Pages

Wednesday, September 5, 2012

Test your knowledge on Linux!!

The computer BIOS will try to boot from which partition?
first
master
active
primary
system

What action in /etc/inittab says to restart processes that have ended?
init
restart
wait
respawn
reload

The information displayed during the boot process is typically written to which file?
/var/log/start.log
/var/log/message 
/var/adm/start.log
/var/adm/syslog
/var/log/syslog

The system logging daemon is
loggerd
logd
logger
syslogger
syslogd

Typically the default run level for Linux is

S
init
1
2

What is the configuration file for the init program?
/etc/default/inittab
/var/adm/inittab
/etc/init.conf
/var/adm/init.conf
/etc/inittab

What is the configuration file for the init program?
/etc/init.conf 
/var/adm/inittab
/etc/inittab
/var/adm/init.conf
/etc/default/inittab

What is typically the first step when your computer boots?
POST 
lilo
rc-scripts
init
kernel start-up

What command would you use if you wanted to send regular warnings to users as the system is shutting down?
stop
shutdown 
halt
haltsys
reboot

What provides the "boot prompt" at system start-up and processes the various options?
BIOS
The primary boot loader
the kernel
init
The secondary boot loader

Errors encountered as the system boots can be found in
/var/log/errors
/etc/messages
/var/log/messages 
/usr/adm/logs
/usr/adm/errors

Unlike DOS and Windows, Ctrl-Alt-Del will not reboot your Linux system.
False 
True

What file is used to configure the system logger daemon?
/etc/syslog.conf 
/var/opt/logger.conf
/etc/logger.conf
/var/opt/syslog.conf
/etc/default/logger.conf

What option to halt says to power off when the system is down?
-r
-p
-n
-k
-P

Which file contains a list users, one of which must be logged in on a virtual console before the shutdown command can be used?
/etc/shutdown.enable
/etc/allow.shutdown
/etc/shutdown.allow
/etc/syconfig/shutdown
/etc/shutdown

What action in /etc/inittab determines what is run when CTRL-ALT-DEL is pressed.
powerdown
ctraltdel 
sysreboot
shutdown
reboot

LILO uses the system BIOS to access the hard disk.
False
True

Which actions in /etc/inittab are run first
boot
once
sysinit
ondemand
bootwait

The kernel is often stored in which directory?
/sys
/system
/boot 
/kernel
/start

Virus can typically only affect Linux if the attack the master boot record.
False
True

What does POST stand for?
Pre-Operations System Test
Post-On Self-Test
Pre-Operating System Test
Power-On Self-Test
Pre-Operating System Tasks

Which actions in /etc/inittab are run first
sysinit 
bootwait
once
ondemand
boot

What file is used to configure the system logger daemon?
/var/opt/logger.conf
/etc/logger.conf
/var/opt/syslog.conf
/etc/default/logger.conf
/etc/syslog.conf

What option to shutdown tells how many seconds to wait before starting the actual shutdown?
-s
-r
-k
-t 
-w

Which run level would shut down the system
4
2
3
1
0

What is the first process started?
init 
vmlinuz
loader
kernel.init
lilo

What option to shutdown forces the system to reboot?
-r 
-w
-F
-f
-n

What is another term for run-level 1?
start mode or maintenance mode
boot mode or maintenance mode
single-user or admin mode
single-user or maintenance mode 
start mode or boot mode

What entry in the inittab file determines the (system's) run level for a normal boot?
startup
initdefault 
default
initial
boot

Where is hardware information stored that the system uses when booting?
POST
PCI
RAM
DMA
CMOS

What Version of Linux and What Machine Name Is This?
A: Type:
 $ uname -a

1.Every command in Linux is a
text file
stored variable
executable program
None

2. How long can a filename in Linux be?
8 characters
10 characters
200 characters
255 characters

3. What is the shortcut to the login directory?
shift + cd
cd + enter key
alt + ctrl + cd
ctrl + cd

4. The hierarchy of a series of directories branching in a user system starts from
\home
\root
/home
/root

5. Saving open files, flush the system cache and other necessary system maintenance are allowed by.
restarting the system
rebooting the system
logging off the system
shutting down the system

6. Which directory contains configuration files that stores system and application setting?
/etc
/lib
/usr
/var

7. Which command is used to find data files, programs, directories that match the search argument?
find
search
locate
browse

8. Applications written to provide a GUI shell for Unix and Linux are called
DOS
x windows
OS/2
Vista

9. The advantage of using NFS rather than Samba for file sharing in Linux is
files saved as .tar extension
compressed files
compatibility with Windows file sharing
None of the above

10. Which framework is provided for the programs to interchange information about Linux OS?
Resource Sharing Framework
Resource Security Framework
Information Sharing Framework
Resource Definition Framework

11. To implement new application on IBM z/10. Which of the following options need to be considered if it to be implemented in Linux?
IBM z/OS outperforms Red Hat Linux in commercial workloads
IBM z/OS is more expensive, Linux is shareware
Red Hat Linux does not support all the devices supported by IBM z/OS
z/OS is supported by IBM SupportLine, whereas Red Hat Linux can only be supported by Red Hat


12. Which of the following has greater market share of Linux SW/HW environment?
Linux on z10
Linux HP integrity servers
Linux on AS/400 servers locate
Linux on DELL Xeon

13. Which of the following commands can be run to remove all the rules in an iptables table?
iptables -L
iptables -A
iptables -F
iptables --delete

14. Which of the following is the BEST way to set up SSH(Secure Shell) for communicating between Systems without needing passwords?
Correct answer: Use ssh-keygen for generating public-private keys.

15. How much usable space is available, when a Linux system is configured with a RAID 5 array that consists of six 20 GB hard disk drives?
80
100
120
60

16. Which of the following commands can be used to check for file corruption?
md5sum
checkfile
cat -vet
tar --checksum

17. Which of the following allows to secure remote command line access?
telnet
SSL
SSH(Secure Shell)
Rlogin

18. Which of the following supports for creating a Linux VPN (Virtual Private Network)?
RC2
3DES
chap
NTLMv2

19. Which of the following commands delete the files from the /tmp directory, issued by non-root user?
rmdir -rf /tmp/*
rm -rf /tmp/* -su
su -c "rm -rf /tmp/*"
su "rm -rf /tmp/*"

20. Which configuration does cardmgr read at Linux system startup?
PCMCIA cards
PCI cards
USB cards
SCSI cards

21. When a computer system is reported problems with inodes and blocks, which of the following is the problem and its solution to rectify it?
The file system has become corrupt and needs to be repaired.
The boot sector is corrupt and needs to be repaired.
The drive is configured using an improper file system and needs to be reformatted.
The partition table has become corrupt and needs to be replaced.

22. Which Linux command will successfully mounts a USB drive?
mount /dev/uda1 /mnt/usb
mount /dev/sda1 /mnt/usb
mount -t usbfs /dev/usb001 /mnt/usb
mount /dev/hde1 /mnt/usb

23. ___________ is a common tool for determining services and ports running on a remote Linux.
arp
nmap
netstat
None of the above

24. For supporting new diskless client workstations, which of the following services needs to be installed on a server?
dhcpcd and rexec
named and httpd
remoted and dhcpd
PXE (Preboot eXecution Environment) and tftpd

25. Which of the following will kill the process 1010 by an administrator(logged in as a standard user)? The process 1010 was started by the root user.
kill 1010
su "kill 1010"
su -c "kill 1010"
killall -9 1010

26. Which of the following Linux commands could be used to find what processor was detected on boot, when a laptop system is slow/
proc
POST
dmesg
Any of the above

27. How to accomplish the LILO boot configuration updation for supporting a newly installed IDE hard drive?
Run "lilo -o /dev/hda"
Edit lilo.conf and run "lilo -v -v"
Edit lilo.conf and run "liloconf -v -v"
Set LILO=/dev/hda and then run "liloconf /dev/hda"

1. Which of the following below are true functionalities of Kernel?
Allocates time and memory to programs
Authenticates user
Interprets commands
All of the above

2. Which of the following below are true functionalities of shell?
Authenticates user
Interprets commands
Allocates time and memory to programs
only a and b

3. Which command is used to find what is in your home directory?
% List
% ls
% home
Either a or c

4. cd home to get back to your home-directory?
True
False

5. Which command is used to clear the screen?
% clear
clear
% clrscr
either a or c

6. The head command writes the first _____________ lines of a file to the screen.
five
Twenty
ten
fifteen

7. What is used to search files for specified words or patterns?
less
srch
%src
grep

8. > symbol is used to redirect the output of a command
True
False

9. Pipe symbol is represented by
||
|
^
$

10. Which character is used to match exactly one character?
|
*
^
?

11. Which command is used to see the online manual?
man
manual
*man
%man

12. A process is identified by a unique
pid
id
processid
proid

13. A process can run only in the background
True
False

14. Which command reduces the size of a file?
pzip
gcat
pgcat
gzip

15. Find command can search for files by
date
size
name
all of above

16. Which of the following below are environmental variables?
USER
HOME
both a and b
VARHOST

17. CWD is a type of shell variable
True
False

18. How can we find the current value for shell variables?
Set command
Display command
val command
Currval command

19. What is the difference between PATH and path?
PATH and path specify directories to search for commands and programs
Both variables always represent the same directory list
altering either automatically causes the other to be changed
All of the above


20. What is the default number of shell commands saved in the history list of .cshrc file?
200
100
150
175

21. What is the difference between linux file system and windows file system?
Under Linux, the various partitions are detected at boot and assigned a drive letter whereas Under windows, unless you mount a partition or a device, the system does not know of the existence of that partition or device.
Under Windows, the various partitions are detected at boot and assigned a drive letter whereas Under Linux, unless you mount a partition or a device, the system does not know of the existence of that partition or device.
Under Windows, the various partitions are detected at reboot and assigned a drive letter whereas Under Linux, unless you mount a partition or a device, the system does not know of the existence of that partition or device.
Under Windows, the various partitions are detected at reboot and assigned a drive letter whereas Under Linux, you mount a partition or a device.

22. What is the content of /etc directory?
Configuration files for your system.
Contains the system startup scripts
Both a and b
User-specific settings for programs like IRC, X etc.

23. /temp is a type of filesystem
True
False

24. The basic function of ______________ is to search files for lines (or other units of text) that contain a pattern.
awk
search
%awk
cat

25. Which of the following below is/are true for Date command?
It can work w/o arguments
It always needs an argument
It always need to have a+ as an argument
None of the above

1. Echo is used to Display message on screen. Which of the following options below should be used with echo to not output the trailing newline?
/e
/n
-n
both b and c

2. mount –r is used to mount a file in read only mode
True
False==

3. Which command is most useful when you want not only to send some data down a pipe, but also to save a copy?
pipe
awk
split
tee

4. There is no difference between who and whoami command?
True
False

5. When trying to compare two files using cmp, if the files differ; what is the output?
tells the first byte where they differ
tells the line number where they differ
tells the first byte and line number where they differ
it displays the files

6. Cal is used to display calendar. If no arguments are supplied, what is displayed?
The current month is displayed
Nothing is displayed
Shows an error
None of the above

7. Which of the following command is used to test a network connection?
ping
pingall
echo
both a and b

8. Ping will only report damaged packets.
True
False

9. Which of the following are valid functions of Red Hat Package Manager?
Used to verify software packages.
search engine to search for software’s
search engine to search for commandsnettop
both a and b

10. What is the Non interactive mode of nslookup used for?
Fetch information about the specified host or domain
Interact by querying information
none of the able
Both a and b

11. Nettop is used to find network usage
True
False

12. In _____________ state of a process, the process will be terminated and the information will still be available in the process table.
Interruptible
Uninterruptible
Zombie
Running

13. Which system call is used to bias the existing property of process?
proc()
bias()
Exec()
Nice()

14. LD_LIBRARY_PATH is a type of
system call
command
Environmental variable
both b and c

15. What is the major difference between UNIX and LINUX?
Linux is an open source and free software
UNIX is an open source and free software
UNIX uses Linux like OS
Both a and c

16. What is the use of a pipe?
Several functions can be combined in a single statement.
UNIX is an open source and free software
Stream input to output.
Both a and c

17. By default, the shell uses the _______________ library
read
data
readline
processline

18. The kernel cannot be updated.
True
False

19. Which of the following below are types of shell?
-ksh
-/bin
-tcsh
all of the above

20. The ______________ file contains all the information on users who may log into your system
/etc/passwd
/etc
/etc/password
/etc/pass

21. Which directory is used to write messages when kernel is loading?
/etc/log/messages
/var/log/messages
/var/messages
/etc/ messages

22. Which command is used to report on the status of the quotas that have set including the amount of allocated space and amount of used space?
quota -a
repquota
repquota -a
rquota -a

23. Linux Support s Virtualized File Systems Like RAID.
True
False

24. When Linux is installed, which account is created by default?
Super admin
Admin
Home
Root

25. Using CHMOD if we want to give ALL permissions to a user, which mode is used?
666
777
776
667

26. Why do we use pgrep command?
To search through the currently running processes
To search through all the processes
To search through the currently running processes and kill them
Both a and b

1. Q. How do you list files in a directory?

   A. ls  - list directory contents
   ls -l (-l  use a long listing format)

2. Q. How do you list all files in a directory, including the hidden files?
   A. ls -a  (-a, do not hide entries starting with .)

3. Q. How do you find out all processes that are currently running?
   A. ps -f (-f does full-format listing.)

4. Q. How do you find out the processes that are currently running or a particular user?
   A. ps -au Myname   (-u by effective user ID (supports names)) (a - all users)

5. Q. How do you kill a process?
   A. kill -9  8 (process_id 8) or kill -9  %7  (job number 7)
      kill -9 -1  (Kill all processes you can kill.)
      killall - kill processes by name most (useful - killall java)

6. Q. What would you use to view contents of the file?
   A. less filename
      cat filename
      pg filename
      pr filename
      more filename
      most useful is command: tail file_name - you can see the end of the log file.

7. Q. What would you use to edit contents of the file?
   A. vi  screen editor or jedit, nedit or ex  line editor

8. Q. What would you use to view contents of a large error log file?
   A. tail  -10 file_name   ( last 10 rows)

9. Q. How do you log in to a remote Unix box?
   A. Using telnet server_name or ssh -l ( ssh - OpenSSH SSH client (remote login program))

10.Q. How do you get help on a UNIX terminal?
   A. man command_name
      info command_name (more information)

11.Q. How do you list contents of a directory including all of its
  subdirectories, providing full details and sorted by modification time?
   A. ls -lac
      -a all entries
      -c by time

12.Q. How do you create a symbolic link to a file (give some reasons of doing so)?
   A. ln /../file1 Link_name
Links create pointers to the actual files, without duplicating the contents of
the files. That is, a link is a way of providing another name to the same file.
There are two types of links to a file:Hard link, Symbolic (or soft) link;

13.Q. What is a filesystem?
   A. Sum of all directories called file system.
      A file system is the primary means of file storage in UNIX.
      File systems are made of inodes and superblocks.

14.Q. How do you get its usage (a filesystem)?
   A. By storing  and manipulate  files.

15.Q. How do you check the sizes of all users home directories (one command)?
   A. du -s
      df
The du command summarizes disk usage by directory. It recurses through all subdirectories and shows disk usage by each subdirectory with a final total at the end.

   Q. in current directory
   A. ls -ps (p- directory; s - size)

16.Q. How do you check for processes started by user 'pat'?
 A. ps -fu pat   (-f -full_format u -user_name )

17.Q. How do you start a job on background?
  A. bg  %4  (job 4)

18 Q. What utility would you use to replace a string '2001' for '2002' in a text file?
   A. Grep,  Kde( works on Linux and Unix)

19. Q. What utility would you use to cut off the first column in a text file?
    A. awk, kde

20. Q. How to copy file into directory?
    A. cp  /tmp/file_name . (dot mean in the current directory)

21. Q. How to remove directory with files?
    A. rm -rf directory_name

22. Q. What is the difference between internal and external commands?
    A. Internal commands are stored in the; same level as the operating system while external
commands are stored on the hard disk among the other utility programs.

23. Q. List the three main parts of an operating system command:
    A. The three main parts are the command, options and arguments.

24  Q. What is the difference between an argument and an option (or switch)?
    A. An argument is what the command should act on: it could be a filename,
directory or name. An option is specified when you want to request additional
information over and above the basic information each command supplies.

25. Q. What is the purpose of online help?
    A. Online help provides information on each operating system command, the
syntax, the options, the arguments with descriptive information.

26.  Q. Name two forms of security.
    A.  Two forms of security are Passwords and File Security with permissions specified.

27. Q. What command do you type to find help about the command who?
    A. $ man who

28. Q. What is the difference between home directory and working directory?
    A. Home directory is the directory you begin at when you log into the
system. Working directory can be anywhere on the system and it is where you are currently
working.

29. Q. Which directory is closer to the top of the file system tree, parent directory or current directory?
    A. The parent directory is above the current directory, so it is closer to the root or top of the file system.

30. Q. Given the following pathname:
$ /business/acctg/payable/supplier/april
a) If you were in the directory called acctg, what would be the relative
pathname name for the file called april?
b) What would be the absolute pathname for april?
   A.
a) $payable/supplier/april
b) $ /business/acctg/payable/supplier/april

31. Q. Suppose your directory had the following files:
help. 1 help.2 help.3 help.4 help.O1 help.O2
aid.O1 aid.O2 aid.O3 back. 1 back.2 back.3
a) What is the command to list all files ending in 2?
b) What is the command to list all files starting in aid?
c) What is the command to list all "help" files with one character extension?
     A.
a) ls *2
b) ls aid.*
c) ls help.?

32. Q. What are two subtle differences in using the more and the pg commands?
    A.  With the more command you display another screenful by pressing
 the spacebar, with pg you press the return key.
      The more command returns you automatically to the UNIX
shell when completed, while pg waits until you press return.

33. Q. When is it better to use the more command rather than cat command?
    A. It is sometimes better to use the more command when you are viewing
 a file that will display over one screen.

34. Q. What are two functions the move mv command can carry out?
    A. The mv command moves files and can also be used to rename a file or directory.

35. Q. Name two methods you could use to rename a file.
    A. Two methods that could be used:
a. use the mv command
b. copy the file and give it a new name and then remove the original file if no longer needed.

36. The soccer league consists of boy and girl teams. The boy file names begin
with B, the girl teams begin with G. All of these files are in one directory
called "soccer", which is your current directory:
Bteam.abc Bteam.OOl Bteam.OO2 Bteam.OO4
Gteam.win Gteam.OOl Gteam.OO2 Gteam.OO3
Write the commands to do the following:
a) rename the file Bteam.abc to Bteam.OO3.
b) erase the file Gteam. win after you have viewed the contents of the file
c) make a directory for the boy team files called "boys", and one for the girl team files
called" girls"
d) move all the boy teams into the "boys" directory
e) move all the girl teams into the "girls" directory
f) make a new file called Gteam.OO4 that is identical to Gteam.OOl
g) make a new file called Gteam.OO5 that is identical to Bteam.OO2
  A.
a) mv Bteam.abc Bteam.OO3.
b) cat Gteam.win -or- more Gteam.win
rm Gteam. win
c) mkdir boys
mkdir girls
d) mv Bteam* boys
e) mv Gteam* girls
f) cd girls
cp Gteam.OO1 Gteam.OO4
g) There are several ways to do this. Remember that we are currently in the directory
/soccer/girls.
cp ../boys/Bteam.OO2 Gteam.OO5
or
cd ../boys
cp Bteam.OO2 ../girls/Gteam.OO5

38. Q. What metacharacter is used to do the following:
1.1 Move up one level higher in the directory tree structure
1.2 Specify all the files ending in .txt
1.3 Specify one character
1.4 Redirect input from a file
1.5 Redirect the output and append it to a file
    A.
1. 1.1 double-dot or ..
1.2 asterisk or *
1.3 question or ?
1.4 double greater than sign: >>
1.5 the less than sign or <

39. Q. List all the files beginning with A
    A. To list all the files beginning with A command: ls A*

40. Q. Which of the quoting or escape characters allows the dollar sign ($) to retain its special meaning?
    A. The double quote (") allows the dollar sign ($) to retain its special meaning.
Both the backslash (\) and single quote (') would remove the special meaning of the dollar sign.

41. Q. What is a faster way to do the same command?
mv fileO.txt newdir
mv filel.txt newdir
mv file2.txt newdir
mv file3.txt newdir
    A. A shortcut method would be:   mv file?.txt newdir

42. Q. List two ways to create a new file:
    A.
a. Copy a file to make a new file.
b. Use the output operator e.g. ls -l > newfile.txt

43. Q. What is the difference between > and >> operators?
    A. The operator > either overwrite the existing file (WITHOUT WARNING) or creates a new file.
The operator >> either adds the new contents to the end of an existing file or creates a new file.

44. Write the command to do the following:
44.1 Redirect the output from the directory listing to a printer.
44.2 Add the file efg.txt to the end of the file abc.txt.
44.3 The file testdata feeds information into the file called program
44.4 Observe the contents of the file called xyz.txt using MORE.
44.5 Observe a directory listing that is four screens long.
     A.
44.1 ls > lpr
44.2 cat efg.txt >> abc.txt
44.3 program < testdata
44.4 more < xyz.txt
44.5 ls > dirsave | more

45. Q. How do you estimate file space usage
    A. Use du command (Summarize disk usage of each FILE, recursively for
directories.) Good to use arguments du -hs
(-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
(-s, --summarize display only a total for each argument)

46. Q. How can you see all mounted drives?
    A. mount -l

47. Q. How can you find a path to the file in the system?
    A. locate file_name (locate - list files in databases that match a pattern)

48. Q. What Linux  HotKeys do you know?
    A. Ctrl-Alt-F1 Exit to command prompt
       Ctrl-Alt-F7 or F8    Takes you back to KDE desktop from command prompt
       Crtl-Alt-Backspace Restart XWindows
       Ctrl-Alt-D Show desktop

49. Q. What can you tell about the tar Command?
    A. The tar program is an immensely useful archiving utility. It can combine
an entire directory tree into one large file suitable for transferring or compression.

50.  Q. What types of files you know?
     A. Files come in eight flavors:
Normal files
Directories
Hard links
Symbolic links
Sockets
Named pipes
Character devices
Block devices

51.  Q. How to copy files from on PC to another on the same network
     A. Use the following command:scp yur_file you_login@your_IP
example: copy .conf file from your PC  to alex computer-
 scp /etc/X11/xorg.conf alex@10.0.10.169:

52.  Q. Please describe information below:
-rw-rw-r--    1 dotpc    dotpc         102 Jul 18  2003 file.buf
drwxr-xr-x    9 dotpc    dotpc        4096 Oct 21 09:34 bin
lrwxrwxrwx    1 dotpc    dotpc          20 Mar 21 15:00 client -> client-2.9.5
drwxrwxr-x   11 dotpc    dotpc        4096 Sep  2  2005 client-2.8.9
drwxrwxr-x    7 dotpc    dotpc        4096 Dec 14 12:13 data
drwxr-xr-x   12 dotpc    dotpc        4096 Oct 21 09:41 docs
drwxr-xr-x    5 dotpc    dotpc        4096 Dec  7 14:22 etc
drwxr-xr-x   11 dotpc    dotpc        4096 Mar 21 15:54 client-2.9.5
-rw-r--r--    1 dotpc    dotpc      644836 Mar 22 09:53 client-2.9.5.tar.gz

     A. This is a result of command $ls -l
we have two files, 6 directories and one link to client-2.9.5 directory.
There is number of files in every directory, size and data of last change.

53. Q. If you would like to run two commands in sequence what operators you can use?
     A. ; or && the difference is:
if you separate commands with ; second command will be run automatically.
if you separate commands with && second command will be run only in the case
 the first was run successfully.

54.  Q. How you will uncompress the file?
      A. Use tar command (The GNU version of the tar archiving utility):
tar -zxvf file_name.tar.gz

55. Q.How do you execute a program or script, my_script in your current directoty?
    A. ./my_script

56. Q.How to find current time configuration in the file my_new.cfg
    A. grep time my_new.cfg
Grep  searches the named input files (or standard input if
no files are named, or the file name - is given) for lines
containing a match to the given pattern.

Q. What does grep() stand for?
A. General Regular Expression Parser.

57. Q. What does the top command display?
     A. Top provides an ongoing look at processor activity in real
       time.   It  displays  a  listing of the most CPU-intensive
       tasks on the system, and can provide an interactive inter­
       face for manipulating processes. (q is to quit)

58. Q. How can you find configuration on linux?
    A. by using /sin/ifconfig
If no arguments are given, ifconfig displays the  status  of  the  cur-rently  active interfaces.  If a single interface argument is given, it displays the status of the given interface only; if a single  -a  argu-ment  is  given,  it  displays the status of all interfaces, even those that are down.  Otherwise, it configures an interface.

59.  Q. How to find difference in two configuration files on the same server?
     A. Use diff command that is compare files line by line
diff -u /usr/home/my_project1/etc/ABC.conf /usr/home/my_project2/etc/ABC.conf

60.  Q. What is the best way to see the end of a logfile.log file?
     A. Use tail command - output the last part of files
tail -n file_name ( the last N lines, instead of the last 10 as default)

61.  Q. Please write a loop for removing all files in the current directory that contains a word 'log'
     A. for i in *log*; do rm $i; done

62.  Question: How to switch to a previously used directory?
     Answer:   cd -

1.   Q.How many VI editor modes do you know?
     A.Three modes -
Command mode: letters or sequence of letters interactively command vi.
Insert mode: Text is inserted.
Command line mode: enter this mode by typing ":"  and entry command line  at the foot of the screen.

2.   Q. How can you terminate VI session?
     A.
    Use command: ZZ that is save changes and quit.
    Use command line: ":wq" that is write changes and quit.
    Use command line: ":q!" to ignore changes and quit.

3.   Q. How can you copy lines into the buffer in command mode?
     A.
yy - copy a single line defined by the current cursor position
3yy - copy 3 lines. Current line and two lines below it.

What is Linux and why is it so popular?
Answer
Linux is an operating system that uses UNIX like Operating system. However, unlike UNIX, Linux is an open source and free software. Linux was originally created by Linus Torvalds and commonly used in servers.
Popularity of Linux is because of the following reasons
It is a free and open source. We can download Linux for free and customize it as per our needs.
It is very robust and adaptable.
Immense amount of libraries and utilities

What is LILO?
LILO stands for Linux Loader which is a bootstrap program. LILO is a code snippet which loads PC BIOS into the main memory at the time of starting the computer system. LILO handles the following tasks:
-Locating Linux kernel
-Identifying other supporting programs and loading them in the memory
-Staring Kernel

The selection of various kernel images and boot routines is supported by LILO. For this reason, LILO is known as boot manager.

What is the difference between home directory and working directory?
Home Directory: Every user will have one home directory and will have complete control over it. On login, home is the default working directory for the user.
It contains the configuration files and responsible for login and logout of the user.
Working directory: The directory in which the user is working currently is known as working directory. The home may also be the working directory, if the user is working on it.

What is the difference between internal and external commands?
The commands that are directly executed by the shell are known as internal commands. No separate process is there to run these commands.
The commands that are executed by the kernel are known as external commands. Each command has its unique process id.

Explain the difference between a static library and a dynamic library.
Static library has functionality that bound to a static program at compile time. Every static program has its own copy of library.
Dynamic libraries are loaded into the memory and binds at runtime. The external functionality is accessed at runtime. This process reduces the overall footprint of memory.

What is LD_LIBRARY_PATH?
LD_LIBRARY_PATH is an environment variable. This is used to search for the shared objects / dynamic libraries by the operating system for extendable functionality at runtime.

What is the file server in Linux server?
Answer
File server is used for file sharing. It enables the processes required for sharing. All the files can be stored at a centralized location. Linux uses Samba to view the files on the server. Files on this server are backed up on a regular basis. Rights can be also assigned for the files on a file server.

What is NFS? What is its purpose?
Answer
NFS is Network File system. It is a file system used for sharing of files over a network. Other resources like printers and storage devices can also be shared. This means that using NFS files can be accessed remotely. Nfs command in linux can be used to achieve this.
Purpose of NFS:
NFS can be used for sharing of files remotely.
Data can be stored on a single machine and still remain accessible to others over the network.
Reduction of the number of removable media drives throughout the network since they can be shared.

How do I send email with Linux?
Linux supports to work with sending emails using a set of commands called as mail commands. The command to send email is ‘mail’. The ‘mail’ command is used to send and receive emails.
Syntax:
mail [options] [users]
Options are: -s,-c,-b
Where –s for subject, -c for copy and –b for blind carbon copy

Ex: mail username –s “Reports are needed”
It prompts displays the subject as “Reports are needed”.
Similarly if –c and –b is given the mail will be sent to the corresponding recipients.

Explain RPM (Red Hat Package Manager) features.
RPM is a powerful software management tool for installing, uninstalling, verifying, querying and updating software packages. RPM is a straight forward program to perform the above software management tasks. It is available with Fedora, Suse, CentOS, Mandriva Linux and other version of Linux.

What is Kernel? Explain the task it performs.
Kernel is the component that is responsible for managing the resources of a computer system.
The tasks are:
- Provides the abstraction level for resources such as memory, processors, and I/O devices.
-Performs inter process communication
-Responds to system calls
-Provides methods for synchronization and communication between processes.

What is Linux Shell? What is Shell Script?
Linux shell is the user interface to communicate with Linux operating system. Shell interprets the user requests, executes them. Shell may use kernel to execute certain programs. Shell Script: A shell script is a program file in which certain Linux commands are placed to execute one after another. A shell script is a flat text file. Shell scripts are useful to accept inputs and provide output to the user. Everyday automation process can be simplified by a shell script.

What are Pipes? Explain use of pipes.
Pipe is a symbol used to provide output of one command as input to another command. The output of the command to the left of the pipe is sent as input to the command to the right of the pipe. The symbol is |.
For example:
$ cat apple.txt | wc
In the above example the output of apple.txt file will be sent as input for wc command which counts the no. of words in a file. The file for which the no. of words counts is the file apple.txt.
Pipes are useful to chain up several programs, so that multiple commands can execute at once without using a shell script.

Explain trap command; shift Command, getopts command of linux.
trap command is used to catch a signal that is sent to a process. An action is taken based on the signal by using the action which is defined in the trap command instead of taking the default effect on the process.
Example:
$ trap “echo ‘interrupt signal received’ “ INT.
shift command is used to replace the parameters that were sent from command line. For example
$ shift will replace $1 by $2
getopts command is used for the purpose of parsing positional parameters.

What does nslookup do? Explain its two modes.
Nslookup is a program used to find information about internet Domain Name server.
The two modes of nslookup are: Interactive and non-interactive.
Using ‘interactive mode’ user can query the name servers for the information pertaining to hosts and domains.
Using ‘non-interactive mode’ the user can just print the name and requested information of a host.

What is Bash Shell?
Answer
Bash is a free shell for UNIX. It is the default shell for most UNIX systems. It has a combination of the C and Korn shell features. Bash shell is not portable. any Bash-specific feature will not function on a system using the Bourne shell or one of its replacements, unless bash is installed as a secondary shell and the script begins with #!/bin/bash. It supports regular and expressions. When bash script starts, it executes commands of different scripts.

Explain some Network-Monitoring Tools in Linux: ping, traceroute, tcpdump, ntop
Answer
Network monitoring tools are used to monitor the network, systems present on the network, traffic etc.
Ping: Ping command is used to check if the system is in the network or not. To check if the host is operating.
e.g. ping ip_address
When the command is executed, it returns a detailed summary of the host. Packets sent, received, lost by estimating the round trip time.
Traceroute: the command is used to trace the path taken by the packet across a network. Tracing the path here means finding out the hosts visited by the packet to reach its destination. This information is useful in debugging. Roundtrip time in ms is shown for every visit to a host.
Tcpdump: commonly used to monitor network traffic. Tcdump captures and displays packet headers and matching them against criteria or all. It interprets Boolean operators and accepts host names, ip address, network names as arguments.
Ntop: Network top shows the network usage. It displays summary of network usage by machines on the network in a format as of UNIX top utility. It can also be run in web mode, which allows the display to be browsed with a web browser. It can display network traffic statistics, identify host etc. Interfaces are
available to view such information.

How does the linux file system work?
Answer
Linux file structure is a tree like structure. It starts from the root directory, represented by '/', and then expands into sub-directories. All the partitions are under the root directory. If a partition is mounted (The mount point defines the place of a particular data set in the file system) anywhere apart from a “device”, the system is not aware of the existence of that partition or device. Directories that are only one level below the root directory are often preceded by a slash, to indicate their position.

Explain file system of linux. The root "/" filesystem, /usr filesystem, /var filesystem, /home filesystem, /proc filesystem.
Answer
Root "/" file system: The kernel needs a root file system to mount at start up. The root file system is generally small and should not be changed often as it may interrupt in booting. The root directory usually does not have the critical files. Instead sub directories are created. E.g. /bin (commands needed during bootup), /etc (config files) , /lib(shared libraries).

/usr filesystem : this file system is generally large as it contains the executable files to be shared amongst different machines. Files are usually the ones installed while installing Linux. This makes it possible to update the system from a new version of the distribution, or even a completely new distribution, without having to install all programs again. Sub directories include /bin, /include, /lib, /local (for local executables)

/var filesystem : this file system is specific to local systems. It is called as var because the data keeps changing. The sub directories include /cache/man (A cache for man pages), /games (any variable data belong to games), /lib (files that change), /log (log from different programs), /tmp (for temporary files)

/home filesystem: - this file system differs from host to host. User specific configuration files for applications are stored in the user's home directory in a file. UNIX creates directories for all users directory. E.g /home/my_name. Once the user is logged in ; he is placed in his home directory.

/proc filesystem : this file system does not exist on the hard disk. It is created by the kernel in its memory to provide information about the system. This information is usually about the processes. Contains a hierarchy of special files which represent the current state of the kernel .Few of the Directories include /1 (directory with information about process num 1, where 1 is the identification number), /cpuinfo (information about cpu), /devices (information about devices installed), /filesystem (file systems configured), /net (information about network protocols), /mem (memory usage)

What are the process states in Linux?
The following are the process states:
1. Running: This is a state where a process is either in running or ready to run.
2. Interruptible: This state is a blocked state of a process which awaits for an event or a signal from another process
3. Uninterruptible: It is also a blocked state. The process is forced to halt for certain condition that a hardware status is waited and a signal could not be handled.
4. Stopped: Once the process is completed, this state occurs. This process can be restarted
5. Zombie: In this state, the process will be terminated and the information will still be available in the process table.

What is a zombie?
Dead process is called a zombie. The processes will die eventually at the time when they become zombies. A dead process cannot be killed. The parent process will send a signal to the operating system that is not needed the zombie by using wait () system call.

Explain each system calls used for process management in linux.
Answer
System calls used for Process management:
Fork () :- Used to create a new process
Exec() :- Execute a new program
Wait():- wait until the process finishes execution
Exit():- Exit from the process
Getpid():- get the unique process id of the process
Getppid():- get the parent process unique id
Nice():- to bias the existing property of process

Which command is used to check the number of files and disk space used and the each user’s defined quota?
repquota command is used to check the status of the user’s quota along with the disk space and number of files used. This command gives a summary of the user’s quota that how much space and files are left for the user. Every user has a defined quota in Linux. This is done mainly for the security, as some users have only limited access to files. This provides a security to the files from unwanted access. The quota can be given to a single user or to a group of users.

What is the name and path of the main system log?
By default the main system log is /var/log/messages. This file contains all the messages and the script written by the user. By default all scripts are saved in this file. This is the standard system log file, which contains messages from all system software, non-kernel boot issues, and messages that go to 'dmesg'. dmesg is a system file that is written upon system boot.

How secured is Linux? Explain.
Security is the most important aspect of an operating system. Due to its unique authentication module, Linux is considered as more secured than other operating systems. Linux consists of PAM. PAM is Pluggable Authentication Modules. It provides a layer between applications and actual authentication mechanism. It is a library of loadable modules which are called by the application for authentication. It also allows the administrator to control when a user can log in. All PAM applications are configured in the directory "/etc/pam.d" or in a file "/etc/pam.conf". PAM is controlled using the configuration file or the configuration directory.

Can Linux computer be made a router so that several machines may share a single Internet connection? How?
Yes a Linux machine can be made a router. This is called "IP Masquerade." IP Masquerade is a networking function in Linux similar to the one-to-many (1: Many) NAT (Network Address Translation) servers found in many commercial firewalls and network routers. The IP Masquerade feature allows other "internal" computers connected to this Linux box (via PPP, Ethernet, etc.) to also reach the Internet as well. Linux IP Masquerading allows this functionality even if the internal computers do not have IP addresses.
The IP masquerading can be done by the following steps:
1. The Linux PC must have an internet connection and a connection to LAN. Typically, the Linux PC has two network interfaces-an Ethernet card for the LAN and a dial-up PPP connection to the Internet (through an ISP).
2. All other systems on your LAN use the Linux PC as the default gateway for TCP/IP networking. Use the same ISP-provided DNS addresses on all systems.
3. Enable IP forwarding in the kernel. By default the IP forwarding is not enabled. To ensure that IP forwarding is enabled when you reboot your system, place this command in the /etc/rc.d/rc.local file.
4. Run /sbin/iptables-the IP packet filter administration program-to set up the rules that enable the Linux PC to masquerade for your LAN.

What is the minimum number of partitions you need to install Linux?
Minimum 2 partitions are needed for installing Linux. The one is / or root which contains all the files and the other is swap. Linux file system is function specific which means that files and folders are organized according to their functionality. For example, all executables are in one folder, all devices in another, all libraries in another and so on. / or ‘root’ is the base of this file system. All the other folders are under this one. / can be consider as C: .Swap is a partition that will be used as virtual memory. If there is no more available RAM a Linux computer will use an area of the hard disk, called swap, to temporarily store data. In other words it is a way of expanding your computers RAM.

Which command is used to review boot messages?
dmesg command is used to review boot messages. This command will display system messages contained in the kernel ring buffer. We can use this command immediately after booting to see boot messages. A ring buffer is a buffer of fixed size for which any new data added to it overwrites the oldest data in it.
Its basic syntax is
dmesg [options]
Invoking dmesg without any of its options causes it to write all the kernel messages to standard output. This usually produces far too many lines to fit into the display screen all at once, and thus only the final messages are visible. However, the output can be redirected to the less command through the use of a pipe, thereby allowing the startup messages to be viewed on one screen at a time
dmesg | less

Which utility is used to make automate rotation of a log?
logrotate command is used to make automate rotation of log.
Syntax of the command is:
logrotate [-dv] [-f|] [-s|] config_file+
It allows automatic rotation, compression, removal, and mailing of log files. This command is mainly used for rotating and compressing log files. This job is done every day when a log file becomes too large. This command can also be run by giving on command line. We can done force rotation by giving –f option with this command in command line. This command is also used for mailing. We can give –m option for mailing with this command. This option takes two arguments one is subject and other is recipient name.

What are the partitions created on the mail server hard drive?
The main partitions are done firstly which are root, swap and boot partition. But for the mail server three different partitions are also done which are as follows:
1. /var/spool- This is done so that if something goes wrong with the mail server or spool than the output cannot overrun the file system.
2. /tmp- putting this on its own partition prevents any user item or software from overrunning the system files.
3. /home- putting this on its own is useful for system upgrades or reinstalls. It allow not to wipe off the /home hierarchy along with other areas.

What are the fields in the/etc/passwd file?
It contains all the information of the users who log into the system. It contains a list of the system's accounts, giving for each account some useful information like user ID, group ID, home directory, shell, etc. It should have general read permission as many utilities, like ls use it to map user IDs to user names, but write access only for the superuser (root). The main fields of /etc/passwd file are:
1. Username: It is used when user logs in. It should be between 1 and 32 characters in length.
2. Password: An x character indicates that encrypted password is stored in /etc/shadow file.
3. User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for other predefined accounts.
Further UID 100-999 are reserved by system for administrative and system accounts/groups.
4. Group ID (GID): The primary group ID (stored in /etc/group file)
5. User ID Info: The comment field. It allow you to add extra information about the users such as user's full name, phone number etc. This field use by finger command.
6. Home directory: The absolute path to the directory the user will be in when they log in. If this directory does not exists then users directory becomes /
7. Command/shell: The absolute path of a command or shell (/bin/bash). Typically, this is a shell.

Which commands are used to set a processor-intensive job to use less CPU time?
nice command is used for changing priority of the jobs.
Syntax: nice [OPTION] [COMMAND [ARG]...]
Range of priority goes from -20 (highest priority) to 19 (lowest).Priority is given to a job so that the most important job is executed first by the kernel and then the other least important jobs. This takes less CPU times as the jobs are scheduled and are given priorities so the CPU executes fast. The priority is given by numbers like -20 describe the highest priority and 19 describe the least priority.

How to change window manager by editing your home directory?
/.xinitrc file allows changing the window manager we want to use when logging into X from that account. The dot in the file name shows you that the file is a hidden file and doesn't show when you do a normal directory listing. For setting a window manager we have to save a command in this file. The syntax of command is: exec windowmanager.After this, save the file. Next time when you run a startx a new window manager will open and become default. The commands for starting some popular window managers and desktop environments are:
-KDE = startkde
-Gnome = gnome-session
-Blackbox = blackbox
-FVWM = fvwm
-Window Maker = wmaker
-IceWM = icewm

How documentation of an application is stored?
When a new application is installed its documentation is also installed. This documentation is stored under the directory named for application. For example if my application name is App1 then the path of the documentation will be /user/doc/App1. It contains all the information about the application. It contains
date of creating application, name of application and other important module of the application. We can get the basic information of application from the documentation.

How shadow passwords are given?
pwconv command is used for giving shadow passwords. Shadow passwords are given for better system security. The pwconv command creates the file /etc/shadow and changes all passwords to ‘x’ in the /etc/passwd file. First, entries in the shadowed file which don't exist in the main file are removed. Then, shadowed entries which don't have `x' as the password in the main file are updated. Any missing shadowed entries are added. Finally, passwords in the main file are replaced with `x'. These programs can be used for initial conversion as well to update the shadowed file if the main file is edited by hand.

How do you create a new user account?
useradd command is used for creating a new user account. When invoked without the
-D option, the useradd command creates a new user account using the values specified on the command line and the default values from the system. The new user account will be entered into the system files as needed, and initial files copied, depending on the command line options. This command uses the system default as home directory. If –m option is given then the home directory is made.

Which password package is installed for the security of central password?
Shadow password packages are used for security of central passwords. Security is the most important aspect of every operating system. When this package is not installed the user information including passwords is stored in the /etc/passwd file. The password is stored in an encoded format. These encoded forms can be easily identified by the System crackers by randomly encoding the passwords from dictionaries. The Shadow Package solves the problem by relocating the passwords to another file (usually /etc/shadow). The /etc/shadow file is set so that it cannot be read by just anyone. Only root will be able to read and write to the /etc/shadow file.

Which shell do you assign to a POP3 mail-only account?
POP3 mail only account is assigned to the /bin/false shell. However, assigning bash shell to a POP3 mail only gives user login access, which is avoided. /bin/nologin can also be used. This shell is provided to the user when we don’t want to give shell access to the user. The user cannot access the shell and it reject shell login on the server like on telnet. It is mainly for the security of the shells. POP3 is basically used for downloading mail to mail program. So for illegal downloading of emails on the shell this account is assigned to the /bin/false shell or /bin/nologin. These both shells are same they both do the same work of rejecting the user login to the shell. The main difference between these two shells is that false shell shows the incorrect code and any
unusual coding when user login with it. But the nologin shell simply tells that no such account is available. So nologin shell is used mostly in Linux.

Which daemon is responsible for tracking events on Linux system?
syslogd is responsible for tracking system information and save it to the desired log files. It provides two system utilities which provide system logging and kernel message trapping. Internet and UNIX domain sockets support enable this utility package to support both local and remote logging. Every logged
message contains at least a time and a hostname field, normally a program name field, too. So to track these information this daemon is used. syslogd mainly reacts to the set of signals given by the user. These are the signals given to syslogd: SIGHUP: This lets syslogd perform a re-initialization. All open files are closed, the configuration file (default is /etc/syslog.conf) will be reread and the syslog facility is started again. SIGTERM: The syslogd will die. SIGINT, SIGQUIT: If debugging is enabled these are ignored, otherwise syslogd will die. SIGUSR1: Switch debugging on/off. This option can only be used if syslogd is started with the - d debug option. SIGCHLD: Wait for Childs if some were born, because of waiting messages.

Which daemon is used for scheduling of the commands?
The crontab command is used for scheduling of the commands to run at a later time. SYNTAX
crontab [ -u user ] file
crontab [ -u user ] { -l | -r | -e }
Options
-l List - display the current crontab entries.
-r Remove the current crontab.
-e Edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables.
When user exits from the editor, the modified crontab will be installed automatically. Each user can have their own crontab, and though these are files in
/var, they are not intended to be edited directly. If the –u option is given than the crontab gives the name of the user whose crontab is to be tweaked. If it is given without this then it will display the crontab of the user who is executing the command.

How environment variable is set so that the file permission can be automatically set to the newly created files?
umask command is used to set file permission on newly created files automatically.
Syntax
umask [-p] [-S] [mode]
It is represented in octal numbers. We can simply use this command without arguments to see the current file permissions. To change the permissions, mode is given in the arguments. The default umask used for normal user is 0002. The default umask for the root user is 0022. For calculating the original values, the values shown by the umask must be subtracted by the default values. It is mainly used for masking of the file and directory permission. The /etc/profile script is where the umask command is usually set for all users. The –S option can be used to see the current default permissions displayed in the alpha symbolic format.
For example, umask 022 ensures that new files will have at most 755 permissions (777 NAND 022).
The permissions can be calculated by taking the NAND of original value with the default values of files and directories.

What are the two different kinds of Linux User Modes?
The following are the two types of Linux user modes:

Command Line
GUI

How to check memory stats and CPU stats as a Linux Admin?
Using the free and vmstat commands, we can display the physical and virtual memory statistics, respectively.

Do you know the Maximum length (in bytes) of the filename in Linux?
The maximum length of a filename is 255 bytes. In this filename, the pathname is not included, so the total length of the pathname and filename may easily surpass 255 characters.

What is Hard Link?
In Linux, Hard links can be defined as another name for an already existing file. For each file, we can generate an unlimited number of hard links. They have the ability to generate links for other hard connections. We can use the `Is-I` command to find out the total number of hard links in a file. And we can create Hard links using the following command:

$ ln [original filename] [link name]

What is Soft Link?
Soft link is also known as a symbolic link. Soft links are files that, in most cases, lead to another file. It just links to another entry somewhere in the file system and does not include any data in the destination file. These kinds of connections can be utilized across several file systems. The following command can be used to create soft links:

$ ln -s [original filename] [link name]

Suppose, your FTP Server is hacked and the entire server needs to be restored. How would you restore the original kernel system files?
We cannot restore the entire operating system from the tape backup device. Therefore, we should reinstall the core operating system and then restore the system configuration files and user data from the tape backup device.

Differentiate between Linux and Unix
The differences between Linux and Unix are mentioned in the following table:
Linux
Offers both paid and free OS
It is portable It is non-portable
The installation process of Linux does not involve any hardware components
It is developed by a worldwide Linux community. .
It is highly flexible and compatible
It is used in both software and hardware, frameworks, etc.

Unix
Cost varies with the levels
Hardware components are needed to install Unix
It is developed by AT&T developers
It is less flexible and compatible compared to Linux. 
It is used in servers, workstations, etc.

Can we convert a Linux computer into a router in order to enable multiple machines to work on the same Internet connection? If yes, how?
Yes! We can convert a Linux PC into a router so that it can act as an IP gateway for a network. This process of turning a Linux machine into a router is referred to as IP Masquerade, which is basically a Linux networking function that is quite similar to the one-to-many network address translation servers.

Linux IP Masquerading enables the other ‘internal’ computers that are linked to this Linux system to get connected to the Internet. This Linux feature is available even when these machines do not have their own IP addresses.

In Linux, we can perform IP Masquerading by following the below steps:

Step 1: First of all, we have to make sure that our Linux PC is having an Internet connection, along with a LAN connection. In fact, a Linux PC will be having a PPP connection and an Ethernet card.
Step 2: As the default gateway for TCP/IP networking, all the other systems on our LAN use the Linux machine. Hence, we have to use the same DNS addresses provided by the Internet service provider on all our systems.
Step 3: Now, for enabling IP forwarding, we will use the following command:

echo 1 > /proc/sys/net/ipv4/ip_forward
For checking whether we have IP forwarding enabled already, we can use the following:

sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
Or, we will just check out the value i /proc/sys/net/ipv4/ip_forward:

~]# cat /proc/sys/net/ipv4/ip_forward
0
Step 4: Finally, we will run /sbin/iptables for setting up those rules that enable IP Masquerading.

What daemon is used for scheduling commands?
The crontab command is used for scheduling commands to run at a later time.
Syntax:
crontab [ -u user ] file
crontab [ -u user ] { -l | -r | -e }
Options:
-l: Displays the current crontab entries
-r: Removes the current crontab
-e: Edits the current crontab using the editor specified by the VISUAL or EDITOR environment variables



No comments:

Post a Comment