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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
You need to use "./hello" to tell the shell to execute the file in the current directory. Otherwise, the shell will search for directories listed in $PATH for "hello" and since it's not in any of those directories, you'll get the "command not found" message.
You should read the pages in linuxcommand.org - they're really helpful and surely clear some things (like this, for example). There are some "shortcuts" in Linux shells, or ways to express something shorter than it actually is, and the dot is one of them (it's a file that always refers to the directory where it is in) - two dots (..) is another file found in every other directory than root directory, and it refers to the upper/parent directory (the dir where the directory is in, that has the two dots file in..got it?)
Like said above, when you issue a command, your shell tries to find the executable for you. There are several ways to execute an executable, for example:
- by giving a full path to it, and the executable name, like /bin/bash
- by giving just the executable name, for example just bash
In the latter case the shell doesn't automagically know where 'bash' (or anything) is, but it searches certain places where it can be. Usually (but can be configured otherwise if I'm right) it first checks all the directories mentioned in $PATH environmental variable (order matters - the executable is executed from where it's first found). If it's found somewhere in there, it's executed there; if not, then the shell usually checks to see if the file is in the current working directory. So if you have executables that have exactly the same name (but in different places), your shell runs the one that is found first. To make sure you run the right one, you can provide the full path to the executable, telling your shell to launch just that executable. And because you don't want to type in your full current-working-directory-here name, you use a special file (the dot, '.') as a "shortcut" to the directory: there ./ means just the same as if you had typed the full current working directory path.
Ubuntu has this nice feature not in every distribution that if you type in a command name that is not found (from $PATH; I'm not sure if it's even checked against the parent working directory, as your example seems to show..), Ubuntu checks to see if there's a program of that name in some package that's available in it's reposity. If yes, it kindly tells you the package name you need to install to obtain the executable you tried to run..