Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am reading MySQL's manuals.

They suggest me that the command

cd /usr/local/mysql
sudo ./bin/mysqld_safe          // it seems that sudo = . + master rights

is the same as

. /usr/local/mysql/bin/mysql    // only ., no master rights

Are the two commands same in action?

share|improve this question
1  
The single dot only signifies your current directory, which is why 'cd' is used with it. –  Andrioid Jul 5 '09 at 9:54
1  
I have added a question and answer that discusses the use of the dot and the difference between its use for sourcing a file or specifying the current directory. See serverfault.com/questions/36052/… –  Dennis Williamson Jul 5 '09 at 13:02
add comment

4 Answers

up vote 5 down vote accepted
. /some/path

executes [ or includes - which is execution ] a shell script you pointed.

./some/path

[ notice lack of space after dot ] executes program/script using relative path [ from current directory, not from the top of filesystem ]

sudo executes given command with other [ usually root ] user's privileges.

there is difference between

cd /usr/local/mysql
./bin/mysqld_safe

and

/usr/local/mysql/bin/mysqld_safe

the difference is current working directory. for mysql probably that does not meter, but for other/badly written programs that use relative paths - it might meter.

share|improve this answer
add comment

No, those commands are completely different. You may have a typo in there -- the following two commands are equivalent:

cd /usr/local/mysql
sudo ./bin/mysqld_safe

And:

sudo /usr/local/mysql/bin/mysqld_safe
share|improve this answer
add comment

From Freshmeat:

Sudo (su "do") allows a system administrator to delegate authority to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while providing an audit trail of the commands and their arguments.

I'm not sure that you are confused about this, but you might be based on the question.

If you're only confused about why

cd /usr/local/mysql
./bin/mysqld_safe

Is the same as

/usr/local/mysql/bin/mysqld_safe

This is because in UNIX, the . means the current directory. So in this way, you will not search your PATH variable for the nearest mysqld_safe and run it, you will specifically run the one at /usr/local/mysql/bin/.

share|improve this answer
    
I am not sure why you can execute a PATH without "." --- This suggests me that "." or source must be in the PATH. –  Masi Jul 5 '09 at 10:03
add comment

In this command:

cd /usr/local/mysql
sudo ./bin/mysqld_safe

starts the mysql server. As others have said, the period signifies the current directory. It is used in this way to, for example, override the $PATH or to execute a program that's not in $PATH. Remember, in bash, etc., the current directory is not in the $PATH unless you add "." to it (not recommended for security reasons).

Then this command allows you to access mysql:

/usr/local/mysql/bin/mysql

Note that there's no dot (".") at all in this command.

share|improve this answer
    
mysqld_safe is a valid command. –  womble Jul 5 '09 at 10:11
    
Thanks, I've corrected it. –  Dennis Williamson Jul 5 '09 at 10:16
    
@Dennis: Why is there no period in the last command? –  Masi Jul 5 '09 at 10:17
    
@Masi - because it's absolute path to binary executable. –  pQd Jul 5 '09 at 10:18
    
I mean to like . /usr/... –  Masi Jul 5 '09 at 10:18
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.