Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Okay, I have on my linux machine a VNC desktop and a SSH server running at all times. The machine runs headless and this is how I connect to it. I do so from my XP machine, from school, from friends' houses, etc. There are all kinds of shell programs that I want to leave running, and here's where my question comes in. VNC is really cool, but if you're running a shell in a 1024X768 window on a 1600X1200 screen and it doesn't update well all the time and has incorrectly-colored pixles in it, it gets kind of annoying. When running shell programs I much prefer SSH. However, I can't keep them running unless I keep the computer connected to the SSH server. Is there any way around this?
So, basically, I'm asking if there is any way to keep a shell program running after disconnecting from the SSH program. These are interactive programs, mind you, not just programs that I can run in the background. For example, I use a text-based gnutella client. I don't want to suspend the program or it won't continue downloading. I just want to sort of suspend the shell and be able to reconnect to it later and perhaps from a different computer.
I know this is a weird question and the answer is probably that I can't do it, but I'm really interested in being able to do this, so please humor me. Thanks in advance for any help.
but...as far as I'm understood, programs that are sent to background, shouldn't "suspend" (because linux can run several processes at the same time, not like windows does...) but run quite normally, and stop ("suspend") only if they need some input from the user...
correct me if I'm wrong, but that's what I think? I've had no problems sending any app/process to background & closing shell..am I just weird or what?
so you're saying that running
gnutella &
(well I don't know the name of the binary, but let's say it's gnutella) makes gnutella suspend? or what?
Well, the issue is that I need to be able to bring it back to the shell and get to an interactive interface again. I also don't know much about running things with the & after them. I thought that made them independent of the shell, but apparently I was wrong because I tried to open xmms by opening a shell and entering xmms & as a command and when I closed the shell xmms closed as well. So, perhaps I need clarification on this.
But, like I said, the issue is that I need to be able to get back to the interactive interface, AND it has to continue running in the background (so downloads continue). Is this possible?
I have read that some people use screen to accomplish this. Basically they login through SSH, run screen and have their applications running. They then exit SSH. Because screen is still running, their programmes remain running too. I've not used it myself, but when I read about it it seemed logical enough.
anyway, if you wish to try the &-thingie (the & after the command makes the process go background, so that you can do other stuff and the process itself should run "silently" but still run..), here's how it works:
- a process is sent to background in it's startup by giving & at the end of the line and then pressing return
- a process sent to background gets something like a symbolic number (what was the exact name?), so that the first one is known as %1, second %2, third %3 and so on...so it's a percent-mark and the number which starts from 1.
- a process is called back to foreground (from background) via "fg" command: let's say you have three background processes. typing "jobs" in terminal (without quotes) tells you you have three processes and shows their numbers (1, 2 and 3). now you want to get process 2 back to your screen (foreground) - you give the following command in terminal:
fg %2
that takes the job number 2 (you see the numbers corresponding the processnames with the jobs -command) back to foreground. I've also heard about "bg" command which should send processes (running) to background, but haven't tried it... a running process can (as far as I know) be sent to background by giving CTRL+Z when it's active on your screen. and then brought back with fg.
so to get a process to background, start it with & and to get it back foreground by giving a command "fg" without quotes - running program is sent to background with ^Z (ctrl+Z)
EDIT:
now I remembered it...the reason, why apps shut down when you close the shell it's because of linux's (and unix-like os's) way of managing processes: each process may have it's subprocesses, like a terminal (a process) can run other apps from it if you run them by typing the app name in terminal - these apps run from the terminal are the subprocesses of the terminal. now when you kill a process (the terminal), all it's subprocesses are also killed - so every app you start from the terminal, are also killed when you shoot it down. solution? you really should get your apps started as subprocesses of something that won't shut down when you cut your connection to the shell..this is how the way Thymox said works I guess.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.