Most of the new comers in UNIX world aware of 'How to start a application, job, or even background process from command line'. However shell offers extensive job control like
putting a running job in the background, suspend a job, list it, restart it and so on!
A) To start a job in background use following syntax:
command-name &
You would like to start xmms to listen mp3s, you start it using following command:
xmms &
In reality many time you forget to append & at the end and your command; most of the us hit CTRL+C to cancel the xmms and restart it with appending & to it. However, you can take advantage of job management as follows:
i)Start command in background without appending &
$ xmms
ii)Press CTRL+Z to suspend it (you will get job number on screen)
[1]+ Stopped gpdf
iii) Type % &
OR
job-number & (remember % refer to last suspended job so no need to type job number)
$ % &
OR
$ 1% &
[1]+ gpdf &
This will save lot of time for example if you are running a job at shell prompt, and it is taking lots of time. Then use above trick. However, classic book on UNIX suggest following steps:
a) Start a job
$ xmms
b) Hit CTRL+Z to suspend it
c) Lists the active jobs with jobs command:
$ jobs
[1]- Running gpdf &
[2]+ Stopped vi
d) Place a job (with given number) in the background
$ bg %2
e) If you wish you can also put a job in foreground with command:
$ fg %2
f) You can list only job numbers with
$ jobs -p
g) Naturally kill all your jobs using kill command:
$ kill -9 $(jobs -p)
OR
$ kill -9 `jobs -p`
Please note that job management is shell feature and almost available on all type of UNIX/BSD/Linux operating systems. Therefore, commands discussed here should work on Linux, Solaris, HP-UX et all.
1) Read man page of bash
2) Read help pages for bg, fg,and jobs commands, for example:
$ help jobs
3) See screen shot of above commands.
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop











{ 4 comments… read them below or add one }
>OR
>
>$ 1% &
>[1]+ gpdf &
OR simply
$ bg [ENTER]
> $ bg [ENTER]
Yup, you can do that! Thanks for pointing out.
Appreciate your post.
“i)Start command in background without appending &
$ xmms”
dont’ you mean
i)Start command in background without suspending
$ xmms
$ 1% &
[1]+ gpdf &
should be:
$ %1 &
[1]+ gpdf &