Linux or Unix important questions and answers for interview

Continuing from the last post.....
Below is the link to download the document
Q30) some one is asking my machine is slow what is your steps? ORACLE
A1) The increase in the size of SWAP partition may show you the
little effect in increasing the system speed and better run
in Single user mode rather than GUI mode
A2) use top command, then check which process use the most
resource and find the problem.
A3) Re-read all process
#killall –HUP
Q31) what is mean by system calls INFOTECH
A1) A system call is the mechanism used by an application
program to request service from the operating system.
On Unix-based and POSIX-based systems, popular system
calls are open, read, write, close, wait, exec, fork, exit,
and kill. Many of today's operating systems have hundreds of
system calls. For example, Linux has 319 different system
calls. FreeBSD has about the same (almost 330).
Tools such as strace and truss report the system calls made
by a running process
.
Q32) What is trusted/untrusted operating system
A1) As per my perspective , I used to say any/all UNIX flavors
rather than MS WINDOWS
Because of
1. File/Directory permission (Action:Read/Write/Execute,
permissions can be given on behalf of the particular
User/group/Others).
2. All the unix configuration as files rather than
Registry (windows)
a. which cause the application to fail when a newer
or incompatible dynamic library is installed.
b. Some times you may need to restart the entire
system to update the changes with registry.
3. Linux Strong password protection. It won't get booted
(Drop you @ the GUI) without the successful
authentication (even though you don't have any more
users rather than admin/root).In Linux setting
password to the admin/root users is must during the
installation itself.
Where as in windows, let allow you to leave the
password as blank for admin/other user, System also
booting without authenticating.
4. Linux is open source, free under GNU. It doesn't mean
that its only free to install or use, but in fact you
can have these source codes and they are allowing you
to change it and redistribute it.

Windows is Lincesed os. Windows is developed by
Microsoft.
5. Linux is more secure, windows is less secure than
linux in case of virus, worms.
Because in Linux all the files/directory won't get
executable permission, Perhaps you need to set it
manually. Though by default all the incoming trojen,
virus, malwares and worms won't affect the system.
6. Distribution
Linux : Linux has many distributors like Radhat,
mandrake, Corel etc
Windows : whereas windows has only Micrsoft.
7. Run Level
Linux works on both GUI & Console mode (Checkout the
various run levels runlevel 0 - runlevel 6 Generally
known as init level)).
Windows : Only GUI.
8. By default LINUX have multiuser, multitasking,
multiprocessing, multiprogramming features. Perhaps
this will not be available on windows(Except some
versions), In that case you need to PAY & BUY
the extra features in windows.
9. You can play around the Linux through LIVE CDS on a
Windows machine.
Only is a live CD that runs over windows, in RAM,
and doesn't change your system at all..the other is
an install disk. I've used the live CD on two XP
machines and they both ran flawlessly. When you
want to quit, just go to logout under system tools,
and shut down.
Linux will turn itself off, eject the disk, and turn
of your PC.
Remove the disk, boot up, and you're running your
Windows again.
This is the way we are checking the newly bought
NIC/others hardwares support with all the Linux
distributors. Once it got detected, its very easy to
get the device driver names and other details about
that new hardwares, then compile the new kernel
image (bzImage) on your own build version systems.
Q33) Working in Linux/Unix platform, if any command dose not
work, say # ls reports as command not found.
what to do? GOOGLE
A1) Need to check the path first body ....
A2) reinstall that shell
A3) Check whether PATH variable as got the entry /bin
It should be something like this
=========================
[root@bc ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/bin:/sbin:/usr/bin
=========================


Q34) in unix how to change old name to new name
A1) mv // for rename the file in the same
directory
mv // for rename and
move the file in other diretory.
A2) 1. open the file /etc/sysconfig/network and change the
parameter HOSTNAME= to new name.
2. restart the network services.
3. open the file vi /etc/hosts, and change the old name to
new name.
127.0.0.1 localhost.localdomain
localhost
A3) mv
eg:-
[root@localhost]# touch file1 //created a file named file1
root@localhost]# ls //displays the file created
file1
[root@localhost]# mv file1 file2 //command to rename file1
[root@localhost]# ls //displays the renamed file
file2
A4) see there is no rename command in unix ,
so what u can use is "move" (mv) command
mv "(absolute path) old file name" "new file name
A5) rename
Q35) what is the standard output in a file as well as disply it
on the terminal options like
A)pr B) tail C) tee D)nl
A1) tail as it display ten current line
tail -f
option with this
tail -f -n 100
A2) I think, framing the question should be like
"What is the command used to write to the standard output
as well as to a file simultaneously ?
Answer) tee
It is a command that deals with pipes in unix. It
redirects the output of a command to an other command and
at the same time it redirects to a file also.
Q36) what is command like " #(cd unixos; pwd) " tell me OUTPUT
A1) first it will change the directory to unixos and then gives
the output as //unixos
A2) it is two commands runnung one by one.first the cd unixos
command will be executed,then the present working directory
will work.so the output will be showing the presentworking
dirctory that is unixos dir.
A3) WRONG when I hit this command no output or error is printed



v Few more Questions & Answers             JJJ

1) How to create swap if you don't have free partition?
this is some what tricky question if you are new to Linux Administration
here is the command to create swap if you dont have free partation
before doing this you have switchoff the swap

swapoff -a
dd if=/dev/zero of=/root/swapfile bs=1k count=1024
swapon filename
2)How to see swap details?
   cat /proc/swap
   free

3)How to see/get info about RAM in ur system
   free
   cat /proc/meminfo

4)What is the difference between ext2 and ext3
  I)ext3=ext2+journaling
 "journaling" is an add-on to a filesystem that records changes as they are made.
II)ext2 files system is fast
III)less disk writes
IV)ext2 file system in less stable/secure
V)ext2 file system required to run fsck command if the system get crashed
5)How to convert ext2 file system to ext3?
   tune2fs -j /dev/hda1
6)How convert ext3 file system to ext2
   tune2fs -O^has-journal /dev/hda1
7)What is default block/chunk size for PV
   4MB

8)what is the command to update the diskquota on file system
   mount -o remount,rw /home
9)What is the partition type number for swap,RAID,LVM?
   82(swap),fd(RAID),8e(LVM)
10.)aCan we install HPUX( (Hewlett Packard UniX) on Vmware?
A)No. Because HPUX can be installed only on PA-RISC or Itanium and Vmware can not emulate this
hardware

b.What is the difference between IPchains and IPtables?
IPchains : Ipchains is a utility for Linux that System Administrators can use to create and modify the
ruleset that is used for their host based firewall. These rules are used by a system to decide whether or
not it is going to allow a specific remote connection.
IP tables : Iptables is a generic table structure that defines rules and commands as part of the netfilter
framework that facilitates
11.)What is INODE limit? If the file system reaches that limits how to resolve that?
A)Inode is a unique number given to a file in Unix OS. Every file in Unix has a inode number. unix treats
directories/folders as a file so they are also having a inode value.
.

Few more Questions & Answers

1.What is sed? - sed is stream editor, a Unix tool for working with streams of text data. See the
awful truth about sed.
2.How do you substitute strings with sed? -
Use ’s/old/new’ command, so sed
’s/hello/goodbye/’ would substitute the occurrence of the word hello to goodbye.

3.How do you inject text with sed? -
& in the substitution string defines the pattern found in
the search string. As an example, here’s us trying to find a word ‘hello’ and replacing it with
‘hello and how are you’:
     echo ‘hello there’ | sed ’s/^hello/& and how are you/’
4.Can I find several patterns and refer to them in the replacement string? - Yes, use
(pattern) and then refer to your patterns as \1, \2, \3 and so on.

5.If the string is ‘old old old’ and I run ’s/old/new’,
I get ‘new old old’ as the result. I
need ‘new new new‘. - You forgot the global modifier, which would replace every occurrence
of the pattern with the substitution. ’s/old/new/g‘ will work.

6.But I want ‘old old new’ from the previous example. -
Just use the numeric modifier
saying you want the third occurrence to be replaced. ’s/old/new/3‘ will work.

7.I wrote a rather complex sed script. How do I save and run it?
- Assuming that your
file is named myscript1.sed, you can invoke
sed -f myscript1.sed.
8.How do I delete trailing whitespaces from each line? - sed ’s/[ \t]*$//’ Here we’re
replacing any occurrence of a space or a tab with nothing. Check sed one-liners for more
examples.
9.How do you print just a few first lines of the file?
- sed 1q will give you just the first line,
sed 10q the first 10 lines.
10.How do you replace a pattern only if it’s found, so that it’s executed faster? - Nest 
the replacement statement: sed ‘/old/ s/old/new/g’ file.txt
What is LILO?
LILO stands for Linux boot loader. It will load the MBR, master boot record, into the
memory, and tell the system which partition and hard drive to boot from.
What is the main advantage of creating links to a file instead of copies of the file?
A: The main advantage is not really that it saves disk space (though it does that too) but, rather, that a change of permissions on the file is applied to all the link access points. The link will show permissions of lrwxrwxrwx but that is for the link itself and not the access to the file to which the link points. Thus if you want to change the permissions for a command, such as su, you only have to do it on the original. With copies you have to find all of the copies and change permission on each of the copies.
what is the command for finding the higest memory occupied file in
linux?
Top command will show the memory occupied by a file. When top
is showing the output press
shift+m to show the file or
process which is using larger memory.
difference between nfs soft and hard mouniting points?
hard mount option:- If the client fails to access the
server,then connection hang it, after the system up then it
access the server.
Soft:- If the client failed to connect the server it
immediately gives the error report, and close the connection.
Hard mounting : Providing entry in /etc/fstab is called hard
mounting. Using hard mounting when client system boots at
booting time client will try to mount the entry in
/etc/fstab if the server is down client pc willnot boot
until the server is up. mounting at boot time is called hard
mounting.
Soft mounting : Providing entry in /etc/auto.master and
/etc/auto.misc is called soft mounting. When client sys boot
it will try to mount if unable to mount just gives the error
message and it will continue the boot process. Mounting at
boot time or by user request is called soft mounting

in redhat Linux what is the command to check at which date and
time file was created?
stat filename
ls -ltr" gives you detail information of files and
directories.
I know ssh, telnet, dns,apache all are worked on TCP/UDP but i
want to know any one service which are working on UDP only?
netstat
cat /etc/services |grep udp
I want to built a fire wall using iptables. My condition is " inbound
to 192.168.0.2 with a port of 80 from 172.168.0.1 should accept"
iptables -I INPUT -s 172.168.0.1 -p tcp --dport 80 -d 192.168.0.2 -j
ACCEPT

how many limitations of under directories in ext2/3 linux file
system?
Ext2 Limits
============
Max file size: 2-64 TiB
Max number of files: 10 raised 18
Max filename length: 255 characters
Max volume size: 16-32 TiB
Allowed characters in filenames: Any byte except NULL and '/'
Ext3 Limits
===========
Max file size: 2 TiB
Max number of files: Variable, allocated at creation time[1]
Max filename length: 255 bytes
Max volume size: 2 TiB – 16 TiB
Allowed characters in filenames: All bytes except NULL
what are the linux boot files?
1.Grub.conf
2.Vmlinuz
3.initrd.img
I have to make permanent nfs mount
permanent what shall i do?
To make nfs permanent mount go to /etc/fstab & put the entry
& run a cmd to make it mount permanent #mount -a.
to make permanent nfs mount, write it into /etc/fstab
server    nfsmount   mountpoint  filesystem defaults 0 0
192.168.0.1  /var/ftp/pub   /mnt      nfs       defaults 0 0
how do find all failed login attempts via ssh?
tail -f /var/log/secure | grep Failed
 
lastb" is the command to find all failed login attempts
 how do u find remote machine operating system and version?
#nmap -A -v station1
what is the diff b/w ext2 and ext3?
ext3 is the advanced version of ext2

ext2+journaling=ext3
this journaling feature is very much useful while
retrieving data and writing data into a File System
Latest versions of all Linux flavors are coming with ext3
compatible file systems.
ext 2 & ext3 are the two file systems in linux.ext 2 will
take more time while logon the system. this is bcoz ext2
will check all harddisk peripherals at the time of switch on
your sytem. But ext3 is less time consuming,bcoz instead of
checking all harddisk peripherals it will check only the
bootloader peripherals.
Availability
Integrity
Speed
easy transition
In ext2 filesystem, the filesystem is not mounted until its
consistency is checked by e2fsck program. the amount of time
taken to run e2fsck program is determined by the size of
file system. The more files you have on the file system, the
longer the consistency check takes.
     ext3 does not require a file system check even after a
unclean shutdown. the time to recover an ext3 file system
after an unclean shutdown does not depend on size, rather it
depends on size of "journal"  used to maintain consistency.
the default journal takes about a second to recover.
 What is an inode?
An inode is a data structure holding information about files
in a Linux file system. There is an inode for each file, and
a file is uniquely identified by the file system on which it
resides and its inode number on that system.
what is the command to make a process to run in the background from
foreground?
when the process is running, press "control+Z" . Now at the
command prompt , type "bg"
what is a superblock ?
A superblock is a record of the characteristics of a
filesystem, including its size, the block size, the empty
and the filled blocks and their respective counts, the size
and location of the inode tables, the disk block map and
usage information, and the size of the block groups.

how do you configure linux system as a router?
vi /etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
save &
sysctl -p
 1st answer is correct till you boot your Linux machine, once
rebooted, its gone coz the /proc is a fs that is resident on
memory, thus if you want to forward your packets permanently
then you have to alter the net.ipv4.ip_forward parameter to
reflect the changes each time machine is booted. # sysctl -p
makes it effective without reboot.
 follow following command

1.) vi /etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
save (:wq!)
You should have a Two physical LAN card, if You have't two
Lan cat. You have to creat virtual Lan card
2.) cp -arvf /etc/sysconfig/network-scripts/ifcfg-
eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1
3.) Set a diffrent Class IP in virtual Lan card
4.) start network service
     /etc/init.d/network restart
what is the UID and GID of root user? Can a normal user can change
the ownership of a file? what is the command to change ownership of a
file?
the root UID/GID is 0 (zero). which is why he can able to
intervene in all  normal users files even though he don't
had permission. A normal user will don't have the permission
to change ownership of file. The command to change ownership
is  < chown user.user file >
What u know about tar Command?
 
tar command is file archiving cmd and extracting cmd in linux.
create
 tar -cvf /tmp/ram.tar /etc/passwd
this command makes compress the /etc/passwd datas and stored
in /tmp/ram.tar
Extract
 tar -xvf /tmp/ram.tar
extract the data in existing file is /tmp/ram.tar
How do you read ext2/3 file system in windows?
Using Software Winscp ,we can access Linux machine from
Windows.it is an windows software.
through SAMBA, we can share the linux partition or
directory, for windows.
How to monitor ports in a linux machine, with single command?
netstat -anpc
a:all listening ports and established connections
n:numeric host:port values
p:programs
c:continuous monitor
 What is the status code 403,404 represented in apache server
403 represent forbidden error, means if files misses some
selinux security context is missing.
404 represent that their is a cgi script missing or web
pages missing.
Difference between swap partition and swap file?
Swap partition maintained seperate partition.
same swap partition can be used in two OS within single
machine.
If system crashes their is a chance to recover itor may not
be corrupt the partition.

Less fragmented.
where as swap file takes very less space. we can increase
the space very easily, compared to swap partition.
SWap file system fragmented.
If system crashes their is a huge chance to lost the swap
file system.
what is nis server?
Network Information Services is well known as NIS server
which is based on Linux and Unix environment network. NIS
Server create the user name and password to share across the
network for centralize authentication. The best thing is
that passwords can change be changed on NIS server not on
client desktop systems.
How can I only see the first 14 lines of a file?
head -n14 filename
Compare between SYS V launched processes and Xinetd processes in
Linux.
Answer is based on RHEL
   SYS V processes                xinetd processes
1) daemons (run in background)   processes started on request

2) Managed by "service"          Managed by "xinetd" daemon
wrapper command
3) Script files in "/etc/rc.d"   script files in /etc/xinetd.d
directory                        directory
what is the command to make a process to run in the foreground from
background?
Fg
How to FTP user access other directory except his own home
directory ?
specify the user in /etc/vsftpd/user_list.
then in /etc/vsftpd/vsftpd.conf  ,add userlist_deny=NO,,,,
then restart d service......... set d selinux for the
accessing home directory..........
what are the Linux-based security tools?
1.
Clam AntiVirus
  It is an open source (GPL) anti-virus toolkit for UNIX,
designed especially for e-mail scanning on mail gateways.
2. SpamAssassin
 It is a computer program released under the Apache License
2.0 used for e-mail spam filtering based on content-matching
rules.
3. Chkrootkit is a powerful tool to scan your Linux server
for trojans
4. rkhunter (Rootkit Hunter) is a Unix-based tool that scans
for rootkits, backdoors and possible local exploits
 what is a command to display top 10 users who are using Huge Space?
du -s /home/* | sort -nr |head -10
In which File is Static IP address given so that it becomes Permanent?
just go to system-config-network
and type ip address
or

go
vi /etc/sysconfig/network-scripts/ifcfg-eth0
edit in this file it will become permanent.


what are the features of Linux?
The following feature of linux:-
Some of its features include:
1)Virtual memory, allowing the system to use disk room the
same as RAM memory.
2)Networking with TCP/IP and other protocols.
3)Multiple user capability.
4)Protected mode so programs or user's can't access
5)unauthorized areas.
6)Shared libraries
7)True multitasking
8)X - A graphical user interface similar to windows, but
supports remote sessions over a network.
9)Advanced server functionality:-
  FTP server
  Telnet server
  BOOTP server
  DHCP server
  Samba server
  DNS server
  SNMP services
  Mail services
  Network file sharing
  much, much more...
Support of filesystems that other operating systems use
such as DOS (FAT), Windows95,98 (FAT32), Windows NT, 2000
(NTFS), Apple, minix, and others 

1 Comments

Previous Post Next Post