Sunday, November 10, 2019

fork() - Theory


fork() is used create a new child process.
Ø  No arguments
Ø  Process ID of the child process
Ø  After the execution of fork() command both parent & child processes are starting their execution from the next line.

Conditions of  fork()
Ø  fork() > 0 -: not only a child process but also a parent process (Successfully child process created.)
Ø  fork() == 0 -: a child process (Successfully child process created.)
Ø  fork() < 0 -: error in memory allocation (Unsuccessful child process)

Example:



Access permission


1.       chmod
Type
Access permission
User
Group
Other
Directory
d
rwx
r-x
r--
File
-
r-x
r-x
r--
command
u+(access per.)
g+(access per.)
o+(access per.)


Description
Letter representation
Numerical value
readable
r
4
writable
w
2
executable
x
1

Ø  chmod numericalValue filename.fileFormat >>>Ex: chmod 777 file1.txt
Ø  chmod command+letterRepresentation filename.fileFormat >>>Ex: chmod g+w file1.txt

2.       chwon
Ø  chown -R userName:groupName directoryName -: to set a user from the related group as the owner of related directory
>>>Ex: chown -R daniel:admins dir1


Users and Groups



Ø  groupadd groupName -: to create a group
Ø  useradd -G groupName userName -: to add a user to the related group
Ø  passwd userName  -: set a password to the related user
Ø  usermod -a -G  groupName userName -: to add a existing user to a existing group
Ø  login
press “Enter”
give username and password -: to login as related user
Ø  logout -: logout from the user
Ø  grep groupName /etc/group -: to search a group
Ø  userdel userName  -: to remove a user
Ø  groupdel groupName -: to remove a group


fork() - Theory

fork() is used create a new child process. Ø   No arguments Ø   Process ID of the child process Ø   After the execution of fork() command ...