Multitasking refers to the ability to perform several different activities at the same time in a single Linux computing environment. Many jobs that we perform in our day to day duties when running a Linux system can be performed sequentially, that is, one after the other. Jobs that can be run in a very short amount of time or that require an intense period of resource usage that needs to run as a single large process using all computing resources can be run one after another without the need for multitasking. Jobs that are particularly long running that run on a different computer or several different computers even, such as in a grid environment, are good candidates for multitasking. Defragmenting your disk drive or running a search for a particular query string on your local hard drive are examples of long running local jobs that can be multitasked while running other tasks. Jobs such as long database queries or batch loads onto a remote server are examples of jobs that are controlled in a single session, but can be multitasked in a Linux environment so several of these sessions can be run at the same time.
There are a few different ways to achieve multitasking in Linux. One of the easiest ways is through the use of virtual consoles. Linux will let you run several consoles in the background at the same time. These consoles can be navigated and switched from one to another through your F keys. Each of your virtual screens can be assigned to your F1 through F6 function keys and then selected by pushing CTRL + ALT + Fn (where n is 1-6). If you wish to return to your default graphical environment, you can use the combination CTRL + ALT + F7 (or in some cases F8). Each time you switch to one of your different six terminals, you will be asked to log in with that terminal’s credentials. As you switch between consoles in this manner you will automatically keep running each of the virtual consoles in the background. If you wish to view the status of each of your consoles individually, each console can be indicated by their tty number. This means that if you want to see the first virtual console, you would find it listed under tty1, the second console would be listed under tty2, and it goes all the way up to the last possible virtual console which is tty7, which is you default graphics based environment.
Another great way to do multitasking in Linux is through the
Screen is included in all basic distros of Linux and basically allows you to run several different virtual consoles of Linux at the same time. While this same basic functionality is available to you through the virtual tty consoles we have already discussed,
Screen offers you several other features that make it worth your while to use this when you need advanced functionality. The biggest draw for using
Screen over the basic tty virtual consoles is the fact that you are not limited to the F1- F6 numbered consoles. With
Screen, you are able to create new terminal sessions that can be uniquely named. You can then search on each of your
Screen sessions by name. Another nice feature of
Screen is the ability to detach and re-attach screens from your active session. For advanced multi user environments, you can even create shared screens that can be used by several users at one time. There are several advanced features available in Screen for power users and it can be well worth your time to look into this way of multitasking in Linux.
An alternative to
Like Screen tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.
Among the most notable features of tmux there are:
- The use of commands that use syntax-like vi or emacs,
- The possibility to copy/paste between created terminals (panels)
- Total customization through the file ~ /.tmux.conf
- tmux runs as a server-client system. A server is created automatically when necessary and holds a number of sessions, each of which may have a number of windows linked to it.
Author Bio: Jason Phillips has shared this post. He is a continuous blogger and a freelance writer. He has written currently on the topic linux track user activity which was a must read article for tech lovers.
Find me on Google+