Вы находитесь на странице: 1из 8

http://targetiesnow.blogspot.in/p/solution-manual-for.

html
Q 1File manipulation commands:
Creating Files
You can create new files either with applications (such as text editors) or by using the command
touch,
touch <filename>
or
cat>filename
Copying Files
cp <source> <destination>
Moving(or renaming) Files
To move files, use the mv command.
mv /home/jack/testfile /home/jack/testfile2
or, if you're already within /home/ac!"
mv testfile testfile2
Deleting Files and Directories
rm piglet.txt
rmdir new
Question no 2: Directory commands:
mdir - mae directories
mkdir [OPTION] DIRECTORY
Options
Create the DIRECTORY(ies), if they do not aready e!ist"
cd - change directories
#se $d to $han%e dire$tories" Type $d foo&ed 'y the name of a dire$tory to a$$ess that
dire$tory"
m!- change the name of a directory
Type m( foo&ed 'y the $)rrent name of a dire$tory and the ne& name of the dire$tory"
E!* m( testdir ne&namedir
pwd - print woring directory
&i sho& yo) the f) path to the dire$tory yo) are $)rrenty in"
rmdir - "emo!e an e#isting directory
rm -r
Remo(es dire$tories and fies &ithin the dire$tories re$)rsi(ey"
ls - $hort listing of directory contents
%ist the directories and files
Linux Shell
Shell is a user program or it's environment provided for user interaction. Shell is an command
language interpreter that executes commands read from the standard input device (keyboard)
or from a file.
The Linux/nix shell refers to a special program that allo!s you to interact !ith it by entering
certain commands from the keyboard" the shell !ill execute the commands and display its
output on the monitor.
Shell file extension file.sh
How the shell executes commands
#hen the shell has processed a command line and is left with a name that is not a built$in
command, the name of a function, or a second or subse%uent command in a pipeline, it chec!s
the directories listed in your PATH environment variable for a file that matches that name and
on which the executable permission is set for users in your category.
&f such a file exists and is an executable binary file (that is, a program that has been compiled
into machine code), the shell forks' that is, it creates a copy of itself (a ((child'' process) in the
computer's memory (see fork ()) for a list of the characteristics inherited by a child process from
its parent).
The child process then execs the binary file' that is, it loads a copy of the binary file's instructions
in place of its own, and begins to execute it. #hen a shell process execs another process, the new
process completely replaces the shell process in the computer's memory. The parent shell
remains in memory, and waits until the child process terminates before it resumes operation.
&f the file that the shell finds is not a binary file, a different course of events occurs. The shell
for!s a child shell that automatically opens the file and begins to interpret it, one line at a time, as
if each line is being typed on the shell's standard input. This is why such a text file is called a
shell script' it is literally a script of actions to be carried out by the subshell.
*ote that the output of a script that runs in a subshell is not automatically available to the parent
shell' while the subshell ((inherits'' (that is, receives a copy of) the environment of its parent, the
parent does not experience any changes that the subshell ma!es to its environment. )o if you use
a script to set a variable, the variable will not be present in the parent shell's environment.
fork(2)
Name
fork # create a child process
Synopsis
#include <unistd.h>
pidt fork(void)!
Description
fork() creates a ne! process by duplicating the calling process. The ne! process$ referred to as
the child$ is an exact duplicate of the calling process$ referred to as the parent$ except for the
follo!ing points%
&
The child has its o!n uni'ue process ()$ and this *() does not match the () of any
existing process group (setpgid(2)).
&
The child's parent process () is the same as the parent's process ().
+ssignment *age no ,
- .c) OSQPend()
sed !hen a task !ants to receive messages from a message 'ueue. The messages are sent
to the task via the message 'ueue either by an (S/$ or by another task using the OSQPost()
call. The messages received are pointer#si0ed variables$ and their use is application specific. (f
at least one message is already present in the message 'ueue !hen OSQPend() is called$ the
message is retrieved and returned to the caller.
Prototype
void OSQPend (OS!Q p!"#
OS!$%&' timeout#
OS!OP$ opt#
OS!(S)!S%*+ p!msg!si,e#
&P-!$S p!ts#
OS!+.. p!err)
OSQPost()
Skip to end of metadata
1o to start of metadata
Description
)ends a message to a tas! through a message %ueue. + message is a pointer$si,ed variable, and
its use is application specific. &f the message %ueue is full, an error code is returned to the caller.
&n this case, OSQPost() immediately returns to its caller, and the message is not placed in the
message %ueue.
void OSQPost (OS!Q p!"#
void p!void#
OS!(S)!S%*+ msg!si,e#
OS!OP$ opt#
OS!+.. p!err)

Вам также может понравиться