Running Commands In The Background In Linux

A useful technique to know about when using Linux is to run commands in the background. Sometimes certain commands can either take a while (like copying a large file) or will simply take over the terminal window when run. For example, lets say that you open a file in gedit, you might use the following command.

gedit file.txt

Doing this will open the file in gedit but will not allow you to do anything in the terminal window until you close gedit. To open the file but still keep the terminal window active use the & symbol at the end of the command. This will run the proceeding command in the background.

gedit file.txt&

To run a file copy in the background do the following.

cp file.txt file.txt.bak&

Note that this command shouldn't be used for all commands, especially those that produce some form of output. For example, running the following command


Will cause the terminal window to print out the contents of the current directory and sit patiently waiting for you to quit the program. You can do this by pressing Ctrl+c.


Hello there! I truly appreciated reading your write-up. Hope you write more similar to this!
thanks for your post, it is very helpful for me.

Add new comment

The content of this field is kept private and will not be shown publicly.
2 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.