Sie sind auf Seite 1von 4

1A) % mkdir training

% cd training

Now we are in training directory.now type the following command

% mkdir level 1

% mkdir level2

% mkdir cep

now change directory to level 1 by following command

% cd level1

now type following command

% mkdir sdp

% mkdir re

% mkdir se

From the directory se to reach the home directory in one step just type cd command at %
prompt.it
will direct us to the home directory of the user and to navigate to the subdirectory ‘sdp’ in
one step
type following command at % prompt

% cd ~/training/level1/sdp

2). How will you copy a directory structure dir1 to dir2 ? (with all the
subdirectories)

Ans- % cp -r /dir1 /dir2

3). How can you find out if you have the permission to send a message?

Ans- % ls -l
If, in the output, we get; -rw------- , then only the owner have the right to send the
message, while
Others can't

4). Find the space occupied ( in Bytes) by the /home directory including all its
subdirectories.

Ans- % du -b -s .

5). What is the command for printing the current time in 24-hour format?

Ans- % date

6). What is the command for printing the year, month, and date with a horizontal
tab between the fields?

Ans- % date +"%y"%'\t'"%m"%'\t'"%d "

7). Create the following files: chapa, chapb, chapc, chapd, chape, chapA, chapB,
chapC, chapD, chapE,chap01, chap02, chap03, chap04, chap05, chap11, chap12,
chap13, chap14, and chap15.

Ans- touch chapa chapb chapc chapd chape chapA chapB chapC chapD chapE chap01
chap02 chap03
chap04 chap05 chap11 chap12 chap13 chap14 chap15

8). With reference to question 7, What is the command for listing all files ending in
small letters?

Ans- % ls | egrep [a-z]$

or type this command

% find . -name "*[a-z]"

9). With reference to question 7, What is the command for listing all files ending in
capitals?

Ans- % ls | egrep [A-Z]$

or type this command

% find . -name "*[A-Z]"

10). With reference to question 7, What is the command for listing all files whose
last but one character is 0?
Ans- % find . -name "*0?"

11). With reference to question 7, What is the command for listing all files which
end in small letters But not ‘a’ and ‘c’?

Ans- % ls | egrep [a-z]$ | egrep -v [a]$ | egrep -v [c]$

or type this command

% find . -name "*[a-z]" -not \( -name "*a" -o -name "*c" \)

12). In an organisation one wants to know how many programmers are there. The
employee data is stored in a file called ‘personnel’ with one record per employee.
Every record has field for designation.How can grep be used for this purpose?

Ans- % grep -ic programmer personnel

13). In the organisation mentioned in question 12 how can sed be used to print only
the records of all employees who are programmers.

Ans- % sed -n '/programmer/p' < personnel

14). In the organisation mentioned in question 12 how can sed be used to change the
designation ‘programmer’ to ‘software professional’ every where in the ‘personnel’
file

Ans- % sed 's/programmer/software professional/g' < personnel

15). Find out about the sleep command and start five jobs in the background, each
one sleeping for 10minutes.

Ans- % sleep - delay for a specified amount of time.

sleep NUMBER[SUFFIX]...

sleep OPTION

DESCRIPTION

Pause for NUMBER seconds. SUFFIX may be `s' for seconds (the default),`m' for
minutes, `h' for hours
or `d' for days. Unlike most implementations that
require NUMBER be an integer, here NUMBER
may be an arbitrary floating point number. Given two or more arguments, pause for the
amount of time
specified by the sum of their values.

To start five jobs in the background, each one sleeping for 10 minutes, give the following
command
5 times

sleep 10m &

16). How do you get the status of all the processes running on the system? i.e. using
what option?

Ans- A common and convenient way of using ps to obtain much more complete
information about the
processes currently on the system is to use the following:

% ps -aux | less

The -a option tells ps to list the processes of all users on the system rather than just those
of the
current user, with the exception of group leaders
and processes not associated with a terminal.
A group leader is the first member of a group of related processes.The -u option tells ps
to provide
detailed information about each process. The -x option adds to the list processes that have
no
controlling terminal, such as daemons, which are programs that are launched during
booting (i.e.,
computer startup) and run unobtrusively in the background until they are activated by a
particular event
or
condition.

Das könnte Ihnen auch gefallen