Sunday, 7 May 2017

unix questions and answers part -1

Q. List out few of the differences between Softlink and Hardlink ?
a) Hardlink cannot be created for directories. Hard link can only be created for a file.
b) Symbolic links or symlinks can link to a directory.
c) Removing the original file that your hard link points to does not remove the hardlink itself; the hardlink still provides the content of the underlying file.
d) If you remove the hard link or the symlink itself, the original file will stay intact.
e) Removing the original file does not remove the attached symbolic link or symlink, but without the original file, the symlink is useless
5. What is the difference between umask and ulimit ?
umask stands for ‘User file creation mask’, which determines the settings of a mask that controls which file permissions are set for files and directories when they are created. While ulimit is a linux built in command which provides control over the resources available to the shell and/or to processes started by it.
You can limit user to specific range by editing /etc/security/limits.conf at the same time system wide settings can be updated in /etc/sysctl.conf
Q. What is crontab and explain the fields in a crontab ?
The cron is a deamon that executes commands at specific dates and times in linux. You can use this to schedule activities, either as one-time events or as recurring tasks. Crontab is the program used to install, deinstall or list the tables used to drive the cron daemon in a server. Each user can have their own crontab, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly. Here are few of the command line options for crontab.
crontab -e Edit your crontab file.
crontab -l Show your crontab file.
crontab -r Remove your crontab file.
Traditional cron format consists of six fields separated by white spaces:
<Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week> <command/program to execute>
The format is explained in detail below.
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
Q. What are inodes in Linux ? How to find the inode associated with a file ?An inode is a data structure on a filesystem on Linux and other Unix-like operating systems that stores all the information about a file except its name and its actual data. When a file is created, it is assigned both a name and an inode number, which is an integer that is unique within the filesystem. Both the file names and their corresponding inode numbers are stored as entries in the directory that appears to the user to contain the files. The concept of inodes is particularly important to the recovery of damaged filesystems. When parts of the inode are lost, they appear in the lost+found directory within the partition in which they once existed.The following will show the name of each object in the current directory together with its inode number:
# ls -i
The avialble number inodes in a filesystem can be found using the below command :
# df -i
The other way we can get the inode details of a file by using the stat commmand.
Usage : # stat <file name>
Example :
-sh-4.1$ stat note.txt
File: `note.txt'
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: fd05h/64773d Inode: 8655235 Links: 1
Access: (0644/-rw-r--r--) Uid: (69548/nixuser) Gid: (25000/ UNKNOWN)
Access: 2014-06-29 15:27:56.299214865 +0000
Modify: 2014-06-29 15:28:28.027093254 +0000
Change: 2014-06-29 15:28:28.027093254 +0000
Apart from the above basic questions, be prepared for answers for the below questions
1. How to set linux file/directory permissions ?
2. How to set ownership for files/directories ?
3. How to create user/group and how to modify it ?
4. How to find kernel / OS version and its supported bit (32/64) version ?
Uname -a
5. How to set / find interface ip address ?
Ifconfig (use in root)
Q. How to find linux mount points and disk usage ?
Df -h
7. What command to find memory and swap usage ?
Top
Q. Have a look on ps, top, grep, find, awk and dmesg commands ?
If a file has permissions 000, then who can access the file?
Root user can see and modify the file. Below are the steps -

1 > vi filename.txt
2 > change the contents
3 > :wq! (for forcefully edit)
Extract 2 characters in file
Hello,I want to extract 2 characters of the first column of the one file, that file has 19 columns, in bash script.the first column is some thing like this 2005-07-25, and I want to extract 07. I wrote this codeawk '{ print $ substr ($1,6, 2)}, but out put is he whole of the column: 2005-07-25! can you help me?
awk '{print substr($1,1,2)}' lipi.txt  is the syntax for substring function
Searching for file in UNIX
How to search a file in a directory having sub directories having size more than 10MB?
Are u sure ? is it working?
Find . -type f -size +10M
Find First Word of the First Line
How to find first word of the first line of the first ten files?
awk '{print $1}' lipi.txt | sed -n '1p'
Q.How to compress files in UNIX and the commands used ?
Lot of options available like gzip, compress and tar
•    Compress/uncompress filename, gzip/gunzip file, bzip2/bunzip2 file
tar –cvf /directory_nameor path
tar –xvf  /directory_nameor path
tar –tvf /directory_nameor path
Server Down in LINUX
In LINUX OS if Server goes down, What will you do to restore it back?
Server goes down in LINUX, 1. Check whether vm or physical -check on console there should be some thing displayed on console window -if kernel panic or gives blank window try for hard reboot. 2. The...
LINUX Patch / Package
Q.What is the difference between > and >> redirection operators ?
Is the output redirection operator when used it overwrites while >> operator appends into the file.
> is used to copy data (output) by overwriting old data.
>> is used to copy data (output) without overwriting old data. Just will be added under old data.
'>' is used to redirect the output to an file in write mode. If it is redirected to a file which already contain some data, then the data will be overwritten.'>>' redirects the output in append mode. This mode will append the data in existing file.
Explain the UNIX Kernel?
Kernel basically provide the interaction layer between application programs and the physical device. Kernel is base foundation of operating system .The kernel provide services such as hardware and software interaction and memory management. Efficiency of operating system is depend on efficiency of kernel.
Q.What is the difference between grep and find commands?
A)provides information on helpb)grep searches in a file whereas find searches for files and directories.c)both a) and b)d) none of the above
grep is the short form of global regular expressions, so it generally searches for a word in a file or in a list of files. On the other hand find can find a regular file, directory file and special fi...
B)grep searches in a file whereas find searches for files and directories.
How can you come to the home directory?
cd $HOME
Cd , cd ~, cd $HOME.
You will in home_diretory
cd
cd ~
Q.When you issue the command ls -l, what does the first character of the resulting display represent?
If you mean the first character of each line, its the file type (- for regular file, d for directory, l for symbolic link, and b or c for block and character devices).
Totalno. of disk blocks that occupied by current directory.
Q.What is difference between Hard and Soft mount?
Hard mounts can be, and very often are, used with autofs as well. To most users, there is virtually no difference between the two except that if "intr" is not added as a mount option with hard nfs mo...
NFS supports two types of mounts -- hard mounts and soft mounts. If a mount is a hard mount, an NFS request affecting any part of the mounted resource is issued repeatedly until the request is satisfi...
What are the commands to make a file hidden and to delete all hidden files in the folder?
Find . -maxdepth 1 -name ".*" -type f -delete
mv  filename .filename
Rm -rf .* will delete all files present in all current directories. but suppose you have to delete file in a particular directory. we can use find.

find dir -type f -name .* -maxdepth 3|xargs rm -f
or
find dir -type f -name .* -maxdepth 3 exec rm -f {} ;
Q.How to grep directories
Q.How to grep directories has reached above 80% from the df output using basic grep command.below are the steps i have used

df -h  | awk '{print $5,$6}'| grep -vi use | grep [7-9^][0-9]
Echo command
in unix what is the purpose to use echo with the option "-e"??
i.e echo -e
Echo -e /nabhinav
in this first a blank line will be printed after that in next line abhinav. -e is used for special symbols
[/home/gk]=> echo -e "is it different"
-e is it different
[/home/gk]=> echo "is it different"
is it different
Connect Remote Terminals
What is the command to connect to remote terminals?
TELNET or SSH
Ssh command
Which of the following statements about Unix is incorrect. 1. it is a multi-user system 2. it is the name of a file in root directory 3. it is a multitask system 4. it is a real time system
It is the name of the file in the root directory. It is a multi-user system and multitasking.
2. it is the name of a file in root directory
Proxy Server IP
Command to find the IP of an Proxy Server in UNIX
Route -n or  ifconfig
How to change Ownership to a file or folder ?
•    Chown command
How to identify with in the script about the count of parameters passed to a given shell script?
By $#
What difference between cmp and diff commands?
cmp - Compares two files byte by byte and displays the first mismatch
diff - tells the changes to be made to make the files identical
sdiff-
To check the differences between the data of two files cmp command is used. But it displays only the first difference. Syn: $ cmp file1 file2 To display all the differences between the files diff comm...
diff is used primarily for files in text format, for example, source code.  It is used to list all of the differences between two files.It is often used in source code control to get the changes ...
How to find CPU utilization for only server ?
Using "sar" command also
TOP command
How to do soft mount ?
Explain any precautions needs to be take before you do soft mount
An NFS file system that is mounted with the soft option returns an error if the server does not respond. The hard option causes the mount to continue to retry until the server responds. The default is hard

if you want to do soft mount try this cmd  ln -s
Ln -s
Explain Memory Partitioning, Paging, Segmentation?
Segmentation eliminates internal fragmentation, but it suffers from external fragmentation. Since process is broken into a number of smaller process external fragmentation should be less. partitions...
Memory Partitioning- means partitioning the memory into small units or blocks & load the data or code into the blocks, & use this data & code when required by a process.Paging- i...
The root directory of disk should be placed 1. at a fixed address in main memory 2. at a fixed location on disk 3. anywhere on the disk 4. at a fixed location on the system disk
The root directory of disk also known as the MBR or the GUID partition is at a fixed location with replicas distributed at additional locations on the system disk determined by size.
Fread.This commands reads a file and stores the file in the given folder of disk.
UNIX Command to Store Data
You have to store data on the system which command will you use(a) fread(b) fwrite(c) read(d) write
The header to this question is wrong. This is not a unix command it should be titled "C library function to store data in a file".

The answer would then be (a) fwrite.

fwrite is not operating system specific and will work the same on Unix or Windows.
(d) write
Boot cdrom -s
when we give Boot cdrom -s which CD should be there inside cdrom ?
When issuing the boot cdrom -s the system install disk should be in the cdrom drive. Booting this way will allow you to boot in single user mode and hopefully repair a system.
For Booting cd in CD Rom the command is :

mount cd-rom/mount
What are shell variables?
Shell variables are special variables, a name-value pair created and maintained by the shell. Example: PATH, HOME, MAIL and TERM
Shell variables are special variables, a name-value pair created and maintained by the shell. Example: PATH, HOME, MAIL
These are some more variables    .......$PWD,  $DIR_COLORS,  $SHELL,  $SHLVL

What is the output of kill -3 pid ?
Kill -3 pid find the thread dump jvm process
Kill -3 pid is used to create thread dump for the process id. This is basically used for troubleshooting and to understand what went wrong with the above process. Suppose some node of weblogic is not ...
What are the parameters in http.conf file ?
Some parameters are
1.mod_rewrite
2.WLLogFile
3.DebugConfigInfo
4.StatPath
5.CookieName
6.MaxPostSize
7.FileCaching
What is VLAN ?
what is vlan in vio server in aix ? What is its main purpose ?
VLAN stands for virtual LAN,it is a broadcast domain created by switches.With VLAN’s, a switch can create the broadcast domain.The purpose of VLANS is to improve network performance by separating large broadcast domains into smaller ones.
Print Using string copy and concate Commands
Masked Code
What is the number of the masked code ee@?
022 is the number of the masked code ee@
COPY Command
Assume that you are NOT currently in your home directory. Enter a command to copy all files in your home directory beginning with the letter 'a' to the current directory.
Cp [a]* /export/home/
cp  ~/a* .
cp ~/l* .
cp -r ~/l* .
What is kernel? What is the difference between kernel and microkernel? What is the difference between unix and Linux? What is relational database,hierarchal database. and network database? their difference?
Kernel - The kernel is the main component of most computer operating systems. - It is a bridge between applications and the actual data processing done at the hardware level - The kernel is the heart ...
Unix was developed using ‘C’ Language. Unix was the foundation on which Linux was built. Unix has Character based environment while Linux has Graphical as well as Character based environment. Unix has...
What permissions do we need to kill a process ?
We need root access to kill the process.But have to check before killing process whether it is using by any user and importance of that process.
Sleep and Wait in Linux
•    What is the difference between Sleep and Wait in Linux ?
The wait command man page simply states that it pauses script execution until a specified process ID completes.

The man page for the sleep command is a single line stating that it causes a script to pause for specified period of time.
 Superuser Privilege
How will you assign superuser privilege to an ordinary user temporarily?

1) Edit /etc/passwd file by chaning the UID of the required user to "0"
     This makes normal user as superuser

2) Using "sudo", ordinary user can execute any command with superuser privileges.
CPU Utilization Time
By using which command can you find the CPU utilization time?

Top command
$ iostat
tty 2/md300 2/md301 2/md302 2/md303 cpu
tin tout kps tps serv kps tps serv kps tps serv kps tps serv us sy wt id
0 4819 0 0 4 292 15 3 1 0 3 0 0 4 67 10 0 22
UNIX Shell History File
Looking at history file in unix shell for a user, find 5 most often used commands.
Try following- it will give you top most used commands along with the count of how many times they have been used:

"history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5".
What is the default run level in IBM AIX? What are the 4 fields in Inittab file? How to see runlevel of unix system? Describes difference types of runlevel?
3. who -r will give the run level in unix system
In AIX default run level is 2.

4 fields in inittab are.
<ID> :<run level> :<action>:<Command>

ID is unique string taht identifies the object.
Find Files Accessed before 10 minutes
How will you find the files that are accessed before 10 minutes?
Find / -amin -10
What is the command to fetch first 10 records in a file?
Command as follows
HEAD -10 filename

and for lower records

TAIL -10 filename
It would be always safe to use 'sed command'sed -n '1-10p' filename > outputfile
Memory Management
How do you free the memory which is occupied by a process but did not free due to a memory leakage in a UNIX box? I know /proc/sys/vm/drop_caches will remove the memory out that command does not work in our UNIX box so I want a command or steps to find the memory and release them. I can use ipcrm command to remove the shared memory segment or the memory but I need to make sure that the one I am trying...
UNIX Shell History File
Looking at history file in unix shell for a user, find 5 most often used commands.
Try following- it will give you top most used commands along with the count of how many times they have been used:

"history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5".

Gave me following output on my machine:
166 ls
156 cd
53 pwd
21 clear
10 history
What are the various permissions a directory can have?
Read ,Write and Execute. Its just that in case of directories, execute right to a user means he can access the directory.
What UNIX command do you use to find out the open ports in a system?
 lsof -i tcp | grep LISTEN | awk '{print $(NF -1)}' | sort | uniq
To determine which ports are open in Unix AIX v 6+, follow these steps: 1. Identify the services by using the netstat command as follows: # netstat -af inet The following is an example of this comman..

When Grub is crashed then how i start the linux os?
Command is vi /etc/grub/grubconfig
Boot frm 1st cd type1) chroot /mnt/sysimage2) grub-install /dev/sda
Explain kill() and its possible return values?
There are four possible results from this call:�kill()� returns 0. This implies that a process exists with the given PID, and the system would allow you to send signals to it. It is system-dependent whether the process could be a zombie.�kill()� returns -1, �errno == ESRCH� either no process exists with the given PID, or security� enhancements are causing the system to deny its existence. (On���� some...
As we all know kill command sends a signal to the kernel. This signals are of 64 types. To list all these signals you can use kill -l. Signal no 1 -31 can be invoked by user, whereas, signal no 34-64 ...
Kill is one of the command in UNIX/LINux which allow user to kill/terminate one process ID or multiple processes IDs.Syntax:$kill -[options] PID$kill -9 754425The kill command send the specified signal to the specified process or process group
•  $kill  -9 754425
How do you restore deleted files in unix
If they are old files, they will be in snapshot directory Goto the directory, at which files were deleted and do cd .snapshot.Files will be present according to the dates in the respective folders lik...Using debugfs we can restore the deleted file provided if we know the inode no. of the same file
Hard link and Soft link
What is the difference between hard link and soft link?
________________________________________
Hard Link
when a file is copied, both the original and copy occupy separate space on the disk.
unix allows a file to have more than one name and yet maintain a single copy on the disk. The file is then said to have more than one link or name, but all have the same inode number. This is called hard link. All attributes are identical any modification or change in one file is automatically available in the linked file. It provides some protection against accidental deletion. Let there be a file named restore.sh. You need to create another file which provides as backup to the original file. By creating a link, you create a backup.
unix command used to create hard link >>ln- backup.sh restore.sh

Soft Link
It doesn't have the file's content but simply provids pathname of that automatically has the contents. This is called as softlink. but incase the original file is deleted we can't get the file's content from the linked file, coz, it just provides the path name of the file. This is also known as symbolic link. Windows shortcuts are more like symbolic links. The original file and the linked files have different inode nos.
Unix command used to create soft link>>ln-s
Hard Link1. Both the file and link have same inode numbers.2. If the original file is deleted, link also deleted .3. Cannot be used to link file on another file system.4. Cannot be used to link direc...
Hard Linkwhen a file is copied, both the original and copy occupy separate space on the disk.unix allows a file to have more than one name and yet maintain a single copy on the disk. The file is then ...
What can be possible is + is there in host.equiv file ?
 Answer: Any remote or local host users can login without any password Rsh and rcp is possible for all users
True, except for root!If you want to allow root access: /.rhosts
What are the different process states?
This varies by individual Operating System Vendor (AIX, HPUX, etc...) -here's what the man page for the ps command in hpux 11i v1 says:          &...
Kernal User Readyto Orphan Zombie Sleeping Run
How to copy a file from Remote AIX server to my local windows desktop
I am logging to remote AIX server, i want to copy a file from that server to local windows desktop. How can i do this?
Usually you can ftp to transfer files from one system to another, but ftp uses plain text asswords, therefore you can use scp ( secured copy protocol)unix/linux its inbuilt : scpwindows : pscpso from...


What is the use of �grep� command?
�grep� is a pattern search command. It searches for the pattern, specified in the command line with appropriate option, in a file(s). Syntax : ���� grep Example :��� grep 99mx mcafile
When you want to  display the lines which do not start with #, then give following command ,grep -v "^#" file1.txtif you want to serach recursively in all the directories , then give ,grep -r "string"
Grep - stands for Globally Search a Regular Expression and Print. It is used to search a given string/pattern under the given path and list out all the occurances of it in a file or set of...

UNIX File Access
The syntax of command statement in UNIX . If the permission for a file is 000, then the file can be accessed by whom?
Ans – Root only access that file
Find Open Ports
What UNIX command do you use to find out the open ports in a system?
To determine which ports are open in Unix AIX v 6+, follow these steps:
    1. Identify the services by using the netstat command as follows:
        # netstat -af inet
    The following is an example of this command output.
    The last column of the netstat command output indicates the state of each service.
    Services that are waiting for incoming connections are in the LISTEN state.
 
    2. Open the /etc/services file and check the Internet Assigned Numbers Authority (IANA) services to map the service to
    port numbers within the operating system.

    3. Close the unnecessary ports by removing the running services.
    So no one command will do it. It is a combimation of
        # netstat -af ine
        /etc/services, and
        some manual checks to see what ports are open

Explain kill() and its possible return values?
There are four possible results from this call:�kill()� returns 0. This implies that a process exists with the given PID, and the system would allow you to send signals to it. It is system-dependent whether the process could be a zombie.�kill()� returns -1, �errno == ESRCH� either no process exists with the given PID, or security� enhancements are causing the system to deny its existence. (On���� some systems, the process could be a zombie.)�kill()� returns -1, �errno == EPERM� the system would not allow you to kill the specified process. This means that either the process exists (again, it could be a zombie) or draconian security enhancements are present (e.g. your process is not allowed to send signals to *anybody*).�kill()� returns -1, with some other value of �errno� you are in trouble! The most-used technique is to assume that success or failure with �EPERM� implies that the process exists, and any other error implies that it doesn't.An alternative exists, if you are writing specifically for a system (or all those systems) that provide a �/proc� filesystem: checking for the existence of �/proc/PID� may work.
What are the kernel parameters?
Kernel parameters are:1)   /sbin/sysctl -a | grep sem2)  /sbin/sysctl  -a | grep  shm3)  /sbin/sysctl  -a  |  grep  file -max4)  /sbin/sysct    -a |  grep ip_local_port_rangel
UNIX File Access
If the permission for a file is 000, then the file can be accessed by whom?
ANS – ONLY ROOT
Program Termination
If a program is terminated at the middle of execution in UNIX, What will happen to the program?
Nothing, actually. The OS will halt program execution, retrieve whatever resources the program was using, close whatever files it had open, and go back to doing everything else an OS does.

If there is something that needs to occur when a program is terminated; e.g., if the program needs to close its own files gracefully and predictably; then that program needs to implement signal handlers to catch the most common termination signals.
Rollback command
There is no "rollback" Unix command.The "lost+found" directory has no functionality analogous to the Windows "recycle bin".  This directory is where the "fsck&q... We don't have any rollback command in unix. But we have one folder "lost+Find" in the root area. This is like windows recycle bin. Size of this folder is set by UNIX administrator.
In which of the following order are four sections of the file system in Unix arranged 1. Boot block,Super Block,I-list and Data block 2. Boot block,Data Block,Super block and I-list 3. Boot block,Data Block,I-list and Super block 4. Super block,Boot block,I-list and Data block

How will you mirror a volume and how will you find if a volume is mirrored ? lsvg �l (vol gp name)
We can find whether mirrored or not by seeing number of pps, if number of pps is double the size of pp size then it is mirrored. to mirror # mirrorvg vgname diskname
Portable UNIX
Why is UNIX more portable than other operating systems?
Unix operating system is written in C language, hence it is more portable than other operating systems, because of this it is most popular all over the world.
UNIX is portable because you can customize or configure it the way you want it and how you will use it.
Usage of source command in unix
What is the use of "source" command apart from running the script in current shell?
The soure command is used for two ways.

     1. If you want run the more than one command at the time. then you should write the commands in one file. which is run by source command.

    2. If you connect any database server through unix server. then you can run source command if any file contains more than one commands.
UNIX Command for Delay
•    give UNIX command to wait for a specified number of seconds before exit
•    Sleep n
•    'at' command is used for scheduling jobs not for delay
UNIX Commands questions
•    1. Why is the . not included in the path?2. How will you mirror a volume and how will you find if a volume is mirrored ? lsvg �l (vol gp name)3. A system is echoing the ping but not able to login via telnet why ?Etc /services etc/inetd.conf4. what is the migration path from 4.3 to 5.1 ? (or any versions)5. A system is able to ping within the network but not outside why ?6. What are the components of...
•    Telnet is not secured but SSH is secured. Telenet and FTP can be easily traced by hackers where as SSH (which uses SSL) cannot be easily traced.
How to concatenate two strings in UNIX

Var1=abc
var2=cde
var3=${var1}${var2}
echo $var3
Str1=abcde
fstr2=ghijklm
echo ${str1}$str2   
or
echo ${str1}ghijklm
Write command to delete all the files from a directory which have been created after a specified time.
•    find -name "*.dmp" -mtime +180 -exec rm -f {} ; The above one liner will delete the files after searching for the coredump files under the specified directory path which are older than 180 days
•    Try this find . -mtime 2 -print | xargs rmIt will work
Setting kernel parameters
kernel parameters can be set using sysctl utility.. or try using /etc/sysctl.conf
What is the unix command used for giving or changing the permissions for files and folders?
•    the best was is to use CHOWNExample:chown owner:group chown -R owner:group <---- This will change the owner and group of all the files inside the directory recursively.
•    chmod permission file_name/directory_name
How do you get current CPU utilization, memory and disk space usage in Linux/Unix?

•    We can find the CPU utilization by using topas command.and memory utilization by svmon command
What is the command in UNIX to see a list of opened files?
•    lsof   - List open files on the system. Normally, it only lists files you (or processes you own) have open; if run as root, it lists all open files.
What is the command to list files from directory in decreasing order of their file size.
•    Du /directory_path/ | sort –nr
•    Du -sk | sort –n
What does the following command do?cp $ABC/$SUP/xyz.tct .;?
•    This will copy the file xyz.tct from root directory ( / )  to present working directory.
•    This command will copy the file abc.txt (picked up from the location $ABC/$SUP/) to the current directory u are working on. The file created on the currect directory will also be of the same name abc.txt
•    How will u list the contents of parent directory from the current directory? What are the default system wide permissions for a file and directory? What is the default umask value?A user is not able to change the permission , What can it happen? What's the difference between ls -F , ls -p? If a file permission are 000, can the superuser still read and write to that file.? What's the command to remove the files without write permission? How will u make sure that no one can see the files which u had created? How will u change the permissions of a directory recursively? Any response will be greatly appreciated
1. Ans.==> ls ..
2. Ans.==> for file 644, for directory 755
3. Ans.==> 022
4. Ans.==> he might not owner of that object or the ownership has been changed.
5. Ans.==>
6. Ans.==>Yes
7. Ans.==> rm -f
8. Ans.==> the filename has to be started with "."
9. Ans.==> chmod -

How to import and export the data from databse using shell script
To import the data:
mysqldump -u username -p databasename >> databasenamedump.sql
To Export the data:
mysql -u username -p newdatabasename < databasenamedump.sql
Write a shell script to list only the hidden files in the current directories? What is the o/p of following command $a =*, echo $a, echo "$a"? Which of the following is allowed in an arithmetic involving expr instruction. [],{},()? If values "hi", "Hello","Bye","Good Bye" are supplied to the following statement what will be the o/p read n1,n2 , echo $n1 $n2? How do you know that how many commands can be stored in the buffer in one session?
Unix command to concatenate (attach) two strings?
•    There are two different ways to do the same.1. var1 = "first"var2 = "second"var3 = $var1$var2The only problem with the above solution is you can not attach the general text at the
•    Variable1="Open"Variable2="Systems"Variable3=$Variable1$Variable2echo $Variable3-- Output OpenSystems
How do you find OS block size in UNIX TRU64 
•    Solaris: df -g Linux: /sbin/dumpe2fs /dev/sdaX |grep 'Block size' 
Extracting File Name
•    Cat will give the full content of a file in one go.more will give the content of the file in page by page
What is the command to view the active vg?
•    HPUX:# vgdisplay If the VG is ACTIVE, you will get the output else an error message "vg not active".-RK
•    #lsvg -o (AIX)
What is relative path and absolute path?
•    Absolute path: Exact path from root directory to the target directory.Relative path: Path for current directory to target directory.
UNIX Password change issue
•    You can use the following command to change the password.Sudo chpasswd -cusername:passwordpress ctrl+d
Difference - Loading and Linking?
•    A linker takes several object files and libraries as input and produces one executable object file (or) Linking is simply the process of placing the address of a called function into the calling function's code. This is a fundamental software concept.

A loader loads an executable object file into memory, initializes the registers, heap, data, etc and starts the execution of the program.
How do you mount Linux partition on windows
•    In order to mount LINUX partitions on Windows, you need to use a third party software, Windows does not provide any inbuilt utility for this. Unlike "mount" in UNIX/LINUX Windows does not provide you with a utility to access any other file system.
Hello does anyone know how to do the following using some simple unix if possible:I have a file with the following info as comma separated. It shows username, id number and what subjects they are enrolled in. The subjects are separated by colons. UserName,ID,Subjectjsmith,235456939,MATH29879:PHYS45979jdoe,750378929,ENGL36899:JAPN92576I want it to have one username with one course per line. So that it would look like:jsmith,235456939,MATH29879jsmith,235456939,PHYS45979jdoe,750378929,ENGL36899jdoe,750378929,JAPN92576Does anyone have any ideas?Thnx-J
•    Cat |sed s/:/,/g|awk -F"," '{print $1","$2","$3;print$1","$2","$4}'

How to find some particular lines in unix Vi editor which starts with a particular word and end with another particular word?? For ex - There are 10 lines in the editor and only 4 lines start with the word APPLE and end with the word MANGO.Now how to find out these particular lines in Unix?
•    esc` then :/word-to-find then `enter`

What is meant by u-area? Where it resides? What does it contain?

The u area.
In addition to the text, data, and stack segment, the OS also maintains for each process a region called the u area (User Area). The u area contains information specific to the process (e.g. open files, current directory, signal action, accounting information) and a system stack segment for process use. If the process makes a system call (e.g., the system call to write in the function in main ), the stack frame information for the system is stored in the system stack segment. Again, this information is kept by the OS in an area that the process doesn't normally have access to. Thus, if this information is needed, the process must use special system call to access it. Like the process itself, the contents of the u area for the process are paged in and out bye the OS.
•    Every process has a private u area, yet the kernel acesses it as if there were only one u area in the system, that of the running process. The kernel changes its virtual address translation map according to the executing process to access the correct u area. When compiling the operating system, the loader assign the variable u, the name of the u area, a fixed virtual address. The value of the u area virtual address is known to other parts of the kernel, in particular, the module that does the context switch.
Open Source
What is the meaning of open source? How it is associated with the meaning of heavily documented?
•    Open Source Software refers to provision of source code for customization as per your need, for which good documentation is essential.

Also Detailed documentation about licencing type is expected to be included.
eg, GPLv2, GPLv3, Apache common Licence etc ...
What is semaphore?What is Monitor?
A hardware or software flag. In multitasking systems, a semaphore is a
variable with a value that indicates the status of a common resource. It's used
to lock the resource that is being used. A process needing the resource checks
the semaphore to determine the resource's status and then decides how to
proceed.
Where is kernel located in HP unix?
•    kernel will be middle layer,i.e between userlevel and hardware level layers.
•    The kernel is located in /stand
•     It is inside /stand directory with name of "vmunix".Grep
How to use logical AND in grep?
By logical "and" I presume you mean that you wish to see lines that contain both "expressionOne" AND "expressionTwo".

Just pipe the standard output of one "grep" command into the standard input of a second "grep" command.

E.g.:

echo "Good Bad and Ugly" | grep "Good" | grep "Bad"

will print the line.  It is, paradoxically, both "Good" AND "Bad".

echo "All Good Men Must Sleep" | grep "Good" | grep "Bad"

will print nothing.  "Good" AND "Bad" is false.

A thornier question (which you didn't ask) is how to do a logical "OR".
Why is the . not included in the path?

don't think there is any hard and fast rule that not to include "." in the Path variable. If you need it, then you can add and add the . at the end. Like /usr/sbin:/sbin:/usr/etc:.
Explain design philosophy of UNIX operating system and explain the mechanism of inter process communication and synchronisation.
The inter process communication is a way of communication between the processes. In UNIX these are achieved through pipes (named & unnamed pipes), semaphores, message queues, shared memory.
How to read error messages in /var/adm/messages when system is not booting?
•    If OS can't boot into multi-user level, I can try to boot the OS into single-user level.If I can't boot into single-user level, I wouldn't read the messages in /var/adm/messages.
Type in "dmesg" to read what you missed during the boot process.
What is Process Control board in UNIX?
Process Control Block in Unix is a data structure which is used to mange Processes. It contains following:1. PID2. Pointer to the next PCB3. Register Values4. Priority5. I/O information6. Process accounting information. 7. Adress Space.
What is redirection?
redirection in UNIX
it changes standard input in standard output
we can redirect our files accordingly
as
$cat my > you
so here i have redirected file (me) to u actually wt have done is i have change the standard input as well as standard output
here standard input is file MY
and standard output has been converted to file YOU
by default standard o/p is monitor
and standard i/p is keyboard
so check it
$cat my>you
What is a pipe and give an example?
A pipe is two or more commands separated by pipe char '|'. That tells the shell to arrange for the output of the preceding command to be passed as input to the following command. Example : ls -l | prThe output for a command ls is the standard input of pr. When a sequence of commands are combined using pipe, then it is called pipeline.
How to terminate a process which is running and the specialty on command kill 0?
•    Kill -0 : All processes in the current process group are signaled. Kill -0 commnd is use to sends signal to all process and group of process.
Kill 0  will delete all the processesThe Cost of storing a bit is minimum in 1. Cache 2. Register 3. RAM 4. Magnetic tape
Obviously it will be in 'Magnetic tapes' as it can be unlimited and cheaper.
UNIX questions
How do u configure the Disk?

Tell me Steps to configure the VG?

How do u add a new disk in VG?

What are the Attributes of LVM?

Describe about LVM Adva/Dis.Adv?

How do u find the fix is installed?

How to u extend the FS?

Attributes of FS?

List all the LV in system?

How do u find the PP size of the VG?

How do u create the pp size of 32 MB in VG?

What is the Limitation of VG?

How do u disable the paging space?

What is LPAR?

What is the difference between UNIX compress command and LINUX compress command ?I compressed a file in LINUX by using compress command, the file has been compressed successfully with the extension .gz. When i try to uncompress the file in unix, not able to uncompress the file.plz help me

•   
There is no compress command in  LINUX. we have to use ZIP for compressing and gunzip for uncompressing a file. in file extensions also we have difference
Where you have a file extension of .gz, it is normal to use the "gunzip" command to uncompress the file. Sounds like you compress command ran "gzip" to compress the file. What is the use of the command "ls -x chapter[1-5]"?
Ls stands for list; so it displays the list of the files that starts with 'chapter' with suffix '1' to '5', chapter1, chapter2, and so on.
Why linux operating system is virus free? What is the reason behind it to free from virus?
The Linux OS is not virus free. It is as susceptible to viruses as other operating systems. While the relative numbers of Linux viruses is small, the number of viruses written for Linux is growing as Linux comes into widespread use.
n Linus, the kernal is protected by the core and the application programes. Eve if there is any virus coming in linux has built in antivirus  application which which detect the virus and  protect the system from it.
What are your solution strategies for "Dining Philosophers Problem�?

Is it possible to restrict incoming message?

messages can be restricted by you with the help of 'mesg n', this will restrict the incoming of messages to your terminal, for again allowing messages for your terminal you can use 'mesg y'.
Unix & Aix

AIX is one of the favours of Unix and is developed by IBM.

 AIX stands for Advanced Interactive Executive.

 This name came because of an advanced feature(tool)  introduced in AIX called SMIT (System Management Interface Tool). It is a menu driven interface which allows to perforform most of the common system management functions with in one consistent environment.

Most of the administrative tasks can be performed through SMIT. The major difference lies in customization and security.
Difference between kill and kill -9

Kill      ---> generates SIGTERM signal requesting process to terminatekill -9 ---> generates SIGKILL signal for process to terminate immediately
What does the command “ $who | sort ‚logfile > newfile‚do?

Actually the command is who |sort - logfile >newfilethere should be a space between - and logfile.
How to save a path in command prompt to recall it later.

we have an additional command in AIX to obtaine previously used path or command at the command line without assigning that path to a variable

run set -o vi  command at command prompt.

this will open a new shell with vi editor enabled.

then press esc button to ensure that u r in command mode.
then press k key on the keyboard and so on .
these will recall ur previous commands.


Also we can use history command at command line to view all previously used commands or paths or open sh_history file in ur home directory.
Write a command to display a file�s contents in various formats?

To change in hexadecimal command :%!xxd in vim editor...and for return to character :%!xxd -r
What does command "kill -9" does ?


Inter process command

•    inter process command in UNIX be achieved by a)pipes b)messages c)semaphores d)shared memory e)all
•    ans-all

UNIX Maximum simultaneous logins
how many simultaneous logins are allowed in Linux/Solaris for a single user ?
What are Trace files and Log Files in Unix and How do they help in conducting back end testing?


If device driver is put inside RTOS Kernel or User Application, What are the advantages and disadvantages ? How can you debug

There are more disadvantages while putting device driver in User Application then RTOS. There will be more overhead, you have to restart the application for supporting your hardware which inturn depends on your device driver files. But in RTOS it should work fine.
 How many prompts are available in a UNIX system?
Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).
What is the use of crontab command in Linux Operating system?

•    Crontab is a very useful command used for scheduling purpose. If a person working inn Linux operating system wishes to schedule to run later they can achieve this by using the crontab command. Thus it is possible that each user working in the Linux operating system can define their own crontab. There are many options available with this crontab command. Some of them are namely:
•   
•    Crontab with –u option is used for specifying a username.

If this –u option is not specified then the user whoever is executing the command would be taken for crontab.
•   
•    Crontab with –l option is used to list the entries of current crontab
•   
•    Crontab with –r option is used to remove the current crontab.

Which of the following commands is not a filter?(a)man , (b) cat , (c) pg , (d) head?


What is the command one can use to list only the directory names?

•    ls –d /usr/exfor/
•    For a quick listing of Directories I use ls -d */.This lists all the dirs at the current file system level.  It doesn`t follow the leaf nodes down the dir structure.

What is the main purpose of using UNIX for the software testing process ? please explain ?

UNIX is also used by about 30% of the population using computers.  Remember not everyone likes windows or microsoft.
Explain Scheduling?

It is a process by which user work will proceed at the proper time, whether user is there or not.
What will happen when a user try to login after his home directory get full?

On Solaris CDE env, it simply takes your login id and pwd and comes out without throwing any error message.If you are on the console trying to telnet/ssh/rsh/ftp it will allow you to login.
Operating System Security?

Operating system security means in simple to secure your data from external attack, either from intruder or any damage.RegardsSafar

How to switch to a super user status to gain privileges?

su - is the command that is used to switch to a super user.After that it will ask for password of root.then you are super user.
What is Concurrency? Explain with example Deadlock and Starvation?


What is the difference between the below 2 commands:./myExeSh. /myExeShwhere myExeSh is my executable shell file.

What is the functionality of tar command

What is the difference between Daemon & Server process.

Where is the semaphore stored in UNIX operating system?
On linux machines you can view semaphore using command :-ipcs -sYou can delete semaphores using ipcrm command.
How do you rewind the tape to start position?
#mt rewind
What is the difference between the commands sleep, wait and killall?
sleep:

This command is used in UNIX operating system to suspend execution of the system for the specified time limit mentioned in it as parameter.
The general format of sleep command is
sleep no_of_seconds
The sleep suspends the execution of the shell in UNIX operating system for the no_of seconds specified.
For instance
sleep 5
The above suspend the execution of the shell in UNIX operating system for 5 seconds specified.
wait:

wait causes waiting of the process specified in parameter or the job specified in parameter to wait. If nothing is specified all jobs in pipeline are put to waiting state that is all current child process which are currently active are put to wait status. Wait also return the return status. The return status is generally the exit status of last job in the pipeline process which was put to waiting state. In case of scenario in which no job or process is specified the return status would be zero.
The general syntax of wait command in UNIX operating system is
wait n
where n is optional which denote the process or job
killall:

The command killall is used to kill processes which are active. The main aspect in this is killall command can be issued only by the super user
What happens when a compress command is used in UNIX system?
compress command is used for compressing a file that is for making the file size compact so that it becomes small. When a compress command is used in UNIX all the file attributes like the owner of the file and other things remain same except the file size is compressed and the extension of the file becomes .Z
The general syntax for compressing file is
compress filename
For instance if one like to compress the file named as Exforsys it can be done as follows:
compress Exforsys
The above is a generalized compress command without any options, There are many options available in compress command. Some of which are mentioned below namely:
•    compress with –c option
•    compress with –v option
compress with –c option:

When a –c option is used with compress command then the output is written to the display screen and so no .Z files are created.
compress with –v option:

-v option with compress command gives report on the file size by which the file has got compressed.
To add further to this related area of context there is another command called as uncompress which is used to uncompress the file.
Is it possible to create new a file system in UNIX?
Yes, �mkfs� is used to create a new file system.
How does the Kernel in a Linux system differ from a Windows Kernel

What is difference between fork() and vfork()?what is the difference between function call and system call?

What is result of commenting out of root in /etc/ftpd/ftpusers file ?

The root user would be allowed to ftp to the server. The /etc/ftpd/ftpusers file lists users that are disallowed from using ftp
The 'root' cannot access the remote system using FTP connection.
What is meant by shell layer manager?
Which file holds the list of users that are NOT allowed to use cron ?
Answer: /etc/cron.d/cron.deny

What will the following command do?
$ echo *It is similar to 'ls' command and displays all the files in the currentdirectory.
Write a command to kill the last background job?

To kill the last background job, the following command is used:$ kill $!The system variable $! stores the PID of the last background job.The other method is first find the PID using the ps command, then use kill command to do the job.
Where is kernel located in unix?

/stand directory name vmunix.
What is grep() command?

GREP: Global search a Regular Expression and Print it.It is used to select a word or group of words from a given file or directory etc.syntax: grep ""
How to delete cron tab entries of a particular ID?

What is Redirection?

Name the system calls used for process management?

Extensively used one are:ps -eafkillforkHow to debug parts of a program in UNIX environment using CORE DUMP generated?Where core dump generated for a program is stored?

What does the command “$ls | wc –l > file1” do?
Ls becomes the input to wc which counts the number of lines it receives as input and instead of displaying this count , the value is stored in file1.
What is the difference between cat and more command?
Cat displays file contents. If the file is large the contents scroll off the screen before we view it. So command 'more' is like a pager which displays the contents page by page.

How is the command “$cat file2 “ different from “$cat >file2

$cat file2 --- Shows the contents of the file file2$cat >file2 --- Since there is no input file specified, it takes the standard input and copies it to a new file named file2. If the file2 is already existing, it will over write the file.
Name the data structure used to maintain file identification?

�inode�, each file has a separate inode and a unique inode number. Explain the following commands?
$ ls > file1$ banner hi-fi > message$ cat par.3 par.4 par.5 >> report$ cat file1>file1$ date ; who$ date ; who > logfile$ (date ; who) > logfile
1.ls redirects the all files to file named file1
2.banner printd the contents inhigh font letters
3.cat appends the contents of 3 files to "report" file
4.Here cat replace file1 with itself
5.displays date and who also
6.date dislplys the date but who will be redirected to "logfile"
7.both files will b redirected (replaces previous contents") to logfile
How does one translate characters in UNIX operating system?

What is the use of make program in UNIX?

What is meant by Intermachine communication?
•    Just as the name depicts pipeline is the process in which when a pipe is set between two commands then the standard output from the first command is passed through the pipe specified to the second command and thus acts as an input to the second command. In other words the standard output of the first command is pipelined as standard input to the second command. This is done by using the symbol for pipeline as |. It is not necessary that the process of pipe is applied only for commands. That is one can even define the process of pipe between two programs where by the standard output of the first program is taken as standard input of the second program.
•   
•    Let us see this concept of pipeline with a small example:
•   
•    We know that who command in UNIX is used to display the list of users logged in. Suppose we like to get the output as sorted list of users logged in then we can achieve that by using the concept of pipeline as
•   
•   
•    who | sort
•   
•   
•    Thus the first command which is who gives output as list of users logged in which is pipelined to the second command sort as input and thus giving the list of sorted list of users logged in.

Why do Unix systems predominantly use text files?

Which command is used to delete all files in the current directory and all� its sub-directories?
Rm -r *
What is "Piping"?
Pipe accepts the output of one command, and feeds it as an input to the next command
.eg:
ls | wc –l
Output of 'ls' is fed as input to wc-l. Hence wc counts the number of lines in the result of ls.
How do i partition the disk under red hat linux?

What is difference between lilo and stub?
•   
STUB is A temporary implementaion of part of a program for debugging purposes.LILO (LInux LOader) is a boot loader for Linux.
How to password protect the group ?
You have to enter the password by editing the /etc/group file.
•    No command option for giving or changing password
Is it possible to count number char, line in a file; if so, How?
Yes, wc-stands for word count.
wc -c
for counting number of characters in a file.wc -l for counting lines� in a file
Give an example for a valid entry in a direct map
# vi /etc/auto_master/-
What is the command to add the swap file to the system’s swap space?

What are the Advantages of using concatenation in disksuite ?
•   
The Filesystem can be grow while they are mounted.
What is the significance of the “tee” command?
•    It reads the standard input and sends it to the standard output while redirecting a copy of what it has read to the file specified by the user.
•     tee - replicate the standard output
•     Syntax:-tee  [ -ai ]  [ file ... ]
•     -a        Append  the  output  to  the  files  rather   than
           overwriting them.
•     -i        Ignore interrupts.
•    The tee  utility will copy standard input to  standard  out-
put,  making  a  copy  in  zero or more files. tee  will not
buffer its output. The options determine  if  the  specified
files are overwritten or appended to.
Explain Sticky bit?
•    The ‘Sticky Bit’ is a permission bit that can be set on either a file or a directory.
•    If it is set on a file, then that file will remain in memory after execution, thus ’sticking’ in memory. This is useful when running a multi-user program (such as a bulletin board system that I ran once) to make the program execute faster for the next user. This was a common programming tactic earlier in the history of computer programming when speed and disk space were at a premium.
•    If the sticky bit is set on a directory, only the owner of files in that directory will be able to modify or delete files in that directory - even if the permissions set on those files would otherwise allow it.
•    It executes from user and behaves as it executing from the root.

What is Marshalling?
In a distributed environment, client sends its request as a bundle. its like adding header to the data. This process of bundling data is called marshelling.
 What is Semaphore?
A semaphore is a type of Interprocess communication resource used for synchronization and mutual exclusion between any two asynchronous processes.
Do you have idea about "Shell Job Control"?
ob control in Unix means controlling the execution of jobs. Using fg (foreground), bg(background), jobs, kill, nice etc.. you can actually control the priorities, order and the number of jobs which are being processed. The effective use of these commands is called Job control.
What are the difference between Daemons in Unix and service processes in Windows?
both are same. daemons are the background processes in unix. similarly background processes in windows are called as service agents or service processes.

Explain the following file systems: NTFS, Macintosh (HPFS), and FAT?
•    NTFS is a high-performance and self-healing file system proprietary to Windows XP 2000 NT, which supports file-level security, compression and auditing. It also supports large volumes and powerful storage solution such as RAID.
•    FAT system <THE FAT FILE SYSTEMS. FAT32 FAT16 FAT12 >
•    The File Allocation Table (FAT) file system is a simple file system originally designed for small disks and simple folder structures. The FAT file system is named for its method of organization, the file allocation table, which resides at the beginning of the volume. To protect the volume, two copies of the table are kept, in case one becomes damaged. In addition, the file allocation tables and the root folder must be stored in a fixed location so that the files needed to start the system can be correctly located.



How can you recognize a shell (C / Korn / Bourne) just by looking at the prompt?

•    For check current working shell is echo $0
•    To know the shell type the command - $echo $SHELL
Find inode Number
Ls -lrti filename |awk { print $1}
Read fname     #file name to be searched.p=`pwd`cd /l=`find -name $fname`l=`echo $l | ls -i`set $lecho "inode is $1"cd $p
What is difference between Process and a Job ?
Process is nothing but excution in program wheare as job is any task or work.
A process is a program in execution. And a Job is a task.


How to write a shell script ?

Write a shell script to find the smallest of three numbers that are read from the keyboard.
echo first_num
read first_num
echo second_num
read second_num
echo third_num
read third_num

if (first_num>second_num) then
if (first_num>third_num) then
echo $first_num is the biggest
else
echo $third_num is the biggest
elif
(second_num>third_num) then
echo $second_num is the biggest
else
echo$third_num is the biggest

or else we can use sort command
sort -r

What is the use of man command?
You can create a man command for your own scripts also. It requires a particular format for inside the file. It needs to be placed in particular directory to be readable by man command

How to write program to print descending order

#include <stdio.h>

main()

{

int i,n;

printf("Enter a number:");

scanf("%d",&n);

printf("The first %d odd numbers are:-");

for(i=1;i<=n;i=i+2)

{

    printf("

    %d",i);

    }

    }

Print numbers in the reverse order
1.           $echo "12345678" | rev
2.    $x="12345678";

3.    print reverse($x);


How to launch 5 diff application from 5 child process

What is the method by which we find the list of users logged on a server using telnet service?
On unix try 'who' command.
Who | grep -c telnet | awk {print($1)}
You can also use "finger"

What is inter-process communication facility?

•    Sockets won't come in Inter Process Communication.Inter Process communication means communication between the processes with in the same system.Sockets can communicate with the external systems

What are the benefits of creating links to a file?

•    To make the file more secure, if the original file get deleted accidently, then the link will be available there.

What is the concept of named pipe?
Named pipe is FIFO.FIFO pipe create syntax is mknod() or mkfifo().Main thing in pipe,we cannot see the created pipe any where in the system.Named pipe is a file persistent.
Named pipe is nothing but FIFO

Logging Script


What is the use of sleep() function?
Sleep() suspends execution for an interval
The sleep() function will cause the calling thread to be suspended from execution until either the number of real-time seconds specified by the argument seconds has elapsed or a signal is delivered to the calling thread and its action is to invoke a signal-catching function or to terminate the process. The suspension time may be longer than requested due to the scheduling of other activity by the system.

Pipeline of Commands
Use the tee command.who | tee  -a usere.uxtee -a : display the o/p on monitor and save (append) in the file also.—Shambhu

What is the command to find all of the files which have been accessed within the last one month?
find / -atime  -30
How to read and write of a open file?
To read from a file:=============== exec 5<&0 # standard input (your terminal) is denoted by file descriptor 0. It is assigned to 5 exec 0<&5="" reassigned="" terminalto="" write="" a="" file:="============" the="" terminal="" $line="">> samplefile # line is appended to samplefile done
What are the steps for locking a file?
It can be achieved by adding sticky bit to the directory

Dont give permissions to others or group by making it chmod 600 < filename >

Write a korn shell script for renaming the filenames of the files stored in a folder to lower case.
Tested script.#! /usr/bin/kshecho "start"for name in `ls -1`doecho "name $name"name1=`echo $name | tr [A-Z] [a-z]`;echo "name1 $name1"mv $name $name1;if [ -z $name ]thenexit;fidone



== Totally miscellaneous ==
* When debugging a core in gdb, what does the command `bt` give: core memory, heap usage, or calling stack?
* A user complains the web site is slow. What do you do?


Explain the unix file system?
There are three file system in UNIX as below:-1. Ordinary File System: contains only data2. Directory File System: contains other files and directories 3. Device File System: represents all hardware devices.

What are the possible return status of kill() command?
0 or 1; depending upon the arguments given to kill. to enforce killing use kill -9
How would you remove a semaphore / shared memory whose owner processes have died?
ipcrm -sem id ; for semaphores
ipcrm -shm id ; for shared mem


What is wildcard?
A wildcard character is a character that can be substituted for any of a well-defined subset of all possible characters. It may also be termed as a pattern-matching character.

For example, while referring to Unix filenames, a * character within a filename can be substituted for any set of characters at that location including zero to multiple characters, whereas a ? character can be substituted for any exactly one character at that location.
What is the use of waitpid?
The waitpid function call suspends execution of a process till a child specified by a process id in the argument has exited execution.
What is the method of setting an environment variable from a program?
Bourne shell:var=valueexport varKorn shell:export var=valueC-shell:setenv var value
What is meant by child process?
A child process is an almost exact copy of a process created by forking. The child process, however, has its own unique process id, and maintains a reference to the parent's process id.
What are the directory commands available in UNIX programming?
mkdir to create directory
cd to change directory
rmdir to remove directory (must be empty)
pwd to show present working directory
ls to list contents of a directory

What is the use of `du' utility?
du - summarize disk usage
The du utility writes to standard output the size of the file space
allocated to, and  the size of the file space allocated to each subdirectory of
the file hierarchy rooted in each of the specified files.

How would you create shared and dynamic libraries?
Well shared libraries have 2 types1) Static2) Dynamic.u can create library  byar cr -o sharedobj.a file1.o file2.o while file1 and file2 are headfiles (obj)now put this sharedobj.a into /usr/lib directory
What is stty used for?
stty is used to set your terminal options. Following are some of the typical examples1. stty echo -iuclc The above command will switch off character display on your screen and ignore any case differences (ignore upper case and lower case). This can be used in situation where password is read and should not get printed on screen2. stty -erase '^H' This will set the erase character for your terminal3. stty -intr '^c' This will set the execution interrupt as control+c key 4. stty -eof '^d' This will set the end of file character as control+d key
Give examples of how memory leaks can occur with c programs?
a memory leak occurs when mem is allocated but never freed . leakes can b caused by using malloc() without using any free().
but leaks can also be caused if a pointer to dynamically allocated memory is delleted overwritten , it can be caused when allocated mem is overwritten accidentally.
when we allocate memory dynamically, but it will loose the way to reach that memory then we are saying memory leak.

What type of scheduling is used in Unix?
Multi level Round Robin Scheduling algorithm
Explain difference between IPC mechanisms?
ipc mechanisms are mianly 5 types
1.pipes:it is related data only send from one pipe output is giving to another pipe input
to share resouses pipe are used
drawback:itis only related process only communicated
2.message queues:message queues are un related process are also communicate with message queues
drawback:user dont know which process curently works
share memory:memory shared in distributed systems some memory wants to share some files that time it is use full
semaphores
semaphore is integer type and in semaphore resourses give coding like negetive value means process are wants to use perticular resource waiting only
and 0 means no process is waiting
and 1 means one resource is free
and
sockets:sockets also ipc it is comunicate clients and server
with socket system calls connection oriented and connection less also
What are the differences between Shared and Dynamic libraries?
There are two ways in which a library is shared. Static and dynamic
In statically linked library the code of library is referenced at compile time and the result executable will be bigger.
I dynamically linked libraries the code of library is referenced at run time and resulting executable will be smaller. But drwaback is that at run time this will need the library to reference the library related symbols.
If you want to migrate a 32 bit application to a 64 bit os, what all would you check?

Shell Script to Add File Extension
Find . -name "filename" -exec sh -c mv $1 $1.new _ {} ;
Find . -name *.* -exec mv {} {}.xml ;

Write a shell script to identify the given string is palindrome or not?
#!/bin/bash
read -p "please enter the string" string
length=${#string}
while [ $length -gt 0 ]
do
rev_str=revs_str`echo $string|cut -c$length`
length=$length -1
done
echo "$rev_str"
How do u open a read only file in Unix?
Read filename
Cat filename
Want to delete the record if I find a word (dd)in the fixed length(5-7).
Sed /dd/d test.sh
How will you list only the empty lines in a file (using grep)?
$grep -n ^$ file1.txt
$grep -c "^$" file

Write a script to convert all dos style backslashes to unix style slashes in a list of files?write a script to list all the differences between two directories ?what is the command for to display the last newly appending lines of a file during appending data to the same file by same processes ?what is the command to display top most processes which has utilised most of the cpu?
dos2unix only removes the control-M characters at the end of the line.  You need to use sed to do the search and replace for '' to '/'.
Shell Script Validate Password
echo "enter the password"


read password


len="${#password}"





if test $len -ge 8 ; then





    echo "$password" | grep -q [0-9]


     if test $? -eq 0 ; then


           echo "$password" | grep -q [A-Z]


                    if test $? -eq 0 ; then


                        echo "$password" | grep -q [a-z]  


                          if test $? -eq 0 ; then


                           echo "Strong password"


                       else


                           echo "weak password include lower case char"


                       fi


                else


                   echo "weak password include capital char"


                fi


         else


           echo "please include the numbers in password it is weak password"  


         fi


    else


        echo "password lenght should be greater than or equal 8 hence weak password"


    fi

How would you get the character positions 10-20 from a text file?
Cut -c 10-20 filename
Search Data DD/MM/YYYY HH:MM:SS
#!/user/bin/sh
read -p $D
read -p $m
read -p $Y
read -p $H
read -p $M
read -p $S
datestring=$D/$m/$Y $H:$M:$S
sed -p 1,/$datestring/d filename > newfilename
mv filename file_backup
mv newfilename filename
How to find how many users have logged in and logged out in last five minutes using shell scripts?
How many users have logged in and logged out in last five or 10 minutes
Track and filter the output of the last command
By Typing Who commandFeb 04 2007
________________________________________
09:15 PM
________________________________________
6700
Views
19
Ans


Using Bourne shell : if you enter A B C D E F G.......................n after the command,how will you write a programme to reverse these positional parameters?
#!/bin/sh
#to print arguments in stdin in reverse order
for token in `echo $*| rev`
do
echo $token
done
Or,
Echo "$*" | rev
You have current directory containing set of directories which contain files.One file can reside in many directories.Write script which returns number of unique file names inall the subdirectories of a current dir.
find . -type f | awk -F / {print $(NF)} | sort | uniq
Ls * | grep -v ":$" | uniq -c | wc –l

How would you print just the 25th line in a file (smallest possible script please)?
Sed -n 25 p file.txt
Head -25 file.txt | tail -1

How to extract the second row of a text-file?
Sed -n 2p filename

How to delete a word from a file using shell scripting???
Sed s/pattern//g filename

How do you invoke and send mail from unix ?
Mailx -S ""
Or,
To print file as message
cat filename|mailx -s "subject" mail_id
to attach file
uuencode file_name file_name|mailx -s "subject" mail_id
How would you replace the n character in a file with some xyz?
Sed s/xyz/n/g filename

Print nth column of pattern

•    awk{printf $

What does $? return?
$? :- provide exit status of last executed command In case the last command successfully executed then the value is 0 , if its failed to execute then the value non-zero

No comments:

Post a Comment