1834149 Members
2329 Online
110064 Solutions
New Discussion

su problem

 
SOLVED
Go to solution
Ryan Ma
Frequent Advisor

su problem

When I submit the following command, I get this result.

# su - user -c "ls"
(c)Copyright 1983-1997 Hewlett-Packard Co., All Rights Reserved.
(c)Copyright 1979, 1980, 1983, 1985-1993 The Regents of the Univ. of California
...
Technical Data and Computer Software clause in DFARS 252.227-7013.


Hewlett-Packard Company
...
forth in FAR 52.227-19(c)(1,2).
You have mail.
test1.txt test2.txt
test3.txt test4.txt
logout
#


How can I run the command so that I will not get the license, copyright message?

Thanks.
3 REPLIES 3
Frank Li
Trusted Contributor

Re: su problem


su user -c "ls"

can do it.
Hi Friend
Michael Tully
Honored Contributor
Solution

Re: su problem

Hi,

Comment out the "cat /etc/copyright"
message in /etc/profile

Regards
-Michael
Anyone for a Mutiny ?
someone_4
Honored Contributor

Re: su problem

Hello

su user -c "ls"
will work for the ls command but if you read the man pages for the command su it will tell you that without the - you will become user while retaining the previously exported environment. By doing
su - user -c "ls"
It says you become user but change the environment to what would be expected if the user had originally logged in.And will execute command and its arguments using the temporary environment and permissions of user. This is why the - option is important when you do an su for the user root. Because the non root user would not have permissions to execute a root command.
You can always do an su -d user
wich will promt you for a password but not give you the login style promts. And you will stay logged in as that user until you exit out of that user name. I suggest the best way would be to do what Michael recommends

Richard