Run ls as another user?
-
What's the easiest way to run
ls
as the apache user or similar (which you can't login to)? -
@Pete-S said in Run ls as another user?:
What's the easiest way to run
ls
as the apache user (which you can't login as)?su -u apache ls
-
@travisdh1 said in Run ls as apache user?:
@Pete-S said in Run ls as another user?:
What's the easiest way to run
ls
as the apache user (which you can't login as)?su -u apache ls
Did you mean
sudo
orsu
?Because you can't do
su apache
. You get "This account is currently not available.". -
This post is deleted! -
@Pete-S said in Run ls as another user?:
@travisdh1 said in Run ls as apache user?:
@Pete-S said in Run ls as another user?:
What's the easiest way to run
ls
as the apache user (which you can't login as)?su -u apache ls
Did you mean
sudo
orsu
?Because you can't do
su apache
. You get "This account is currently not available.".I know the
-u apache
is needed to run a command as a user fromsu
orsudo
. I'm thinking the issue might be with the apache account being set to nologin in/etc/passwd
. Just be sure to change the shell entry in passwd back when you finish up. -
@travisdh1 said in Run ls as another user?:
@Pete-S said in Run ls as another user?:
@travisdh1 said in Run ls as apache user?:
@Pete-S said in Run ls as another user?:
What's the easiest way to run
ls
as the apache user (which you can't login as)?su -u apache ls
Did you mean
sudo
orsu
?Because you can't do
su apache
. You get "This account is currently not available.".I know the
-u apache
is needed to run a command as a user fromsu
orsudo
. I'm thinking the issue might be with the apache account being set to nologin in/etc/passwd
. Just be sure to change the shell entry in passwd back when you finish up.I'd rather not change anything on the user account if possible.
Accounts such as apache that can't login, doesn't have a shell etc, are used for daemons, but I want to be able to run commands as that daemon user for troubleshooting. I'm thinking that if I am root there should be a way to do that.
-
@Pete-S said in Run ls as another user?:
@travisdh1 said in Run ls as another user?:
@Pete-S said in Run ls as another user?:
@travisdh1 said in Run ls as apache user?:
@Pete-S said in Run ls as another user?:
What's the easiest way to run
ls
as the apache user (which you can't login as)?su -u apache ls
Did you mean
sudo
orsu
?Because you can't do
su apache
. You get "This account is currently not available.".I know the
-u apache
is needed to run a command as a user fromsu
orsudo
. I'm thinking the issue might be with the apache account being set to nologin in/etc/passwd
. Just be sure to change the shell entry in passwd back when you finish up.I'd rather not change anything on the user account if possible.
Accounts such as apache that can't login, doesn't have a shell etc, are used for daemons, but I want to be able to run commands as that daemon user for troubleshooting. I'm thinking that if I am root there should be a way to do that.
You'd think so, I just don't know how to do it easily if it's not working with either su or sudo for you.
-
@travisdh1 said in Run ls as another user?:
@Pete-S said in Run ls as another user?:
What's the easiest way to run
ls
as the apache user (which you can't login as)?su -u apache ls
It's ...
sudo -u apache ls
-
@travisdh1 said in Run ls as another user?:
@Pete-S said in Run ls as another user?:
@travisdh1 said in Run ls as apache user?:
@Pete-S said in Run ls as another user?:
What's the easiest way to run
ls
as the apache user (which you can't login as)?su -u apache ls
Did you mean
sudo
orsu
?Because you can't do
su apache
. You get "This account is currently not available.".I know the
-u apache
is needed to run a command as a user fromsu
orsudo
. I'm thinking the issue might be with the apache account being set to nologin in/etc/passwd
. Just be sure to change the shell entry in passwd back when you finish up.-u is the user for either, but sudo is a loginless command and su uses login. To use su like you are thinking, you also need -c to make it a single command. Both will work, but only sudo will work for a non-login user like this without the -c