UNIT 2
1. What is process?
Ans: - A process is defined as an entity which represents the basic unit of work to be
implemented in the system.
2. What are background and foreground process?
Ans: -
Foreground Process: - Every process when started runs in foreground by default
receives input from the keyboard and send output to the screen.
Background Process: - It runs in the background without keyboard input and waits till
keyboard input is required. Thus, other processes can be done in parallel with the
process running in background since they do not have to wait for the previous process
to be completed.
3. Different types of process.
Ans: -
1. Parent and child process: - The 2nd and 3rd column of the ps – f command shows
   process id and parent’s process id number. For each user process there’s a parent
   process in the system, with most of the commands having shell as their parent.
2. Zombie and Orphan process: - After completing its execution a child process is
   terminated or killed and SIGCHLD updates the parent process about the termination
   and thus can continue the task assigned to it. But at times when the parent process is
   killed before the termination of the child process, the child processes become orphan
   processes, with the parent of all processes “init” process, becomes their new ppid. A
   process which is killed but still shows its entry in the process status or the process
   table is called a zombie process, they are dead and are not used.
3. Daemon process: - They are system-related background processes that often run
   with the permissions of root and services requests from other processes, they most
   of the time run in the background and wait for processes it can work along with for
   ex print daemon.
4. What are internal commands and external commands?
Ans: -
 Internal Command: - Commands which are built into the shell. For all the shell built-
  in commands, execution of the same is fast in the sense that the shell doesn’t have to
  search the given path for them in the PATH variable and also no process needs to be
  spawned for executing it. Examples: source, cd, fg etc.
 External Command: - Commands which aren’t built into the shell. When an external
  command has to be executed, the shell looks for its path given in PATH variable and
   also a new process has to be spawned and the command gets executed. They are
   usually located in /bin or /usr/bin. For example, when you execute the “cat”
   command, which usually is at /usr/bin, the executable /usr/bin/cat gets executed.
5. What is system call? Write down the function of the following system call
   i)     Fork (): - It creates a new process by duplicating the calling process. The new
          process is referred to as the child process. The calling process is referred to as
          the parent process. The child process and the parent process run in separate
          memory spaces.
   ii)    Exec (): - exec command in Linux is used to execute a command from the bash
          itself. This command does not create a new process it just replaces the bash
          with the command to be executed. If the exec command is successful, it does
          not return to the calling process.
   iii)   Wait (): - wait is built-in command of Linux that waits for completing any
          running process. Wait command is used with a particular process id or job id.
          When multiple processes are running in the shell then only the process id of
          the last command will be known by the current shell.
6. Write down the uses of the following command?
    pwd: -
    ls: - Lists files in current directory
    cd: - Move back one directory
    mkdir: - Make a directory called graphics
    rmdir: - Remove directory
    cp: - Copy file into directory
    rm: - Remove or delete file
    mv: - Move or rename files
    more: - Look at file, one page at a time
    lpr: - Send file to printer
    man: - Online manual (help) about command
    ps: - List all running processes by
    chmod: - change file permissions read only
    grep: - Find which files contain a certain word
    passwd: - Change passwd
    kill: - kill process
    gcc: - Compile a program written in C or Compile a program written in C++
    mail: - Send files by email to someone
    telnet: - Open a connection to vortex
    gzip: - Compress file
    ftp: - Upload or download files