SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Linux sysadmin for newbies



    Well, I admit that I am a linux newbie. I'm sure there are many of us here at sitepoint - just beginning to find our way around the big file structure that exists outside of the warmth and safety of the htdocs directory

    Perhaps this thread can turn into a bit of a tips and tricks and how to for the Linux newbie. If I may, I will kick it off with this question.

    Why can't I run scripts from the command line by their name (as always seems to be done in examples I read on the web or in turorials or installation guides).

    For example, a tutorial or book will tell me to open the mysql server like so

    $ mysql -u freakysid -p

    but I have to use ./ like so

    $ ./mysql -u freakysid -p

    Why is this so and what can be done about it?

    Thanks.

  2. #2
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you type in 'mysql', the shell in which you're typing it will look for an executable in one of the registered 'bin' folders with that name. With adding ./ in front of that name, you notify the shell that the executable you're referring to is placed in the current folder.

    What you can do about it? Well, enjoy it, I'd say. It's so much better than DOS/Windows does it IMO.

    I actually don't see any reasons to change this
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OIC - but if I type 'mysql' in the shell (regardless of which directory I'm in) the mysql client doesn't start-up. I get a "bash command not found" error (or something like that). How do I register my bin directories when I'm installing new software? Is this something to do with setting the PATH variable. Could you give me some concrete instructions of what I should do to be able to register my bin directories. BTW, I'm even worste with DOS (my background is almost exclusively Mac - been using them since 1988. )

  4. #4
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    That is because mysql is not a bash command. It is a prog command that the system does not understand. You need to specify where the executable is and if it is in the current directory that is why you use ./

    I have set mine up (some way that I don't remember) so that certain commands (like Apache, mozilla, GIMP etc.) can be started from the shell without all the extra gunk. Let me search around and see if I can remember how I did it lol

  5. #5
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So when you talk about a registered bin is this something to do with exporting a path? Can someone explain this. I'm sure its very simple. At the moment, if I want to start up mysqld for example I have to give the full path /usr/local/mysql/bin/mysqld Quite a pain in the bottom.

  6. #6
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To add directories to the search path, do this:

    export PATH=$PATH:/usr/local/mysql/bin

    (assuming you're using bash)

    Then you can type the name of any executable in /usr/local/mysql/bin without the full path, and bash will find it and execute it for you.

  7. #7
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Brilliant. Thanks. Yes I'm using bash. It is the default shell installed with RedHat 7.0

    Now when I look at that bash command you have given me, it would appear that it is concatenating the string :/usr/local/mysql/bin onto a variable called $PATH. I have no understanding of shell scripting Is that right? And what is the command export exactly. If you can be bothered to reply I'm sure it would add a little fill to the overall matrix of my understanding of linux.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •