i don't understand the difference between "top, top&, top &" commands in linux.

- 56,709
- 26
- 150
- 232
-
8Please, don't post images of text. – Kusalananda Oct 07 '17 at 07:45
3 Answers
The &
character at the end of a command, no matter if it's preceded by a space or not, will start a background process (sometimes also called an asyncrounous process since the shell will not wait for it to terminate before executing the next command).
Running top
as a background process makes little sense as it is, by default, an interactive program. This is also why you see the text Stopped
in the terminal as soon as the backgrounded top
tries to interact with the user (it can't, because it's not connected to the controlling terminal).
On my system, I get a slightly more descriptive message:
[1] + Stopped (tty output) top
meaning "top
tried to write something to the terminal, but couldn't, so it's been stopped temporarily".
To move the backgrounded top
into the foreground, use fg
.
In this case, you have two backgrounded top
processes running. To foreground the first, use fg %1
. To foreground the second, use fg %2
.
The numbers in %1
and %2
are job IDs, or job specifications. These corresponds to the numbers in square brackets displayed when you started the background jobs.
Related:
- What does "fg" stand for?
- How to suspend and bring a background process to foreground
- Why do backgrounded processes sometimes stop spontaneously?
... and other questions related to the job-control tag.

- 333,661
top&
and top &
do the same thing.
They'll both run top as a background task (which in case of top is not very useful)
In your screenshot this is shown by [1] 4679
and you can get the process into the foreground by using fg 1
.
You can read more on that Topic here

- 67,283
- 35
- 116
- 255

- 141
First of all top& and top & are same thing as & is used to run processes in background. The only difference between top and top& or top & is simple top will be running as process on your screen and top& or top & will run as background process.