Beginning to get a feel for unix and have some difficulties finding commands for process controls. As an user that is NOT root, I am trying to find out...

(1) the process id of current shell, 
(2) its parent process’s process id, 
(3) how many processes this user is running, 
(4) how many of processes are running on the machine, 
(5) how many are sleeping, how many are stopped, 
(6) how much total memory your machine has, 
(7) how much of that is used and how much is free.
(8) how to determine whether or not a process is using more than X amount of memory
(9) how to suspend a process temporarily for investigation purposes and how to resume it again
(10)terminating a process and ensuring it is in fact, terminated

A friend recommended me to use


but I am having trouble navigating it. If you could also share a great general resource for unix commands it would be much appreciated.

  • Considering this and your previous questions, it sounds like this is homework. Have you tried using google to find the answers for these questions? – Ryan Castillo Mar 10 '11 at 2:07
  • 2
    Sometimes it's hard to tell friends from enemies when they make recommendations like that. – Greg Hewgill Mar 10 '11 at 2:07
  • I recommend RUTE. That makes me a much better friend. – Ignacio Vazquez-Abrams Mar 10 '11 at 2:09
  • Yes I've just discovered that Google is way faster than combing through the manual. You guys are not joking when you say Google is your best friend though I'm only beginning to learn using syntax in searches carefully for better results. – gigadrill Mar 10 '11 at 2:12

This is specific to Linux and bash. Some of it will work on other Unixes, and some of it will work in other shells. In particular, the stuff involving anything in /proc will not work on any other Unix. And while I think most shells have $$, I don't know that any shell but bash has $PPID.

  1. echo $$
  2. echo $PPID
  3. ps -u $USER | tail -n +2 | wc -l
  4. ps -e | tail -n +2 | wc -l
  5. This is possible to find out, but not really easy.
  6. fgrep MemTotal /proc/meminfo
  7. This question also has no easy answer. In an ideal system there is never more than a little memory 'free' since any that isn't needed by programs will be allocated for disk cache. Linux dynamically shifts memory between being used by processes and being used by cache.
  8. ps -ev and look for processes that have a large RSS, which stands for 'resident set size' and represents how much memory that process is using.
  9. kill -STOP <pid>
  10. First, kill it gently kill <pid> and if it doesn't go away shortly after that, kill it with prejudice kill -9 <pid>. It will go away after the -9, if it doesn't, it's a kernel problem of some kind.

As some have mentioned, the top utility (do a man top) will be very helpful. It will tell you about total memory and how much is being used for buffers and cache, and how much is free. It can also be used to show processes ordered by memory usage or CPU usage.

| improve this answer | |
  • Wow great insight especially on point 7 thank you for your time – gigadrill Mar 10 '11 at 2:23

Just for starters, here is a cheat sheet on common Unix commands. The purpose of man is to find more information about each command, like their options and required input. So ls list the files in your current directory. If you do man ls you can find more options for that command.

| improve this answer | |
  • Very useful will get it tattoo on my arm – gigadrill Mar 10 '11 at 2:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.