Question regarding sudo command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Question regarding sudo command
# 1  
Old 07-25-2016
Wrench Question regarding sudo command

Hi,

I get error when

Code:
sudo -u user1 -s -H
(AD: coro.int) Password:
cannot access parent directories

I do not get error when

Code:
sudo -u user1 -i -H

Can you tell me why do i not get error when using -i option instead of -s option with sudo.

Code:
$ uname -a
SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v

Code:
  -i [command]  run a login shell as target user
  -s [command]  run a shell as target user

Basically, can u make it easy for me(layman) to understand the above -i and -s options as to how they are different ?

Please reply in context of the error i am getting and why the pwd command does not yield output with the -s option when it does with the -i option.

Last edited by mohtashims; 07-25-2016 at 10:05 AM..
# 2  
Old 07-25-2016
-i runs a login shell so your current working directory will be set to the home directory of user1. Without this your CWD is not changing and user1 does not have read/execute access on the current directory where sudo is executing from.

Try this and post the output.
Code:
ls -ld .  #check permissions.
cd /tmp
sudo -u user1 -s -H

# 3  
Old 07-25-2016
can anyone answer this question please

Write a script named time that displays the time in standard 12-hour format, rather than 24-hour format. Allow the user to give a -m option to get 24-hour format. For example:
> date
Sun Feb 10 10:56:50 CST 2008

> time
10:56 AM

> date
Sun Feb 10 21:57:07 CST 2008

> time
9:57 PM

> time -m
21:57




Moderator's Comments:
Mod Comment Don't hijack other peoples' posts; create a new one yourself.

Is that a homework question? Those should be posted in Homework & Coursework Questions using the correct form according to the forum rules.

Last edited by RudiC; 07-25-2016 at 03:07 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Sudo question

I am running AIX 6.6.5.115 and am experiencing a problem using sudo. I have shell scripts that I created for our HR user and shell scripts that I created for root administrators. I do have a need to embed a sudo command in the user shell script to run one command as root. However the two... (8 Replies)
Discussion started by: RonDeF
8 Replies

2. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies

3. UNIX for Dummies Questions & Answers

Unable to use the Sudo command. "0509-130 Symbol resolution failed for sudo because:"

Hi! I'm very new to unix, so please keep that in mind with the level of language used if you choose to help :D Thanks! When attempting to use sudo on and AIX machine with oslevel 5.1.0.0, I get the following error: exec(): 0509-036 Cannot load program sudo because of the following errors:... (1 Reply)
Discussion started by: Chloe123
1 Replies

4. Ubuntu

sudo question.

Hello all, Anyone fimilar with su -l command? So when I do su -l <user> any user it doesn't prompt me for password for that user. How I enable sudo to prompt for password whenever su -l command is used. Please help! thanks, -Lalit :D (7 Replies)
Discussion started by: email-lalit
7 Replies

5. Cybersecurity

sudo question

Hi, Is it possible to stop users from copying a login shell, say bash, to another name and then executing it via sudo to gain root priviliges? Normal users have read access to login shells, so they can copy them without any limitations. How can I stop this? Thanks (12 Replies)
Discussion started by: melias
12 Replies

6. Linux

Sudo question

Hello, I would like to know what should I put on the sudoers file to block a determined group os using just one specific command as root? He can do anything, but not execute program X, how can I do this? Thank you very much. (2 Replies)
Discussion started by: Zarnick
2 Replies

7. UNIX for Dummies Questions & Answers

Sudo question

Folks; I have a sudo question: - I have a real user named "greg" and another generic user named "devuser" & application that must be run like start/stop as "devuser" user. Is there a way to: Have user Greg login into the Solaris 10 box as himself then sudo as "devuser" to be able to... (10 Replies)
Discussion started by: Katkota
10 Replies

8. UNIX for Advanced & Expert Users

SUDO question - please help

Hi, I was wondering if someone can give me some pointers about configuring SUDO. I am trying to configure SUDO to have about 30 users run about 200 scripts as a different user. I understand that I can create an User_Alias but how do I give that User_Alias rights to run all the scripts in a certain... (5 Replies)
Discussion started by: sajjad02
5 Replies

9. UNIX for Dummies Questions & Answers

sudo question

how do i go about adding a file to sudo so a user name oracle can run the file??? for some reason my man pages dont have anything for sudo. files sudoers exist in /etc can anyone help this is urgent thank you (1 Reply)
Discussion started by: TRUEST
1 Replies
Login or Register to Ask a Question