Solved

RHEL, su in /etc/profile

Posted on 2013-11-19
3
218 Views
Last Modified: 2013-11-26
When I try to use su in a script,  I perform a whoami, followed by a su

[root@btvm1 etc]#
[root@btvm1 etc]# cat aa
whoami
su - mqm
[root@btvm1 etc]#
[root@btvm1 etc]#
[root@btvm1 etc]# ./aa
root
mqm
Password:

Open in new window


As you can see, he thinks he is root, but when he tries to perform the su, he thinks he needs a pw

What is going on, how can I convince root of his identity
0
Comment
Question by:Los Angeles1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:Los Angeles1
ID: 39660852
ok I know I am slow, but in this case the password it was happy with was the root password

1> So the question is why if I am calling a batch file from root do I need to enter my root password

2> and, How can I fix this ?

Thanks
0
 
LVL 19

Expert Comment

by:xterm
ID: 39660897
Why are you running the batch file as root, and then trying to have it su to mqm.  Can you not just run it while logged in as user mqm?

If you are running it as root, but want it to execute a command as user mqm, then do it like this:

su mqm -c <command to run as mqm>


PS. I do not know why you are being prompted for a password in that script - I created the identical script on my system, and it changed users as it was supposed to.
0
 
LVL 21

Accepted Solution

by:
Mazdajai earned 500 total points
ID: 39663600
You can do this with sudo.

Edit /etc/sudoers wit the following line -
<userid> ALL=(ALL)       NOPASSWD: ALL

Open in new window

sudo su - mqm -c command

Open in new window

0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linux Hosting 16 107
Apache LDAP Authentication 20 72
plsql job on oracle 18 111
CentOs root password/fsck issue 7 62
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question