LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 04-06-2010, 01:47 AM   #1
nagavinodh
Member
 
Registered: Aug 2009
Posts: 118

Rep: Reputation: 15
difference


Hi,

What is the difference between #./a.shand #sh a.sh in linux?
And also su - oracle and su oracle?
 
Old 04-06-2010, 01:58 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

These questions sound very much like homework and the answers can very easily be found using Google. If you just ask exactly what you posted in Google, you'll get complete answers within the first 5 links. Please put in some time and work instead of relying on LQ to answer the simplest questions.

Kind regards,

Eric
 
Old 04-06-2010, 02:00 AM   #3
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
'su -' mimics the act of logging in, so the user's environment variables and profile are sourced. sh invokes the shell, whereas the . means 'source' so it doesn't matter what type of executable is being called.
 
Old 04-06-2010, 02:00 AM   #4
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
Have you tried yourself. Its not that hard.
For the first issue, sh a.sh will run the script as sh shell script. If you run it as bash a.sh it will run as bash script. While ./a.sh will do the same but if it is written using different shell than what you are running then you might get issues.

For second, su - oracle will take you to home directory for oracle user but su oracle will keep you in the current and not change to oracle home directory.
 
Old 04-06-2010, 08:06 AM   #5
nagavinodh
Member
 
Registered: Aug 2009
Posts: 118

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by linuxlover.chaitanya View Post
Have you tried yourself. Its not that hard.
For the first issue, sh a.sh will run the script as sh shell script. If you run it as bash a.sh it will run as bash script. While ./a.sh will do the same but if it is written using different shell than what you are running then you might get issues.

For second, su - oracle will take you to home directory for oracle user but su oracle will keep you in the current and not change to oracle home directory.


Hi,

Thanks for reply.

I tried it.but confusing.
when execute the cd then enter and pwd which shows the home directory?

su oracle also returns same thing as su - oracle except 2 line

1,[root@per1 ~]# su oracle
2[oracle@per1 root]$ pwd
3,/root
4,[oracle@per1 root]$ cd
5,[oracle@per1 ~]$ pwd
6,/home/oracle
7,[oracle@per1 ~]$



And please tell about ./a.sh ?
 
Old 04-06-2010, 08:10 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by affinity View Post
.......the . means 'source' so it doesn't matter what type of executable is being called.
Not in this context........

"./file" means "run file in the current directory"----the "." means current directory.
 
Old 04-06-2010, 08:13 AM   #7
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
Code:
1,[root@per1 ~]# su oracle
2[oracle@per1 root]$ pwd
3,/root
You can see here you are in root's home directory.

While if you do su - oracle and then give pwd command you will notice /home/oracle as the output of pwd.
 
Old 04-06-2010, 08:15 AM   #8
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
And about your second issue, you have already received replies. ./a.sh will try to run the script which is in current directory as already said by pixellany. And it will try to run using the shell user is logged in into.
 
Old 04-06-2010, 10:07 PM   #9
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
Quote:
Originally Posted by pixellany View Post
Not in this context........

"./file" means "run file in the current directory"----the "." means current directory.
Ah, thank you for the correction, this whole time I thought it meant something different when used to execute a program.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script to find the difference betwwn two file and place the difference to other kittunot4u Linux - General 3 07-19-2010 04:26 AM
difference between $@ and $* shibu_sp Linux - Newbie 1 11-17-2009 01:00 AM
[SOLVED] What is the difference between ./ls and . ./ls? jcky Linux - Newbie 8 09-14-2009 12:07 AM
what's the difference between | and > ? lugoteehalt Linux - Newbie 3 09-07-2007 11:56 AM
Difference? Jongi Linux - Newbie 4 08-22-2003 02:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration