LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-06-2012, 02:02 PM   #1
AffanLinux
LQ Newbie
 
Registered: May 2012
Posts: 1

Rep: Reputation: Disabled
Difference between ./ and & to run a script


Hi, i installed vmware tools on my mint OS. i noticed i could run vmware-toolbox with either ./vmware-toolbox and vmware-toobox &

Is there any difference between these two?

Thanks!
 
Old 05-06-2012, 02:04 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Those two are totally unrelated. ./ before a script name tells your shell to look into the current directory, which is on Linux systems (opposite to Windows) not in the PATH. The ampersand (&) tells the shell to run a program in the background. Both commands have totally different uses and are not related.
 
Old 05-06-2012, 02:06 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Well apart from ./ means your running the one in the current directory and without it you are running the one in your PATH, which may or may not include the current directory, and the & is telling the
shell to run the command in the background ... I would have to say ./ and & have very little in common
 
1 members found this post helpful.
Old 05-07-2012, 07:14 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
What they said ^
Also, if you are researching this, you should also lookup the nohup cmd ..
 
Old 05-08-2012, 05:46 AM   #5
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,672

Rep: Reputation: 486Reputation: 486Reputation: 486Reputation: 486Reputation: 486
Welcome to Linux Questions!

The most noticeable thing you will find regarding the two ways of running the command is that
Code:
./<executable file>
will run the command within your terminal window and you can't use the terminal till it's complete and control is passed back to the terminal (The prompt re-appears) Yes, the executable file must be within your current directory.

Code:
 <executable file> &
will display the PID of the process the command started in the background but you are still able to work with the same terminal.

I thought you might like a slightly less-technical reply.

Play Bonny!
 
  


Reply



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
shell script to find the difference betwwn two file and place the difference to other kittunot4u Linux - General 3 07-19-2010 04:26 AM
review postgres dump script and difference between pg_dump & pg_dumpall noir911 Linux - Server 1 10-09-2008 10:11 AM
difference between shell script & make subbusp2 Linux - Newbie 1 07-23-2008 09:33 PM
Howto Encrypt & Run Bash script File nabeeliumattack Linux - General 7 05-17-2008 04:58 PM
Difference between executing & sourcing a script muazfarooqaslam Linux - Newbie 1 01-04-2008 02:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:54 AM.

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