1)Using the commands PS, cut, tr and kill, along with pipes, write a command that will find all sleep processes running on the system and kill them?
ps: check process status
Syntax: ps ?option
Option:
e: list all currently running processes (A for Linux)
f: gives full listing (give ancestry for Linux)
l: gives long listing
u username: list processes for the user only
S: sleeping
O: running
R: on run queue
Z: zombie (parent didn’t wait for death of its child
T: stopped or suspended
2) Difference Between Grep and Find command ?
Find command is used to search for a file with a specific file name in a set of files.
Syntax: find .-name "fileE" -print
grep command is used to search pattren within a file.
Syntax: grep "pattren" filename
3) Which of the following commands is not a filter man , (b) cat , (c) pg , (d) head
man
A filter is a program which can receive a flow of data from std input, process (or filter) it and send the result to the std output.
4) In UNIX 50 records are there,i want to retrieve the 20-30 records & iwant 23 record which commands we are using?
cat filename | head -n | tail +k
5) Write a command to display a file?s contents in various formats?
$od -cbd file_name
c - character, b - binary (octal), d-decimal, od=Octal Dump.
6) What are the processes that are not bothered by the swapper? Give Reason.
Zombie process: They do not take any up physical memory.
Processes locked in memories that are updating the region of the process.
Kernel swaps only the sleeping processes rather than the ?ready-to-run? processes, as they have the higher probability of being scheduled than the Sleeping processes.
7) Which command is used to delete all files in the current directory and all its sub-directories?
rm -r *
8) 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.
9) Construct pipes to execute the following jobs.
1. Output of who should be displayed on the screen with value of total number of users who have logged in displayed at the bottom of the list.
2. Output of ls should be displayed on the screen and from this output the lines containing the word ?poem? should be counted and the count should be stored in a file.
3. Contents of file1 and file2 should be displayed on the screen and this output should be appended in a file. From output of ls the lines containing ?poem? should be displayed on the screen along with the count.
4. Name of cities should be accepted from the keyboard . This list should be combined with the list present in a file. This combined list should be sorted and the sorted list should be stored in a file ?newcity?.
5. All files present in a directory dir1 should be deleted any error while deleting should be stored in a file ?errorlog?
10)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 | pr
The 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.
11)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
12) 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
13) 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
14) How to terminate a process which is running and the specialty on command kill 0?
With the help of kill command we can terminate the process.
Syntax: kill pid
Kill 0 - kills all processes in your system except the login shell.
15) 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
16) Explain about sh?
Sh is the command line interpreter and it is the primary user interface. This forms the programmable command line interpreter. After windows appeared it still retained the programmable characteristics.
17) Explain about chmod options filename?
This command allows you to change, write, read and execute permissions on your file. Changes can be done to the file system but at times you need to change permissions for the file systems. At times files should be executable for viewing the file
18) Explain about lpr filename?
This command is used to print a file. If you want to change the default print you can change the printer by using the P option. For double sided print you can use lpr-Pvalkyr-d. This is very useful command in UNIX present in many packages
19) Brief about the command ff?
This command finds files present anywhere on the system. This command is used to find document location where you forgot the directory in which you kept the file but you do remember about the name. This command is not restricted in finding files it displays files and documents relevant to the name.
20) Brief about ftp hostname?
This command lets you download information, documents, etc from a remote ftp. First it is important to configure an FTP for the process to begin. Some of the important commands relevant to the usage of FTP are as follows get, put, mget, mput, etc. If you are planning to transfer files other than ASCII defined it is imperative to use binary mode.
21) 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.
22) Explain the steps that a shell follows while processing a command.
After the command line is terminated by the key, the shel goes ahead with processing the command line in one or more passes. The sequence is well defined and assumes the following order.
Parsing: The shell first breaks up the command line into words, using spaces and the delimiters, unless quoted. All consecutive occurrences of a space or tab are replaced here with a single space.
Variable evaluation: All words preceded by a $ are avaluated as variables, unless quoted or escaped.
Command substitution: Any command surrounded by backquotes is executed by the shell which then replaces the standard output of the command into the command line.
Wild-card interpretation: The shell finally scans the command line for wild-cards (the characters *, ?, [, ]). Any word containing a wild-card is replaced by a sorted list of filenames that match the pattern. The list of these filenames then forms the arguments to the command.
PATH evaluation: It finally looks for the PATH variable to determine the sequence of directories it has to search in order to hunt for the command.
23) What is relative path and absolute path.
Absolute path : Exact path from root directory.
Relative path : Relative to the current path.
24) Write a command to kill the last background job?
Kill $!
25) Is ?du? a command? If so, what is its use?
Yes, it stands for ?disk usage?. With the help of this command you can find the disk capacity and free space of the disk
26) How many prompts are available in a UNIX system?
Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).
27) How does the kernel differentiate device files and ordinary files?
Kernel checks 'type' field in the file's inode structure.
28) How to switch to a super user status to gain privileges?
Use ?su? command. The system asks for password and when valid entry is made the user gains super user (admin) privileges.
29) How is the command ?$cat file2 ? different from ?$cat >file2 and >> redirection operators ?
is the output redirection operator when used it overwrites while >> operator appends into the file.
30) What will the following command do?
$ echo *
It is similar to 'ls' command and displays all the files in the current
directory.
31) What is redirection?
Directing the flow of data to the file or from the file for input or output.
Example : ls > wc
32) Explain about gzip filename?
Gzip filename is used to compress the files so that those files take up less space. The size of the file actually gets reduced to half their size but they might also depend upon about the file size and nature of the file systems. Files using gzip file name end with .gz.
33) Explain about lprm job number?
This command is used to remove documents from the printer queue. The job number or the queue number can be found by using lpq. Printer name should be specified but this is not necessary if you want to use your default printer.
34) Explain about the command elm?
This command lets you to send email message from your system. This command is not the only one which sends email there are lots of other messenger systems which can facilitate the process of sending a mail. This command behaves differently on different machines
35) Brief about the command kill PID?
This command ends the process to which it was assigned (ID). This command cannot be used in multi systems in the network. ID can be obtained by the command ps. This command ignores completely the state at which the process is it kills the process
36) Brief about the command nn?
This command allows you to read the news. First you can read about the local news and then the remote news. "nnl? Command makes or allows you to read local news and nnr command is used to read remote news. Manual and help information is available with many popular packages.
37) 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
38) Is it possible to create new a file system in UNIX?
Yes, ?mkfs? is used to create a new file system.
39) 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.
40) State and explain about features of UNIX?
UNIX operating system originally was developed in 1969. This is an open source operating system developed by AT&T. It is widely used in work stations and servers. It is designed to be multi tasking, multi user and portable. UNIX has many several components packed together.
41) Brief about finger username?
This command is used to give information about the user; it gives out a profile about the user. This command is very useful for administrators as it gives the log information, email, current log information, etc. finger also displays information such as phone number and name when they use a file called .plan.
42) 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
43) Name the data structure used to maintain file identification?
?inode?, each file has a separate inode and a unique inode number.
44) Explain about refer?
Refer was written in Bell Laboratories and it is implemented as a troff preprocessor. This program is used managing bibliographic references and it is used to cite them in troff documents. It is offered in most of the UNIX packages. It refers with text and reference file
45) Explain about document formatting?
UNIX systems were primarily used for typesetting systems and document formatting. Modern UNIX systems used packages such as Tex and Ghostscript. It uses some of the programs such as nroff, tbl, troff, refer, eqn and pic.Document formatting is very used because it forms the base of UNIX.
46) Is it possible to restrict incoming message?
Yes, using the ?mesg? command.
47) Explain about system and user utilities?
There are two utilities they are system and user utilities. System utilities contain administrative tools such as mkfs, fsck, etc. Where as user utilities contain features such as passwd, kill, etc. It basically contains environment values.
48) Explain about the command lynx?
This command helps you to browse web from an ordinary terminal. Text can be seen but not the pictures. URL can be assigned as an argument to the G command. Help section can be obtained by pressing H and Q makes the program to quit.
No comments:
Post a Comment