Running programs: Multitasking and Sessions
To run a program, type its name as you would do under DOS. If the directory where the program is stored is included in the PATH the program will start. Exception: unlike DOS, under Linux a program located in the current directory won’t run unless the directory is included in the PATH.
You can type multiple command with; as the separator like:
$ command1; command2; ….;commandn
That’s all about running programs, but it’s easy to go a step beyond. One of the main reasons for using Linux is that it is the multitasking OS- it can run several programs (from now on, processes) at the same time. You can launch processes in background and continue working straight away.
Moreover, Linux lets you have several sessions: it’s like having many computers to work on at once!
Some wonderful tips, hope you will find useful.
To switch to session 1..6:
$ ALT-F1 …ALT-F6
To start a new session without leaving the current one:
$ su – root
This is useful, for one, when you need to mount a disk normally, only root
can do that.
To end a session:
If there are stopped jobs (see later), you’ll be warned.
To launch a process in foreground:
$ programm [-switches] [parameter] [<input][>output]
To launch a process in background, add an ampersand ‘&’ at the end
of the command line:
$ programm [-switches] [parameter] [<input][>output]&
The shell identifies the process with a job number (e.g. ; seebelow), and with a PID (123 in our example).
To see how many process there are:
$ ps -aux
This will output a list of currently running processes.
To find the process running
$ ps aux | grep <process name>
To kill a process:
$ kill <PID>
You may need to kill a process when you don’t know how to quit it the right way…:-). Sometimes, a process
will only be killed by either of the following:
$kill -15 <PID>
$kill -9 <PID>
In addition to this, the shell allows you to stop or temporarily suspend a process, send a process to background, and bring a process from background to foreground. In this context, process are called “jobs”.
To see how many jobs there are:
here jobs are identified by their job number, not by their PID
To stop a process running in foreground (it won’t always work):
To suspend a process running in foreground (ditto):
To send a suspended process intothe background (it becomes a job):
$ bg <job>
To bring a job to foreground:
$ fg <job>
To kill a job:
$ kill <%job>
where job may be 1,2,3… Using these commands you can format a disk, zip a bunch of files, compiles a
program, and unzip an archive all at the same time, and still have the prompt at your disposal. Try this with DOS! And try with Windows, just to see the difference in performance.
Running Programs on Remote Computers
To run a program on a remote machine whose Hostname (Do you know what do you mean by this:) is karnali.linuxnepal.com.np, you do:
$ telnet karnali.linuxnepal.com.np
After logging in, start your favourite program. Needless to say, you must have an account on the remote
machine. (This is bit of high tech stuff will talk about these later)
Directories: Preliminary Notions
We have seen the differences between files under DOS and Linux. As for directories, under DOS the root
directory is \, under Linux / is. Similarly, nested directories are separated by \ under DOS, by / under Linux. Example of file paths:
As usual, .. is the parent directory, . is the current directory. Remember that the system won’t let you cd, rd, or md everywhere you want. Each user starts from his or her own directory called dir is /home/ranjan
Directories, too, have permissions, as well (user, group, and other). For a directory, rx means you can cd to that directory, and w means that you can delete a file in the directory (according to the file’s permissions, of course), or the directory itself.
For example, to prevent other users from snooping in /home/ranjan/text:
$chmod o-rwx /home/ranjan/text
Translating Commands from DOS to Linux
1. When using rmdir, the directory to remove must be empty. To delete a directory and all of its contents, use rm -R (at your own risk).
2. The character ‘~’ is a shortcut for the name of your home directory. The commands cd or cd ~ will take
you to your home directory from wherever you are; the command cd ~/tmp will take you to /home/your_home/tmp.
3. cd – “undoes” the last cd.