FCI-Helwan blog

Just another FCI-H weblog

Linux Shell Tip #2

In the previous post, I mentioned a case when you have run a program through the shell and you want to close the shell without closing your program.

So before you close the shell, you may notice that you can’t type any other command untill you close the running program.

What if you need to use the shell for another purpose?

This is when you need to place an ampersand “&” at the end of the command. so for the gedit example i have mentioned before, the command would be like this:

gedit &

The ampersand (&) placed at the end of the command starts the process as a background process which means that this process will not capture your keyboard input in the shell, so you can use the shell for typing any other commands.

Remember that if u close the shell the programs you have run will close. To overcome this situation you will need to use nohup in association with the “&”. So if you want to run gedit the command will:

nohup gedit &

and the general form of it would be:

nohup “your command” &

Now you can:

# Use the shell for any purpose after running the programs you want.
# Close the shell without disrupting the operation of the programs you have run.

Advertisements

February 21, 2007 - Posted by | Linux

1 Comment »

  1. If one forgot to add & he can do this :
    Ctrl+Z to suspend the job, then enter the command “bg” to move that job to work in the background.

    Comment by Mohammad Nabil | February 22, 2007 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: