Home > other >  How to run a file using sudo bash as root
How to run a file using sudo bash as root

Time:06-23

I'm logging into a linux server that I don't own by using a pem / ppk file on PUTTY and the default user is ubuntu. Works great.

Problem now is that I want to run a script using admin sudo bash start-work.sh but it can't execute line 25 because only start-work.sh is being run as admin, not the content

start-work.sh: line 25: /home/ubuntu/flowable/tomcat/bin/catalina.sh: Permission denied

If I try su - I get asked a password but I have a pem / ppk file

What do I do?

CodePudding user response:

Your script start-work.sh, running as root, attempts to invoke another script /home/ubuntu/flowable/tomcat/bin/catalina.sh.

The error "Permission denied" indicates either:

  1. catalina.sh is not executable, or
  2. one or more directories in the path are not accessible by root

(1) can be fixed by chmod x or similar

(2) can be caused in various ways, such as if the script is on an NFS filesystem mounted with root_squash, or on an sshfs FUSE filesystem mounted without allow_root.

  •  Tags:  
  • bash
  • Related