User access and managing Unix processes

Access prompts

chmod
With this prompt, the access rights of the user (u), a group (g) or other users (o) are specified for files and directories. Access is given with a plus sign (+) and taken away with a minus sign (-). 

NB: be extra careful when using the chmod prompt, so that you do not make a file accessible to everyone by mistake. 

 

Specify access to the file my_dear_alisa.txt so that only the owner of the Unix account (u, user) har read and write access (r and w) to it. 
 % chmod u+rw my_dear_alisa.txt
 

 

Specify access to the file my_dear_alisa.txt so that groups (g) and other users (o) cannot access the file in any way (they can neither read (r), write (w) nor execute (x) the file). 
 % chmod go-rwx my_dear_alisa.txt
 

 

Managing Unix processes

The execution of prompts and other programs in Unix is carried out with so-called processes. Processes can be terminated, suspended and they can be set to run in the background (the outputs of the program are not shown on-screen) and back to run in the foreground (so you can see the program being executed on-screen).

One way to use the background run is when you have remote access and you want to use several programs at the same time: you can start any program in the background and continue using other programs over the remote access connection. When you need to, you can return to the background program and use it in the same terminal window or a separate one. This is possible because Unix usually allows you to form several remote connections to the same systems at the same time.

 

Starting processes

Unix prompts and the execution of Unix programs are usually carried out via the command line. By typing the program execution prompt on the command line, the program will be executed as a foreground run so that you can see the execution on-screen.

Start the e-mail program pine:
 % pine
 

You can also execute Unix processes as background runs, i.e. so that the program is not shown on-screen. Use the sign & to set a process to background run. This will allow you to do other things from the command line.

Start the mozilla browser in the background so that you can use the command line for other tasks at the same time:
 % mozilla &
 

 

 

Handling processes

When a process is running, you can either terminate the whole process completely, or suspend it for a while:

 

  • Terminate a process: CTRL-c
  • Suspend a process: CTRL-z.

After giving the terminate prompt, you cannot go back to the process, but if you have suspended a process, you can continue to execute it later.

If you press down the key combination CTRL-z, the program in the foreground will be suspended. A dialogue will appear on-screen (in the example, the pine program has been suspended): 

 % [1]  + 26457 Suspended (signal)            pine
 

jobs
With this prompt, you can find out which programs are running, and which programs are suspended.

Show processes (the prompt will output a list of running and suspended processes).
 % jobs
 [1]    Suspended (signal)            pine
[2] - Suspended lynx
[3] + Suspended (signal) tin

 

 

bg
This prompt continues to run a suspended process in the background when you give the prompt the id of the process (shown inside [ ] in the example above).

Set suspended process # 1 to run in the background:
 % bg %1
 [1]    pine &


fg

This prompt brings a suspended process to the foreground (=shown on-screen).

Bring process # 1 to the foreground:
  % fg %1
 

 

The following list shows some other prompts for managing processes:

  • ps -aux = Show process states
  • top = Show processes that tax the server processor the most
  • kill = Kill the process

Learn more about these prompts with the man prompt.