Operating System Basics: What Is Your Favorite OS and Why?
Operating System Basics: What Is Your Favorite OS and Why?
Operating System Basics: What Is Your Favorite OS and Why?
What is fragmentation?
Fragmentation occurs when a piece of data in memory is broken up into many pieces that are not close
together
OR
Fragmentation occurs when the operating system cannot or will not allocate enough contiguous space to
store a complete file as a unit, but instead puts parts of it in gaps between other files
Scattered Data
What is Semaphore?
Locking Mechanism used inside resource mangers and resourse dispensers.
Cache:
First time accessing the data gets cache in the RAM, once the data is moved from disk into the cache,
future use can be made by accessing the cached copy rather than refetching or recomputing the original
data, so that the average access time is lower
Buffer:
Memory used to temporarily store output or input data, which is not yet written to disk.
2
LINUX BASICS
What are the main flavors of UNIX?
System V (five) from AT&T Berkeley Software Distribution
HP-UNIX FreeBSD
IBM-AIX NetBSD
SCO-UNIX
SOLARIS
What is Fedora?
Fedora is a set of projects, sponsored by Red Hat and guided by the Fedora Foundation. These projects are
developed by a large community of people who strive to provide and maintain the very best in free, open
source software and standards
4
Whats the differences between every release of Fedora Core
Whats the difference between RedHat Enterprise Linux and Fedora Core Projects
RHEL Fedora
1. RHEL is intended for commercial use Fedora Core is intended for personal, hobbyist, and
developer use
2. RHEL 3 is based on still redhat 9 src code Fedora Core 3 is much advance having latest kernel
2.6 And newer developer tools.
3. RHEL 4 is based on FC3. Fedora Core 4 is having latest gcc and tools.
4. RedHat Support No Support
5. Cost Based Free
What is a kernel?
The kernel is the core piece of most operating systems. It is a piece of software responsible for the
communication between hardware and software components.
What is SWAP?
Its an extension of RAM.
And if incase I would need this swap file at boot time permanently
# dd if=/dev/zero of=/data/swapfile.1 bs=1024 count=65536
# mkswap /data/swapfile.1
Add an entry in /etc/fstab file
/data/swapfile.1 none swap pri=5,defaults 0 0
# swapon –a
How much disk space should you allocate for the /proc filesystem?
We don’t have to. It does not consume any storage space, and it consumes only a limited amount of
memory.
Init 6
|
inittab
|
/etc/rc.d/rc
|
/etc/rc.d/rc6.d/
6
What is difference between grep & find?
GREP: get regular expression
From grep you can’t search files. Used to search for a string from a file
FIND:
From find you can search by filenames. Used to search for a string from a file
What are the fields in the passwd file? What do they mean, what do they do?
7 fields
user:x:uid:gid:gecos:home:shell
5th field
GECOS: GECOS (General Electric Comprehensive Operating System)
Specifies general information about the user that is not needed by the system, such as an office or phone
number.
username
The User Name
passwd
The Encoded password
last
Days since Jan 1, 1970 that password was last changed
min
The minimum period in days that must expire before the password can be changed
must
Days after which password must be changed
warn
Days before password is to expire that user is warned
Expire
Days after password expires that account is disabled
7
disable
Days since Jan 1, 1970 that account is disabled
reserved
A reserved field
How does enabling shadow passwd's change the functionality of user authentication?
Why is there a /etc/shadow (or similar, differently-named) file? What is in it, and how
Is it different from /etc/passwd?
When a system has shadow passwords enabled, the password field in /etc/passwd is replaced by an "x"
and the user's real encrypted password is stored in /etc/shadow.
Dump is a backup utility. If its 0, it will not backup the file system
Fsck is a file system check utility. Numbers are define to tell in which order the file system should be
checked.
How you gonna check on which redhat linux version you are working on?
# Cat /etc/redhat-release
How do you findout whether a command is an aliases, bash function, built-in like cd and
type, or executable program?
# Type -all yourcmd
CRON/ANACRON
Whats the difference between CRON and AnaCRON
CRON:
8
cron assumes your system is running. Continuously. (And that crond is running).
AnaCRON:
Anacron uses a config file and a time stamp to determine the last time a task was done. If the tasks is
overdue to be done, anacron makes sure it gets done.anacron does not run continuously. It is a “one shot”
command. It is usually invoked on bootup
Anacron looks at boot-time if something was missed while the computer was off.
Used to control the execution of daily, weekly, and monthly jobs
When I add a new task to my crontab, I get an e-mail evertime it has been executed. Can
this be avoided in some way?
Yes, append '> /dev/null' to your crontab entry.
Example:
30 04 * * * mydailyscript.sh > /dev/null
How do you find all the programs, and there location, using sockets or pipes on your
computer?
lsof
9
How do you create directory and subdirectories when the parent directory may exist, in one
command? In other words, create the following directory structure.
/home/user/one/two the command should work whether /home/user exists or not.
mkdir -p /home/user/one/two The -p or "parents" makes the parent directory as needed.
If someone talks about ext2 and ext3 filesystems, what are they most likely running?
Debian or Redhat?
RedHat
How do you create a directory that's sharable to a group that by default will have each file
created as sharable to a group?
Mkdir <dir>
Chmod 770 <dir>
What options to (GNU) tar (1) would you use to decompress and extract everything from an
archive named files.tar.gz into the current directory?
# Tar –zxvf file.tar.gz
If you mistype a password, how do you clear it out to retype the password again?
Ctrl-C.
What command would you use to check available disk space on all currently-mounted
disks?
Partitions?
# df –h
How would you add a user to your system? What files get modified?"
# useradd <username>
It modifies two files:
/etc/passwd
/etc/shadow
How do I remove those enoying ^M chars from textfiles that has been generated on a
Microsoft platform?
Use the 'tr' command to remove them like this:
# cat <thefile.txt> | tr -d '\r'
This will output the new file without the ^M charters to your standard output. Just redirect them using the
'>' char to get the result in to a file like this:
# cat <thefile.txt> | tr -d '\r' > newfile.txt
tr – translate
-d delete
\r return
How do you give a user access to an application or program that needs to run as root
without giving them the root password?
I would use sudo or setuid
What are the steps involving the recompilation of the linux kernel
1. untar the tar file into /usr/src/kernel
2. VI Makefile (change the ver.)
3. make menuconfig or ./config or
4. make deps
5. make bzImage
6. cp /kernel/arc/i386/boot/bsImage to /boot/bzImage
7. cp /kernel/system.map to /boot/system.map
8. make
9. make check
10. make install
If I'm logged in as root, what command lets me "become" another user id?
su
What is a daemon?
What is /etc/inittab?
Startup sequence file
What is the first process to start on a UNIX system, after the kernel?
init
What is an X Server?
graphical display device,7optional
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 most graceful way to get to run level single user mode?
A: The most graceful way is to use the command init s.
If you want to shut everything down before going to single user mode then do init 0 first and from the ok
prompt do a boot -s.
What does the following command line produce? Explain each aspect of this line.
$ (date ; ps -ef | awk ‘{print $1}’ | sort | uniq | wc -l ) >> Activity.log
A: First let’s dissect the line: The date gives the date and time as the first command of the line, this is
followed by the a list of all running processes in long form with UIDs listed first, this is the ps -ef. These
are fed into the awk which filters out all but the UIDs; these UIDs are piped into sort for no discernible
reason and then onto uniq (now we see the reason for the sort - uniq only works on sorted data - if the list
is A, B, A, then A, B, A will be the output of uniq, but if it’s A, A, B then A, B is the output) which
produces only one copy of each UID.
These UIDs are fed into wc -l which counts the lines - in this case the number of distinct UIDs running
processes on the system. Finally the results of these two commands, the date and the wc -l, are appended
to the file "Activity.log". Now to answer the question as to what this command line produces. This writes
the date and time into the file Activity.log together with the number of distinct users who have processes
running on the system at that time. If the file already exists, then these items are appended to the file,
otherwise the file is created.
Question 5: What is CVS? List some useful CVS commands. (Asked by Silicon Magic Corp.
people)
CVS is Concurrent Version System. It is the front end to the RCS revision control system which extends
the notion of revision control from a collection of files in a single directory to a hierarchical collection of
directories consisting of revision controlled files. These directories and files can be combined together to
form a software release.
There are some useful commands that are being used very often. They are
cvs checkout
13
cvs update
cvs add
cvs remove
cvs commit
What is PAM?
What is Jouranaling.
The act of moving pages of memory from RAM to virtual memory on a hard drive. Excessive paging is
caused by a lack of actual system memory. In this case the system has to use the hard drive as memory
frequently, and performance is degraded.
What are the main differences between Apache 1.x and 2.x?
What does the “route” command do?
What are the read/write/execute bits on a directory mean?
What is SED?
SED (which stands for Stream EDitor) is a simple but powerful computer program used to apply various
pre-specified textual transformations to a sequential stream of text data.
It reads input files line by line, edits each line according to rules specified in its simple language (the sed
script), and then outputs the line.
What is AWK?
AWK is a complete pattern scanning and processing language, it is most commonly used as a UNIX
command-line filter to reformat the output of other commands.
For example, to print only the second and sixth fields of the date command (the month and year) with a
space separating them, at the UNIX prompt, you would enter:
Date | awk ‘{print $2” ” $6}’
What's your biggest fuck up, and how did you fix it?
Now tell me how you would a) mirror the rootdisk, b) grow an existing filesystem, or c)
modify the partition table for a disk on that OS.
Do you consider the open source movement to be a threat to the commercial software
industry?
Do I need to reboot the machine after increasing the maximum number of open files at
/etc/security/limits.conf
No
14
/etc/security/limits.conf
* - nofile 2048
System Monitoring
Like when you use 'uptime' (or 'w'), what do the three numbers after 'load average'
represent?
ps -aux, will show all processes. Look for "Z" in that stat and defunct under the command.
Note: wait may still produce zombies. This can happen of child A terminates, and its signal has been
caught. While this signal is being process child B terminates. Since these signals won't queue, child B
could stay in the zombie state. It's safer to use the waitpid call.
Describe the various metrics and procedures you would use to evaluate the performance
and system utilization of a linux machine
How would you find the most recently changed file in a directory?
ls –ltr
How would you find all the processes being run by user "joe?"
System 5: ps -fe | grep joe
Berkeley: ps -auxww | grep joe
There are two unix machines named A and B that are on the same subnet. Describe to me, in as much
detail as possible, what happens when I type "telnet B" from a terminal on machine A.
How would you grab the middle 300 lines of a 1000 line file, grab the second field of every
line in that range, and sort the result alphabetically using only piped commands from the
toolbox?
Q2. An incremental backup is the quickest method for performing backups of data. An
incremental backup only backs up files that have been created or modified (their archive bit
is set to 1) since the last normal or incremental backup. An incremental backup also clears
the archive bit (sets the archive bit back to 0) of all files that it backs up.
Basic Networking
What's a socket? What's a port? How do you reserve them? how are they related? How do
you find out what's going on with them on a system?
Normally, a server runs on a specific computer and has a socket that is bound to a specific port number.
The server just waits, listening to the socket for a client to make a connection request.
Socket: IP + Port
Port: is a virtual data connection. Programs binds on the port to exchange the data.
What would you use to view the contents of TCP packets on the network
16
# tcpdump
How would you check TCP packets coming from Remote IP?
# tcpdump –i <interface> src <IP>
Q. How do you setup multiple IP address on one NIC (Network Interface Card)...assume
ethernet.
4. Where would you look for startup and error messages on a UNIX server?
/var/adm/messages (/usr/adm/syslog on HP-UX boxes). They can also run the command dmesg.
TROUBLESHOOTING
KERNEL COMPILATION
When would you want to reconfigure the kernel and how would you do it?
If incase your hardware doesn’t supports, Enabling SMP
RAID
RAID
17
===
Fs it advisable to put a swap portion in RAID1 (mirroring?) pros & cons?
What is RAID?
Redundant Array of Independant Disks, striping, mirroring, etc..
What is striping?
A technique for spreading data over multiple disk drives. Disk striping can speed up operations that
retrieve data from disk storage. The computer system breaks a body of data into units and spreads these
units across the available disks. Systems that implement disk striping generally allow the user to select the
data unit size or stripe width.
Disk striping is available in two types. Single user striping uses relatively large data units, and improves
performance on a single-user workstation by allowing parallel transfers from different disks. Multi-user
striping uses smaller data units and improves performance in a multi-user environment by allowing
simultaneous (or overlapping) read operations on multiple disk drives.
What is RAID-5?
What is striping?
RAID levels; pros & cons of different levels; what is RAID 1+0
Mail Server
6. If you send an e-mail to someone and it comes back "Message Undeliverable", what could be
wrong?
7. You can receive e-mail, but can't send any. What is wrong?
- Name at least two types of server process that can be an open mail relay but are not SMTP server
processes.
- Explain in what ways each of the IMAP, POP3, and SMTP protocols are used.
- Give at least two differences between IMAP and POP3.
- Explain at least one way that SMTP is used that does not involve a mail user agent.
(Bonus points for creative answers.)
- What is an open mail relay?
- How would you test an SMTP server to see if it is an open mail relay?
- Name at least two types of server process that can be an open mail relay but are not
18
SMTP server processes.
- What are the basic commands to send a message to an SMTP server?
(Hint: Begin with HELO.)
What is /etc/aliases? mail aliases for systems
Is there an easy way to find out which mailservers that handles incoming e-mail for a domain?
Answer
Yes, this can be done with the 'host' command. Have a look at the manpage for more information on how
to use it.
Example:
# host mreriksson.net
mreriksson.net has address 62.20.106.119
mreriksson.net mail is handled (pri=10) by mail.mreriksson.net
#
Is there some interactive way to view active processes in the system based on their size or cpu-usage?
Answer
Many unix/linux systems comes with a command called 'top' that does this. See the manpage for top for
detailed information on how to display processes based on cpu- or memory-usage.
Web Server
How to install and configure an Apache Web server.
How do I know what modules I have available in my installation of apache?
Answer
Execute: 'httpd -l', this will show you a list of all available modules.
--------------------------------------------------------------------------------
Question 2
What user should the stand-alone server is run as?
Answer
It should be run as root to be able to attach to port 80. Apache will then spawn it's children with the owner
you specify in the httpd.conf file. (Which should be a user without any additional access)
--------------------------------------------------------------------------------
Question 3
When would I use the inetd daemon to execute Apache?
Answer
Since running Apache from inetd will slow down new client connections quite alot, it's best suited for
servers which doesn't handle alot of requests, and would are low on memory.
19
Note: To run Apache from inetd can also make life a bit easier when working with apaches configuration
files, since they will be re-read as soon as a new client connects.
--------------------------------------------------------------------------------
Question 4
Can I prevent a user to override my global settings with the .htaccess file?
Answer
Yes, you can do this with the 'AllowOverride' option in the config file.
Example:
<Directory />
AllowOverride None
</Directory>
This will prevent users from using the .htaccess file in all directories.
--------------------------------------------------------------------------------
Question 5
Is the UserDir module safe to use?
Answer
The UserDir module is said to be safe if the html pages arn't stored in the users homedirectory. Instead
you should set up an additional directory for each user outside it's homedirectory, and use the following
configuration:
<IfModule mod_userdir.c>
UserDir /home/httpd/*/
</IfModule>
And for each user have a directory, which they own, under /home/httpd/, with the same name as the user.
This will enable users to have an URL like http://host.fo/~user
--------------------------------------------------------------------------------
Question 6
How should I configure Apache to make it serve WAP pages?
Answer
You should add these lines to your Apache configuration:
The you should locate the 'DirectoryIndex' directive in the file, and add the 'index.wml' tag to it, should
look something like this afterwards:
<IfModule mod_dir.c>
DirectoryIndex index.html index.wml
</IfModule>
This tells Apache to look for a file named index.wml if no file is specified in the requested URL.
(Example: http://host.fo/wap/)
Note: There might be more arguments here if you, for example, have installed support for PHP or Perl.
--------------------------------------------------------------------------------
Question 7
How do I use Apaches user authentication (htaccess)?
Answer
First of all, you need to configure your Apache server to allow usage of the .htaccess file for
authentication control. This is done by adding the keyword 'AuthConfig' to the 'AllowOverride' option in
the current <Directory> block. Based on the default configuration, you might end up with something like
this:
<Directory />
Options FollowSymLinks
AllowOverride AuthConfig
</Directory>
This enables the usage of .htaccess in all directories in your file system. (For security reasons, you might
want to limit this to a certin directory instead of the file system root)
To limit the access to a directory and all its sub-directories, you should create a file called '.htaccess'
within it. This file should contain the following options:
AuthName ZoneName
AuthType Basic
AuthUserFile /usr/local/etc/apache/htusers
Require valid-user
AuthName configures the name of this authenticated zone. By defining the same name in several zones,
they can be included in the same authentication session, and thereby only require the user to login once to
access all zones on the site.
AuthType defines the type of authentication that should be used; the 'Basic' type is the most widespread
one and will provide the best compatibility.
21
AuthUserFile referes to the htpassword file to fetch login information from. This file can be generated by
using the htpasswd(1) command provided with the Apache package, or via the online tool availible at
http://mreriksson.net/online/htgenerator/ .
The Require option tells Apache which usernames to accept for this zone. Using the 'valid-user' keyword
will allow all users defined in the AuthUserFile to login. The 'user' keyword allows a whitespace
separated list of usernames that are allowed from the given userfile. Example: Require user user1 user2
user3
--------------------------------------------------------------------------------
Question 8
Is there a way to allow virtual hosts to have their own cgi-bin directory?
Answer
Yes, this can be specified using the ScriptAlias-option in the <VirtualHost> block that you want to enable
this for.
Example:
<VirtualHost *>
ServerAdmin [email protected]
DocumentRoot /home/httpd/www.foo.bar/public_html/
ServerName foo.bar
ServerAlias www.foo.bar
ScriptAlias /cgi-bin/ /home/httpd/www.foo.bar/cgi-bin/
ErrorLog /home/httpd/www.foo.bar/logs/error_log
CustomLog /home/httpd/www.foo.bar/logs/access_log common
</VirtualHost>
Note:
It's important that you end the path to the cgi-bin directory with a slash (/), or Apache will fail to find your
cgi's.
--------------------------------------------------------------------------------
Question 9
When using ScriptAlias to allow site-specific cgi-bin-directories, is there a way to require the user to log
in before the cgi's can be accessed?
Answer
Yes, this can be done in the normal way with the htaccess-system. Just place an .htaccess-file that
configures the authentication-requirements in the cgi-bin directory.
DNS Server
22
- What is found in a DNS zone file? (Assume BIND running on a POSIX operating system.)
- What is the purpose of an MX record?
- What data is transferred in a DNS zone transfer?
- In what circumstances would you permit systems outside of your local/corporate network?
To perform DNS zone transfers? In what circumstances would you not?
2. What files are used to configure DNS on a UNIX BOX?
/etc/resolv.conf and /etc/nsswitch.conf
-
Know the options available in /etc/named.conf.
DNS
-------------
# what is DNS
DNS stores the database of domain name and its corresponding IPs.
It is used for translating domain name to IP and vice versa
# dig MX domainname
# nslookup -query=NS linobox.com
NFS Server
What is NFS?
NFS is Network File System
It is basically used for sharing files & directories on a network.
What is RPC?
Library routines for remote procedure calls
These routines allow C programs to make procedure calls on other machines across the network.
How would you share /home/exports to a specific machine (192.168.20.10) with read/write permission?
# vi /etc/exports
/home/exports 192.168.20.10(rw)
NFS is a RPC protocol that runs atop UDP and IP. Explain
RPC is simply a system call that is processed by a remote server. When a prg makes an I/O call, for an
NFS file, the call is intercepted by the NFS file system and sent over the NW to the remote server for
Processing.
The NFS daemon starts up some helper daemons alongwith? What are they?
A: rpc.rquotad,rpc.lockd, rpc.mountd
9. These helper damons, like all daemons, needs ports to bind to [monitor] and
run on. Are these ports given in /etc/services?
A: No
A: 2049
A: /etc/services
A: 111
14. RPC services have their own config file. What is it?
A: /etc/rpc
15. Display a list of NFS shares from a client if the server is shiva
A: showmount -e shiva
A: showmount -e localhost
17. Which file is configured on a NFS server to facilitate sharing across a NW?
A: /etc/exports
A: Telling the NFS daemon to re-process /etc/exports and rebuild the NFS
mount table config file, which is...., cannot say, since it a question.
See later.
20. Which NFS file shows the export permissions of all exported directories ?
A: /var/lib/nfs/rmtab
21. Which NFS file shows the info about currently exported dirs, which 'mountd'
reads when processing client mount requests and is rebuilt every time
'exportfs' is run?
A: /var/lib/nfs/xtab
22. How would you check who [remote hosts ] were using your NFS server and
Which files were in use?
A: nfsstat -a
23. I wish to temporarily export a dir /jokes on shiva to brahma with r/w
perms. How?
A: exportfs brahma:/jokes -o rw
26. Then how would you unexport this temporary dir, if I did not wish to do a
'service nfs restart'?
A: exportfs -u brahma:/jokes
27. Can I unexport all exported dirs w/o shutting down/restarting the NFS
daemons? How?
A: Yes.
28. How?
A: exportfs -ua
27
29. How would you know there are no shares now which are exported?
A: showmount -e
/ shiva brahma
31. How would a user foo on a remote client brahma mount this on her local
empty dir /win ?
32. Can a user foo delete any files in the NFS share win?
A: No
A: No
35. squashed ?
A: nfsnobody.
A: Yes!
A: 65534/65534
/ shiva(rw) brahma(rw,no_root_squash)
41. Why can't user foo on shiva delete files on ganesh. It does have NFS'
share's rw perms on it. So ?
Although NFS does allow it, dir perms of the OS do not for
[no "w" for 'others'].
'Root', meanwhile, has also been squashed!
/ shiva(rw)
/ shiva (rw)
A: Exports the entire filesystem to machine shiva with r/o access and to the
entire world with write access. Precisely what you did not want, in reverse!
/ 192.168.0.
A: Exports the entire FS to all m/cs on segment 192.168.0 with r/o access.
/projects proj*.local.domain(rw)
/home/foo pc001(rw,all_squash,anonuid=100,anongid=100)
A: These options explicitly set the uid and gid of the anonymous account
which would normally have been nfsnobody [65534/65534]. So why bother?
Primarily useful for PC [M$] / NFS clients, where you might want all
requests to appear to be from one user.
Here, all requests are mapped to uid 100 (which is supposedly that of
user foo).
/pub (ro,insecure,all_squash)
A: Exports the public FTP directory to every host in the world, executing
all requests under the nfsnobody account.
The insecure option in this entry also allows clients with NFS
implementations that do not use a reserved port for NFS.
49. Remote NFS client brahma mounts /jokes on local dir /funny using the
following :
Now, for some reason, the NFS server on ganesh goes down.
What will happen on brahma?
A: No
A: Use intr
A: Use soft
53. You suddenly get smart overnite. How would you do all this before mounting
a NFS share?
55. How would you automate a NFS Client with all the above considerations in
mind?
and make sure the netfs daemon starts at boottime. And of course
portmap
56. What is the default for the read and write buffer ?
A: 4096
A: 6
A:
* Block sp. device [devdrv], or remote FS to be mounted.
One can use LABEL too which points to a hardware partition.
* Mt point for the FS
* Type of FS
* Mount options associated with the FS
* Dump details
* fsck
59. The fifth field of /etc/fstab contains mount options associated with the
FS viz. ext3.
What does defaults mean?
A: rw,suid,dev,exec,auto,nouser,async
61. How would you remount all the FS's in /etc/fstab w/o rebooting?
A: mount -a
A: Yes
A: user [nouser]
65. foo mounts a cdrom and logs out? Can bar log in and use his own cdrom?
A: No. He will have to unmount foo's cdrom first, for which he has no
permission.
67. You just said that owner and user and synonymous! Can I use 'owners' above ?
A: Yes. redhat-config-nfs.
Q Which of the following packages must be installed to host an NFS server? a. knfsd
b. knfsd-clients
c. netfs ====
d. portmap =====
You have just added a new NFS share to the appropriate file. What must you do?
To activate the share?
A. reboot
B. exportfs -a =======================
C. ndc restart
D. server nfs start
E. mount -A
Q. How can I see what directories are being shared via NFS on a remote host
Called fileserver?
A. ping fileserver
B. mount -a -t NFS fileserver
C. show mount -e fileserver =======================
D. stalk --query fileserver
E. None of the above
Q. What is Portmap?
Q. What is RPC?
Samba Server
Firewall (IPTABLES)
What is DMZ
What is Bastion Host
What do you know about Firewalls?
Printing
Shell Programming
Write a script to convert all DOS style backslashes to UNIX style slashes in a list of files.
You have 20 servers that need to be updated named server01,server02...server20. Write a bash script to
update all the computers, assuming they all use ssh, with the account bozo.
Ans:
34
#!/bin/bash
user="bozo";
updatecmd="ls -l"; # put in rpm command here
errorfile="updatelog";
for i in `seq -w 20`
do
ssh "${user}@server$i" $updatecmd || echo "Error on server $i >> $errorfile";
done
How can you easily print quotes in an awk script? U sing a sed script print only the
data between "<start>.....</start>" in a file.
for i in {01..20} should get the same effect in recent versions of bash2.
Write a regular expression (or sed script) to replace all occurrences of the letter ‘f’, followed by any
number of characters, followed by the letter ‘a’, followed by one or more numeric characters, followed by
the letter ‘n’, and replace what’s found with the string “UNIX”.
Write a script to list all the differences between two directories.
Write a program in any language you choose, to reverse a file.
PERL
What does the @ in a variable indicate? its an array
___ What's the current version of Perl? 4 or 5 prefer 5. 5.005 is MRV
___ What is a Hash? a key-data pair type of array variable
What is an inode?
Pointer to block of disk, referenced in a directory
The inode contains information about the file size, file location, ownership, etc. Plus, it contains a pointer
to the first few blocks of data in the file.
Any Unix today that requires one to play with the file system at the superblock level is also too broken to
use in any kind of production environment. It is simply not "production quality," let alone "state of the
art."
All that kind of stuff went away with the development of fsck some 20+ years ago.
While playing with superblocks and file system structure may be fine on a hobby system, a commercial
system cannot afford the downtime, the introduced lack of reliability associated with playing with the file
system on the bit level or the time while someone plays -- that time is better spent on recovery which you
are willing to "bet the company on."
FIND
Using the find command how do you find directory names that "do not contain" a
particular file?
Using the find command, how do you find all files with the immunitable attribute set?
Write a command to find all of the files which have been accessed within the last 30 days.
find / -type f -atime -30 > December.files
This command will find all the files under root, which is ‘/’, with file type is file. ‘-atime -30′ will give all
the files accessed less than 30 days ago. And the output will put into a file call December.files.
NET
What is the difference between IP Masq and Proxy?
SSH
How would I configure sshd to not ask for a password when connecting with a given user from a
certain host?
The best solution for this is to create a DSA key which can be used to authorize you when you log into the
computer. This is done in two steps, 1) Create the key, 2) Transfer the public part of the key to the server.
Step one:
36
On the machine which you want to connect from, execute the following command:
ssh-keygen -b 768 -d -f ~/.ssh/id_dsa -P ""
This will create two files under .ssh/ in your homedirectory. They will be called 'id_dsa' and 'id_dsa.pub'
which contains the public (id_dsa.pub) and the private (id_dsa) parts of your key.
Step two:
The public part of your key will now need to be transfered to the server which you want to connect to
without entering a password. This can be done using the 'scp' command provided with most ssh clients:
scp ~/.ssh/id_dsa.pub [email protected]:~/.ssh/authorized_keys2
In reality, you should just find a way to transfer your '.ssh/id_dsa.pub' file to the remote machine, rename
it to 'authorized_keys2' and place it under '.ssh/' in your homedirectory. Also, if you want to add more
keys to the same account on a server, you'll just append the data in your new id_dsa.pub file to the
.ssh/authorized_keys2 file on the server.
Note: This solution is based on the ssh v2.0 protocol since it's more secure than v1.x in general. Therefor,
if your ssh client supports v1.x and the server is configured to try that version first, you'll probably have to
tell the client to use v2.0, or you will get a password question anyway. (With OpenSSH, this is done using
the '-2' flag)