Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-23-2008, 01:37 AM   #1
LQ Newbie
Registered: Feb 2007
Posts: 4

Rep: Reputation: 0
Using the & (ampersand) with a command

Using Linux Server 10, I used the following syntax from the command line.

yast2 nfs &

The results of the command is

[1] 26956

Without the & (ampersand) the command will run.

Here are my questions.

1. What is the & (ampersand) used for?
2. What is the [1] 26956 results represent?
3. What should actually happen when the command is used?

Stephen C.
Old 11-23-2008, 02:02 AM   #2
Registered: Jan 2004
Distribution: Mac OS X 10.6.4 "Snow Leopard", Win 7, Ubuntu 10.04
Posts: 322

Rep: Reputation: 31
You say Linux 10, and reference yast, so I assume you are running openSUSE or SUSE Linux Enterprise. Linux is the kernel, and on top of that is everything else. Just a note so when you ask another question, people may need to know what you are using...

The command is working both ways. The function of the ampersand is to make a command run in the background. So that should answer 1 and 3. As for 2, I am pretty certain that number represents the process number. The ps command will show you running processes and the process number, the kill command followed by a process number will stop that command.

And finally, welcome to LQ!
Old 11-23-2008, 02:32 AM   #3
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
The ampersand will run the command in the background. Some commands expect terminal input, and running them in the background will cause the program to stall as it waits for input. There is a similar situation if you aren't careful starting some scripts in a cronjob. Cron will start the script, but cron is a service running in the background without an attached terminal or stderr. You need to either redirect text output to /dev/null or to a log file.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ampersand problem in cgi script... Sherlock Programming 1 05-22-2007 08:42 AM
ampersand problem in cgi script... Sherlock Programming 6 05-22-2007 03:12 AM
pdftotext - How to output to html with ampersand entities ? narc Linux - Software 2 01-04-2006 03:34 PM
alternative way to write an ampersand (or another fix to my superkaramba problem)? fibbi Linux - Software 1 04-23-2004 03:51 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:50 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration