When running on a windows machine, a fair amount of problems can be solved with a simple Ctrl+Alt+Del. For those of you who still don’t get it the task manager comes up and you can kill any process you want. Moreover, if you want a process to run into the background you need to make it a service (or write a windows native program to minimize to tray). Now when running linux gives you much more freedom. First of all the processes than can be run are much more. With 30-40 processes a windows machine can feel a burdain, on a linux machine 60 processes are just for fun. Now, a lot of you out there are trying to find out which processes are running and most of the time you can hear your self say “well i love linux but there is nothing like the task manager!”. Now that is not only true, but you can use several ways to monitor your running processes.
The first and main tool to check the running processes on your machine is “ps”. When you run this you will get all the processes that are running from you. If you want all the processes then issue the “ps -A” command. For more info on ps read the fine manual (man ps). If you want to see if apache for instance is running then try “ps -A | grep apache”.
Now, this is half the job. The other half is terminating processe that are either not responding or we don’t want them to run any more. This can be done using the “kill” command. To kill a process you need to know the process ID. This id can be found from the previous command “ps”. So, if the process id of apache is 4130 for example, you can kill it by issuing “kill 4130”. There is a good chance that the process will not die what so ever (either because it is not responding at all or for any reason that you can imagine).
To understand why, we have to explain the meaning of a “signal”. To actually tell the process about shutting down (among other things) we send what we call a signal. You must have noticed when shutting down the machine a line saying “Sending all the processes the TERM signal”. That’s what you have to do. Send the process the TERM signal to make almost sure that the process will die. To do that you have to issue the kill command with a parameter like this “kill -s SIGTERM 4130” (assuming that 4130 is the process id that we want to kill). I must add the “killall” command that takes a process name as a parameter and kills all the processes with a name like that.
This is the long way round. For those of you used to the task manager this next tool will make it up to you. it’s called “htop”. It is actually based on the “top” command. Here are a couple of screenshots.
Now isn’t that sweet? This is a great tool. It visualizes everything and makes the viewing and killing (and much more actually) very easy. You can sort the processes by any column, you can search for processes, send any signals etc.
Now, one more thing i’d like to add. If you want to run a process on the background you can add the “&” symbol on the end of the command. If you want to restrain the load that it will give to the system then you can run it under “nice”. Finaly, if you want to make the process run as a daemon that will not die when you close the console then the “nohup” is what you need. Nohup actually ignores the SIGHUP signal sent from the dying terminal to all the child processes. So, suming up all the above, running a command on the background, without a huge impact on your system that still runs when you close your terminal (an example of a process can be an @home project) you can issue “nohup nice command &”.
Hope it is usefull to you all guys and do not hesitate to contact me if you need more details/advice!
I love XP 😛
for desktop PC win is what i use too. but for my small server (and any server for that matter) i would definitely go with linux (debian to be exact)