Share your knowledge at the LQ Wiki.
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 12-30-2004, 05:53 PM   #1
Super Nade
LQ Newbie
Registered: Dec 2004
Distribution: Mandrake 10.1 C
Posts: 9

Rep: Reputation: 0
What does ./ do?

Hello all (N00b here),

I have looked through many books and also googled for information but I can't find the answer to this question:

What does ./ do?

This came up when I was trying to install Mathematica on my Mandrake 10.1 beta system.

-The instructions said I must login as root, so I did a su root.

-Next, I did cd /mnt/cdrom/Unix/Installer

-I found the file MathInstaller displayed in green with a star after it. So I typed in MathInstaller at the prompt. I got an error message saying command not found. So, somehow I did a ./ MathInstaller and it worked!

So should I always do a ./ to run green files?

I am overwhelmed by the amount of sttuff that needs to be known to work with Linux. Could somebody point me to a site with basic information for N00bs like me?

Thanks in advance!

Old 12-30-2004, 06:03 PM   #2
Registered: Apr 2004
Posts: 354

Rep: Reputation: 30
./ is usually used to run certian files thats all and what kinda basic stuff you want to know? like basic commands and things like that?
Old 12-30-2004, 06:05 PM   #3
Registered: Aug 2004
Distribution: debian, SuSE
Posts: 365

Rep: Reputation: 36
echo $PATH

That will show you a colon delimited list of directories where you can execute code by just typing their name. Note that the directory you were not in was not in that path statement. Thus, you must declare the full path to the program you are going to run.

. is a shortcut relating to the directory you are currently in.

.. is the directory just above you. (parent directory)
so by saying ./programname, you are giving the path to the command.

Most regular users will have :. at the end of their path. That way no matter what dir they are in, they will have that as their path to execute applications.

The root account rarely has that as he/she may type something accidently in a directory and execute it if there happens to be an executable with that name in the dir. It is a little safety net.

Note: roots path is far different from a regular users. He/she has a lot of sbin directories listed that a regular user doesnt.

Root can type ifconfig to see the network IP address, where as a regular user would have to type /sbin/ifconfig

I think that shud explain it fairly well for you.
Old 12-30-2004, 06:21 PM   #4
Registered: Jan 2004
Location: cheshire, uk
Distribution: Ubuntu Hoary
Posts: 605

Rep: Reputation: 33

your question is best explained as follows, and applies to running commands from within a shell (or command-line environment, eg, konsole)...

executable programs and / or scripts can be found in various locations on your system. the most common places are /usr/bin; /usr/local/bin; /usr/sbin, and so on. these can be considered 'default' locations. now, say you've got a program or script called 'myprogram' located in /usr/bin. to run it, you could type '/usr/bin/myprogram'. but since /usr/bin is such a common location for programs, it would be nice if you didn't have to type in '/usr/bin' every time... this is why environment variables are used, and what this means is that if you just type in 'myprogram', the system will look at all of the 'default' locations, and find the file you want to run.

however, executable programs aren't always found in the 'default' locations - you might have an executable script in your /home directory. in these situations, you prepend ./ to the filename - this tells the system that the file you want to run is located in your current working directory, and prevents the system from assuming that the file is in one of the 'default' locations (where the file would, of course, not be found)..

hope this helps.
Old 12-30-2004, 11:27 PM   #5
Super Nade
LQ Newbie
Registered: Dec 2004
Distribution: Mandrake 10.1 C
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks guys,

I do comprehend the importance of having a safeguard as root and hence the ./
Please tell me if my understanding is right in this context:-

- I'm logged in as root.
- Both /usr/bin and /mnt/cdrom have the same name executable file "myprogram" but I want to run the one on the cd.
- The ./ safeguard will ensure that I run the one on the cd only.

Why should Linux even have a default path list? Wouldn't it be easier just to run the file as $ cd /mnt/cdrom/myprogram ?

I come form the Windows world and hence the question
Old 12-30-2004, 11:33 PM   #6
Registered: Dec 2004
Location: Singapore
Distribution: Fedora Core 5 Linux
Posts: 202

Rep: Reputation: 30
Why should Linux even have a default path list? Wouldn't it be easier just to run the file as $ cd /mnt/cdrom/myprogram ?
Then you have to type the whole path, which is quite tedious! For example, if you wanted to run the command "lilo", you would have to type /sbin/lilo every time, so if you have a path, you just type "lilo".
Old 12-31-2004, 12:05 AM   #7
Super Nade
LQ Newbie
Registered: Dec 2004
Distribution: Mandrake 10.1 C
Posts: 9

Original Poster
Rep: Reputation: 0
O.K that makes sense now.

Another N00b Q:
When I double-clicked the file from a root X-Window, nothing happened. Why is that?
I logged in at the outset as root and din't do an su root.


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:49 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
Open Source Consulting | Domain Registration