Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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
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)..
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
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".
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.