suspending stuff in linux command line
I suspect most linux (and other unixes such as *bsd, solaris and so on) users know how to suspend a currently running job in the terminal. You just have to press “Ctrl-Z”. For example:>ls
012linux.tar.gz
[1]+ Stopped ls –color
- I pressed Ctrl-Z really fast here
. Suspended job number is “1″.
There are some operations you can do with the suspended process. fg command will bring it back to the foreground. bg will put it in the background (the same as appending & to the command). kill %% will kill last job. jobs will display all the jobs in the current terminal, and with job number from that list you can do bg %job-number, fg %job-number and kill %job-number.
But all this is more or less common knowledge. Now to the interesting stuff. Did you know you can suspend telnet, rsh, rlogin and ssh sessions too? Well, you can! In order to do so press tilde (yes, ‘~’) - note it’ll not be displayed and now press “Ctrl-Z” - the session will be suspended. Use fg command to get back to it when needed. Here’s an example with ssh session:a: /> ssh d
Last login: Fri Apr 6 12:34:42 2007 from xxx.xxx.xxx.xxx
d: /> hostname
d
d: /> ~^Z [suspend ssh]
Suspended
a: /> hostname
a
a: /> jobs
[1] + Suspended ssh d
a: /> fg %1
ssh d
hostname
d
d: />
I hope you’ll find it useful.
Technorati Tags: command line, linux, jobs, unix, suspend, fg, bg, cli

