6
Assignment No: 01 1. Using the following Directory tree stru cture, i f IT is your Home directory,: Which command do use to navigate to: Bsc-IT directory? Which command is used to d isplay your current directory? Which command is used to d irectly navigate to root directory from BSc-IT directory? Which command is used to create a new directory in BSc-IT called UNIX?  Ans: Which command do use to navigate to: Bsc-IT directory? : cd BSc-IT Which command is used to d isplay your current directory? pwd Which command is used to d irectly navigate to root directory from BSc-IT directory? : cd /   Which command is used to create a new directory in BSc-IT called UNIX? mkdir UNIX Root IT MBA MCA Finance  Marketing BSc-IT UNIX

Assignment No 51

Embed Size (px)

Citation preview

8/7/2019 Assignment No 51

http://slidepdf.com/reader/full/assignment-no-51 1/6

Assignment No: 01

1. Using the following Directory tree structure, if IT is your Home directory,:

Which command do use to navigate to: Bsc-IT directory?

Which command is used to display your current directory?

Which command is used to directly navigate to root directory from BSc-IT directory?

Which command is used to create a new directory in BSc-IT called UNIX?

 Ans:

Which command do use to navigate to: Bsc-IT directory? :

cd BSc-IT

Which command is used to display your current directory?

pwd

Which command is used to directly navigate to root directory from BSc-IT directory? :

cd /

 

Which command is used to create a new directory in BSc-IT called UNIX?

mkdir UNIX

Root

IT MBA

MCA Finance 

MarketingBSc-IT

UNIX

8/7/2019 Assignment No 51

http://slidepdf.com/reader/full/assignment-no-51 2/6

2) Use cat command to:

Display text ³Welcome Home´ on your screen

Redirect the text ³Welcome Home´ to file called file-1 

 Append text ³Friends´ to the contents of file-1

 Ans:

$ cat >file-1Welcome HomeCrlt +d

$ Cat >>file-1FriendsCrlt +d

3) Which command is used to search following patterns in file by name file-1: ³TENDULKAR,´ 

³tendulkar,´  ³TeNdUlKar´? 

 Ans:$ cat file-1|grep TENDULKAR 

$ cat file-1|grep tendulkar 

$ cat file-1|grep TeNdUlKar 

You can search with grep ±I since spelling is same and with grep ±I it ignores case-

senstive.you can also create patterfile and you can use grep ±F patternfile

8/7/2019 Assignment No 51

http://slidepdf.com/reader/full/assignment-no-51 3/6

 

Assignment No: 02

1. Define Process. Which is the command used to find out currently executing Process in

UNIX?

 Ans: When you execute a program the scheduler submits your process to aqueue called process queue. At this instant the process is said to be insubmit state. Once submitted the process waits its turn in the queue for some time. At this stage the process is said to be in hold state. As the processadvances in the queue at some instant it would become the next

one in the queue to receive CPU attention. At this stage it is in ready state.Finally the process gets the attention of CPU and starts getting executedand thereby attains the run state.

In the middle of this execution it might so happen that the time slice allottedto this process gets over and the CPU starts running another process. Atsuch times the old process is returned to the ready state and is placed backin the process queue. As the CPU diverts its attention to the new process allthe necessary parameters of the old process are saved for retrieval whenits next time slice arrives. The old process will now be in ready state waitingfor its next time slice to arrive.

Some processes might be required to do disk input/output. Since I/O is aslow operation the CPU can¶t lie idle till the time I/O is over. Therefore, suchprocesses are put in wait state until their I/O is over and are then placed inthe ready state.

 A process whose execution comes to an end goes into complete state andis then removed from the process queu

ps command is used to know which process is running. With options along with ps commandyou can find more details of particular process.

2) What is the output of :

$ ps-e

$ ps-a commands

 Ans: -

$ ps ±e 

PID TTY TIME COMMANDO ? 0:00 sched 

1 ? 0:01 init 

2 ? 0:00 vhand 

8/7/2019 Assignment No 51

http://slidepdf.com/reader/full/assignment-no-51 4/6

3 ? 0:00 bdflush

487 01 0:01 sh288 02 0:01 sh

Here, -e stands for every process running at that instant. Note the PID of theprocess sched. This is the scheduler that we talked about and is the first

process that gets launched when the machine is booted. sched processgives birth to the initialiser process /etc/init . That¶s the reason why PPID of /etc/init would be 0. init is a file on disk present in the /etc directory. Thevhand process is the µvirtual memory handler¶ and the task cut out for it is toswap active processes between memory and disk as they run or wait their turn in the queue to be processed by the system. Since vhand is launched

after init its PID is 2. Another process of interest is bdflush standing for buffer to disk flush and is responsible for disk I/O. When we attempt to storesomething to the disk first it gets stored in a buffer in memory. When thebuffer gets full its contents are then flushed (emptied) to the disk.

ps ±a :

To find out which processes are running for the other users who havelogged in execute the ps command with the -a option, , -a standing for processes of all the users.$ ps -aPID TTY TIME COMMAND2269 3a 0.05 sh2396 3a 0.00 ps-a2100 3b 0.00 sh2567 3b 0.00 vi

3) Which command is used to transfer a Foreground process to Background? Give one

example. ?.

 Ans: -

To run a process in the background, Unix provides the ampersand (&) symbol. While executing a command, if this symbol is placed at the end of the command then the command will be executed in the background. When you run a process

in the background a number is displayed on the screen. This number is nothing but, the PID of the process that you \have just executed in the background. For example;

$ sort employee.dat > emp.out &17653

$

8/7/2019 Assignment No 51

http://slidepdf.com/reader/full/assignment-no-51 5/6

 

4). Say you have three Process P 1, P 2 and P3 running in background. You want to assign

priorities to them, which command is suitable give its syntax?

 Ans:-

Processes in the UNIX system are usually executed with equal priority. Thisis not always desirable since high-priority jobs must be completed at theearliest. UNIX offers the nice command, which IS Used with the & operator to reduce the priority of jobs. More important jobs can then have greater access to the system resources (being ³nice´ to your neighbours).To run a job with a low priority, the command name should be prefixed with

nice P1 -1 uxmanual &

Nice value range from 0 to 39, and commands run with a nice value of 20 in theBourne shell, a

higher nice value meaning a lower prioritoy.nice reduces thebpriority of any process by 10 units,

raising its nice value to 30. The amount ofreduction can also be specified with the ±n option:

Nice ±n 15 wc -1 uxmanual&

5). Which command is used to:

Fetch names from a file Name.txt sort them and remove any duplicate entries.

 Ans:-

$ sort ±u Name.txt 

6). Which commands are used to carry out following operations in vi- Editor:

To save a file

To start editing a file

To save and Quit a file

To quit without saving (Forced quit) 

 Ans:-

1 :w filename

2 :i

3 : wq

4 : q!

8/7/2019 Assignment No 51

http://slidepdf.com/reader/full/assignment-no-51 6/6