Welcome to the most active Linux Forum on the web.
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 07-13-2011, 01:31 AM   #1
LQ Newbie
Registered: Oct 2010
Location: melbourne australia
Posts: 4

Rep: Reputation: 0
using ./ to run programs


I have seen other users run programs by putting a ./ in front of them....


$ ./

and just running
does not work.

what is the ./ doing?

Old 07-13-2011, 01:33 AM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
For safety reasons some distro's don't put the current working dir (the ".")
in users PATH. In those you need to use ./program to "qualify" a relative
path to the executable.

1 members found this post helpful.
Old 07-13-2011, 01:36 AM   #3
Senior Member
Registered: Nov 2002
Location: Birmingham UK
Distribution: Various
Posts: 1,736

Rep: Reputation: 146Reputation: 146
It's a way of telling the system that the program to run is in the current working directory.

So, if I type 'firefox' om its own the system will look on the various "paths" (locations of executable files) and run firefox where it finds it (usually symlinked to /usr/bin).
But, if I downloaded an updated version of firefox and had extracted the files from the bz2 file, how would I tell the system to run that version of firefox and not the installed version?
Answer - by typing "./firefox" - the ./ says "in this folder only".
Old 07-13-2011, 02:27 AM   #4
Registered: Oct 2004
Location: USA
Distribution: Ubuntu-Server, Mac OS X, Arch Linux
Posts: 356

Rep: Reputation: 48
those replies are both right on. When it comes to a .sh file, ./ will typically only run if the file is marked executable using chmod +x

a way around this is just to run a .sh file this way:

1 members found this post helpful.
Old 07-13-2011, 03:21 AM   #5
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
I'll add some salt to the soup: the dot is a reference to the current directory, the same way two dots (..) is a reference to the parent directory (the directory in which the current directory is in). If you do

/bin/ls -d ./.*
in any directory (I used exact path to ls to prevent any aliases from being in effect), the first two "files" (in Unix, "everything is a file") you see are . and .., which point to the current directory, and the parent directory. This is why

cd .
seems to do nothing, because it merely would change the current working directory to the current directory (which it already is), and

cd ..
brings you one level higher in the directory tree (e.g., if you were in /home/user and issued that, your working directory would then be /home). So, just as you can execute an executable using the full path (e.g., /bin/ls), you can execute an executable by typing the path to the current directory, ./ using the dot. Typing the filename without any path does not work unless that directory happens to be in the $PATH variable, which lists the directories where the given executable is searched for, in order.

In addition, typing ./ (if it were a shell script; or ./, or ./, etc.) only works if the script contains information about what interpreter should be used (the first line in the script, for example #!/bin/bash). Without that line it can be run by passing it to the interpreter directly, e.g. by running for example

sh ./
Hope this gave you some idea of what's going on..


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
What do I need to run C++ programs ? tuxuser19 Programming 2 01-10-2006 09:48 PM
Cannot run any 3D programs zxt Linux - Distributions 0 07-21-2004 12:32 PM
how to run programs? matejj Linux - Newbie 6 05-06-2004 09:16 AM
How to run programs? timberwolf Mandriva 3 12-08-2003 10:06 AM
cant run certain programs da Perp Linux - Newbie 3 11-08-2001 08:02 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:47 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration