Shell Processes   «Prev  Next»
Lesson 9

Processes and Unix Shell Script Conclusion

This module discussed how to determine your login shell, run a new shell interactively from the command line, and run a shell script using three different techniques. You also learned what a process is, the relationship between parent and child processes, and that parent processes pass their exported variables down to their children. Finally, you learned how the PATH variable affects your scripts and how to redefine the PATH in a shell script.

Determine login shell and run a new shell interactively

Here's how you can achieve both tasks:
  1. Determine your login shell: You can use the environment variable $SHELL to determine your login shell. Here's the command:
    echo $SHELL
    

    This will print the path to the shell executable that your system uses for your login sessions. Common shells you might encounter include bash (Bourne Again SHell), sh (Bourne Shell), csh (C Shell), and ksh (Korn Shell).
  2. Run a new shell interactively: There are two main ways to run a new shell interactively from the command line:
    a) Using the `sh` command:
    The `sh` command is a symbolic link that typically points to the default login shell on your system. You can use it to launch a new instance of your login shell. Here's the command:
    sh
    

    This will start a new instance of your login shell, providing you with a new interactive session.
    b) Using the shell name directly:
    If you know the name of your login shell (e.g., bash, ksh), you can execute it directly to start a new interactive session:
    bash  # Assuming bash is your login shell
    

    Replace `bash` with the actual name of your login shell as identified in step 1.

Both methods will achieve the same outcome - launching a new interactive session with your login shell. The first method using `sh` might be more portable across different systems, while the second method using the specific shell name might be more explicit if you know your login shell for sure.


Key Commands

This module introduced you to the following commands:
  1. ps
  2. ps –f
  3. /bin/sh
  4. /bin/csh
  5. /bin/ksh

Glossary terms

This module introduced the following terms:
  1. process: A process, in simple terms, is an instance of a running program. The operating system tracks processes through a five-digit ID number known as the pid or the process ID. Each process in the system has a unique pid.
  2. shell prompt: The shell prompt (or command line) is where one types commands. When accessing the system through a text-based terminal, the shell is the main way of accessing programs and doing work on the system.
  3. interactive shell: An interactive shell is simply any shell process that you use to type commands, and get back output from those commands.
  4. command line: The command line is a text interface for your computer. It is a program that takes in commands, which it passes on to the computer's operating system to run. From the command line, you can navigate through files and folders on your computer, just as you would with Windows Explorer on Windows or Finder on Mac OS.
  5. command line interface: A CLI (command line interface) is a user interface to a computer's operating system or an application in which the user responds to a visual prompt by typing in a command on a specified line, receives a response back from the system, and then enters another command.
  6. foreground process:Foreground-background is a scheduling algorithm that is used to control an execution of multiple processes on a single processor.
  7. background process:A background process is a computer process that runs behind the scenes and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification.
  8. child process: A child process in unix is a process created by another process (the parent process). This technique pertains to multitasking operating systems, and is sometimes called a subprocess or traditionally a subtask.
  9. parent process:a parent process is a process that has created one or more child processes.
  10. startup file:
    sh
    

Startup (in this order):Upon termination:
/etc/profile (login shells)Any command or script specified using the command:
  
trap "command" 0
.profile (login shells)

In the next module, you will learn to embed one UNIX command inside another. This technique is referred to as embedded command execution.

Shells Processes - Quiz

Click the link below to test your knowledge of processes and shells.
Shells Processes - Quiz

SEMrush Software 9 SEMrush Banner 9