Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Howto run a script as root

  1. #1
    Member registered user
    Join Date
    Jan 2003
    Posts
    54

    Howto run a script as root

    I created a script as root to remove some symlinks and to copy some files instead of them.

    The problem is that I am not able to run the script as root.
    As user knoppix I am able to run the script, but do not have the rights to remove the symlinks.
    I want to save the script on the harddisk, so it will be there all the time.
    As soon as I save it on harddisk the ownership seems to change to knoppix:knoppix
    I tried as root:
    Code:
    chown knoppix:knoppix filename
    ownership did not change.
    I tried as root:
    chmod u+x filename
    and
    chmod +x filename
    root could still not run the script, while knoppix can, but does not have enough rights.

    What can I do about this?

    Another question is: how do I get the answer on the question if knoppix should remove the symlink answered with yes without human interferance.

  2. #2
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    Auckland, New Zealand
    Posts
    818
    sudo script

  3. #3
    Member registered user tuxtom's Avatar
    Join Date
    Nov 2002
    Location
    hamburg.de
    Posts
    32

    Re: Howto run a script as root

    Quote Originally Posted by Hermanh
    I tried as root:
    Code:
    chown knoppix:knoppix filename
    ownership did not change.
    I think you should issue a
    Code:
    chown root:root filename
    or try (as root):
    Code:
    # chmod 777 filename
    tom

  4. #4
    Member registered user
    Join Date
    Jan 2003
    Posts
    54
    Thanks for those answers. I tried them both.

    When I do as root:
    Code:
    chmod 777 filename
    I still can not run the script

    When I do as root:
    Code:
    chown root:root filename
    I get:
    Code:
    chown: changing ownership of 'filename': operation not permitted
    Also
    Code:
    sudo filename
    does not work as root or as knoppix.

    I've started knoppix with the cheatcode knoppix 2 to stay in textmode.
    After the script has run the knoppix-box will function as ftp-server.

  5. #5
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    Auckland, New Zealand
    Posts
    818
    maybe put
    sudo su
    at the top of the script
    or put
    sudo rm / sudo ln etc

    what kind of script? and you are running ./script.sh ?
    what happens with
    sudo ./script.sh ?

  6. #6
    Member registered user
    Join Date
    Jan 2003
    Posts
    54
    When I do as root:
    Code:
    cp /mnt/hda1/filename /etc/filename
    the onwnership of the new file is root:root.
    Still I can not run the script as root, not even when I do as root:
    Code:
    chmod u+x filename
    or
    Code:
    chmod +x filename
    or
    Code:
    chmod 777 filename
    Which should work according to several Linux howto's.

    I get a message:
    Code:
    bash: filename: command not found
    The file exists
    When I do:
    Code:
    ls -l filename
    I get
    Code:
    -rwxrwxrwx    1  root root   549 jan 26 15:25 filename
    ('filename' is colored green)
    Is user knoppix using another shell or something like that?

  7. #7
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    Auckland, New Zealand
    Posts
    818
    you have to do
    Code:
    ./filename
    not just
    Code:
    filename

  8. #8
    Member registered user
    Join Date
    Jan 2003
    Posts
    54
    thanks, the script is running.
    Code:
    ./filename
    did do it. I did not expect that because it runned as knoppix using just
    Code:
    filename
    Another question is: how do I get the answer on the question if knoppix should remove the symlink answered with yes without human interferance.
    Has one of you also the answer for the second part of my question?

  9. #9
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    Auckland, New Zealand
    Posts
    818
    Another question is: how do I get the answer on the question if knoppix should remove the symlink answered with yes without human interferance.
    you mean
    rm -f ?

  10. #10
    Senior Member registered user
    Join Date
    Jan 2003
    Location
    Podunk, Idaho, USA
    Posts
    470
    I'm going from memory, but I saw a post either on this forum or on the linuxtag knoppix forum about a user that could not run scripts. IIRC he had to:

    /bin/bash script

    rock

Page 1 of 2 12 LastLast

Similar Threads

  1. need MIDI howto
    By redss in forum Ideas
    Replies: 5
    Last Post: 01-06-2005, 02:29 AM
  2. DVD playback howto
    By mzilikazi in forum General Support
    Replies: 0
    Last Post: 07-28-2004, 08:36 PM
  3. HOWTO change PC name
    By A. Jorge Garcia in forum Hdd Install / Debian / Apt
    Replies: 3
    Last Post: 07-03-2004, 06:22 PM
  4. Howto: Script to put the device shortcuts on the desktop
    By fabriloup in forum General Support
    Replies: 1
    Last Post: 09-13-2003, 10:28 AM
  5. HOWTO: Script to burn MP3 files to CD
    By Dave_Bechtel in forum General Support
    Replies: 0
    Last Post: 06-04-2003, 11:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Intel Xeon E5-2699 V4 2.20GHz 55M 22-CORES LGA2011-3 Server Processor 145W SR2JS picture

Intel Xeon E5-2699 V4 2.20GHz 55M 22-CORES LGA2011-3 Server Processor 145W SR2JS

$84.49



Dell EMC PowerEdge R440 Xeon silver 4215 2.5GHz 16 GB ram  2x 550W PSU No HDD picture

Dell EMC PowerEdge R440 Xeon silver 4215 2.5GHz 16 GB ram 2x 550W PSU No HDD

$275.00



Dell Precision T5820 950W Workstation 4.00GHz W-2125 No RAM/ GPU/ HDD/ OS picture

Dell Precision T5820 950W Workstation 4.00GHz W-2125 No RAM/ GPU/ HDD/ OS

$144.98



Intel(R) Xeon(R) CPU @ 3.30GHz, 4 Core(s), 32 GB RAM, 1 GB  HDD Workstation 3 picture

Intel(R) Xeon(R) CPU @ 3.30GHz, 4 Core(s), 32 GB RAM, 1 GB HDD Workstation 3

$145.00



HP Z8 G4 Z8G4 Barebone Workstation w/ Intel Xeon Silver - No HDD No RAM No GPU picture

HP Z8 G4 Z8G4 Barebone Workstation w/ Intel Xeon Silver - No HDD No RAM No GPU

$449.99



Lenovo ThinkStation P520 Intel Xeon W-2123 3.6GHz 900W - NO RAM/ GPU/ HDD/ OS picture

Lenovo ThinkStation P520 Intel Xeon W-2123 3.6GHz 900W - NO RAM/ GPU/ HDD/ OS

$189.98



Matched Pair _ Intel Xeon E5-2698 V4 2.2GHz 20-Core Processor CPU LGA2011 SR2JW picture

Matched Pair _ Intel Xeon E5-2698 V4 2.2GHz 20-Core Processor CPU LGA2011 SR2JW

$94.99



Intel Xeon Gold 6230 2.1 GHz Processor - SRF8W picture

Intel Xeon Gold 6230 2.1 GHz Processor - SRF8W

$29.00



Supermicro 1027GR-TSF 1U Rackmount Server 2x Xeon 2.3GHz 128GB DDR3 picture

Supermicro 1027GR-TSF 1U Rackmount Server 2x Xeon 2.3GHz 128GB DDR3

$219.99



Intel Xeon Processor E5-2687W V4 SR2NA 3.00GHz Broadwell 160W LGA2011 12-Core picture

Intel Xeon Processor E5-2687W V4 SR2NA 3.00GHz Broadwell 160W LGA2011 12-Core

$36.00