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.
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.
'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.
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.
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 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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.