Linux Job Management Notes: Difference between revisions

From ITCwiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 63: Line 63:
''Stage 2''
''Stage 2''
This image can consist of two types of images, image 1 is an optional image that understands the semantics of one file system or the other, and has a name like file system name_stage1_5 this image serves as a bridge between stage 1 and stage 2. At this point, either directly form stage 1 or from image 1.5 stage 2 image is loaded it contains the code to load the kernel that boots the operating system, that displays boot menu and contains GRUB shell to enter commands.
This image can consist of two types of images, image 1 is an optional image that understands the semantics of one file system or the other, and has a name like file system name_stage1_5 this image serves as a bridge between stage 1 and stage 2. At this point, either directly form stage 1 or from image 1.5 stage 2 image is loaded it contains the code to load the kernel that boots the operating system, that displays boot menu and contains GRUB shell to enter commands.


'''''Bootstrapping'''''  
'''''Bootstrapping'''''  


After the GRUB is started the kernel is loaded in the first megabyte of RAM random access memory to accomplish this the kernel is compressed, the head of the file contains the code to bring the CPU into protected mode. In this stage the kernel executes its virtual memory subsystem, root files, device divers, mounts the root files, and starts a program called init. The init is the first non-kernel process to start and is always process ID number 1.
After the GRUB is started the kernel is loaded in the first megabyte of RAM random access memory to accomplish this the kernel is compressed, the head of the file contains the code to bring the CPU into protected mode. In this stage the kernel executes its virtual memory subsystem, root files, device divers, mounts the root files, and starts a program called init. The init is the first non-kernel process to start and is always process ID number 1.
'''''Runlevels /etc/inittab,'''''
The init program reads its configuration file /etc/inittab, and determines what runlevel to boot in, and what rc scripts to run and stop at each runlevel. If the runlevel initdefault exists it is automatically selected, if not, you are asked for a runlevel value.
Each runlevel between 0 and 6 has a special purpose.
 0 - System Halted
 1 - Single User Mode
 2 - multiuser Mode, but without networking file system NFS
 3 - Full multiuser mode normal
 4 - Not yet Defined
 5 - Same as runlevel 3, except using an X Windows login instead of a text based login
 6 - Shutdown & Reboot

Revision as of 05:00, 14 July 2011

Job management and control: & condition, CTRL-Z, jobs, fg, bg

The user login shell is the first program that runs when you log into the workstation. The formal definition for this program is a command language interpreter that executes commands; also referred to as an interface between the user and the system. Bash (Bourne Again Shell) is a command line-only interface where programs also referred to as jobs are lunched and controlled, when a job starts it takes control of the terminal, when the job is finished, control is given back to bash, and a command line is redisplayed for the user. You can see a list of jobs that bash is tracking; along with their status, by using the jobs command.

Example: At the command line type jobs press Enter, the following information is displayed [Job number] Status of program, (running or stopped) Program name & after program name if used.

You can start a job using the ampersand & this states a condition that the job give up control of the terminal to bash, and give the user a command line while the job continues to run in the background.

Example: At the command line type program name & press Enter, the job continues to run in the background and you receive a command line and can continue working.

If a job is already running and has control of the terminal you can press CTRL+Z in the terminal window, the job will stop, give control back to bash, and you will receive a command line. When you bring a job that was running in the background to the foreground using the fg command you give control of the terminal back to that job. To bring a job to the foreground use this command:

Example: at the command line type fg job # from the jobs list

You can send a running job to the background using the bg command as follows:

Example: at the command line type bg job # from the ps jobs list.

To start a job stopped in the background bring it back to the foreground using fg, then if you want, you can send it back to the background using bg it will continue running in the background.

Processes: ps, top, kill signal

The ps command stands for process status it list all the processes in a system, if they are running, stopped, or in a zombie state. The most common parameter is ps auxww

Example: at the command line type ps auxww press Enter

It you want to look at the processes that are running on your system line by line you can use | less like this. Example: at the command line type ps auxww | less Enter you can then use the down arrow to scroll line by line.

The top command shows what is running on your system in real time it refreshes every two to three seconds. Top is an interactive program with a command line within the program that can be used to prioritize or kill processes. To start the top program use the following command.

Example: at the command line type top press Enter

Top is a CPU hog if several people are using the program. To prevent other users from running this program you can change the permissions so only root users are allowed access.

Example: at the command line type chmod 0700 `which top`

To exit top type q for quit and you are back to the command line.

The kill command is misleading in that it is not guaranteed to stop a process, but it does send a signal to the running process. The operating system by default supplies each process with signal handlers to deal with incoming signal differently. To send the kill signal you need at least one parameter, and the process identification number from the ps command list.

The most common handlers are:

 9 the operating system simply kills the process,

 15 the SIGTERM signal you must clearly specify -15 or TERM to terminate

 1 to hang up also called SIGHUP OR HUP this signal gives the process time to perform a clean shutdown

Example: at the command line type kill –signal handler# PID# from ps command list

Remember that root users can kill any process, but standard users can only kill the processes they have permission to kill.

Start up: Booting the system, GRUB, stage 1, stage 2,

The boot loader is the first software program that runs when the computer starts, it hands control of the computer over to the operating system. The boot loader is located in the MBR Master Boot Record of the disk. The most common boot loader is GRUB the Grand Unified Bootloader. The GRUB boot process take place in two necessary stages using special image files, each stage helps the next stage along.

Stage 1 The image file in this stage is called stage 1 it is used for booting up GRUB the boot loader. The image file can then either load stage 1.5 or load stage 2 directly.

Stage 2 This image can consist of two types of images, image 1 is an optional image that understands the semantics of one file system or the other, and has a name like file system name_stage1_5 this image serves as a bridge between stage 1 and stage 2. At this point, either directly form stage 1 or from image 1.5 stage 2 image is loaded it contains the code to load the kernel that boots the operating system, that displays boot menu and contains GRUB shell to enter commands.

Bootstrapping

After the GRUB is started the kernel is loaded in the first megabyte of RAM random access memory to accomplish this the kernel is compressed, the head of the file contains the code to bring the CPU into protected mode. In this stage the kernel executes its virtual memory subsystem, root files, device divers, mounts the root files, and starts a program called init. The init is the first non-kernel process to start and is always process ID number 1.

Runlevels /etc/inittab,

The init program reads its configuration file /etc/inittab, and determines what runlevel to boot in, and what rc scripts to run and stop at each runlevel. If the runlevel initdefault exists it is automatically selected, if not, you are asked for a runlevel value. Each runlevel between 0 and 6 has a special purpose.

 0 - System Halted

 1 - Single User Mode

 2 - multiuser Mode, but without networking file system NFS

 3 - Full multiuser mode normal

 4 - Not yet Defined

 5 - Same as runlevel 3, except using an X Windows login instead of a text based login

 6 - Shutdown & Reboot