Welcome to the new Linux Foundation Forum!

question about permissions and sudo

hello,

I'm running an unofficial version of Ubuntu/ Crunchbang Linux.

It uses the sudo command. It's driving me a bit nuts trying to get used to sudo. I'm trying to learn how to do bash scripting language and I need some help setting up an environment to learn. I would appreiciate any help with this matter. Preferably, I would like to be able to use a terminal and not have do deal with sudo while I'm in that enviroment. Could I do something like "chroot"? I have a backup partition that I could use. Mount the partition then would I be free of the sudo constraints?

Comments

  • atreyuatreyu Posts: 216
    tw3ak wrote:
    hello,

    I'm running an unofficial version of Ubuntu/ Crunchbang Linux.
    It uses the sudo command. It's driving me a bit nuts trying to get used to sudo. I'm trying to learn how to do bash scripting language and I need some help setting up an environment to learn. I would appreiciate any help with this matter. Preferably, I would like to be able to use a terminal and not have do deal with sudo while I'm in that enviroment. Could I do something like "chroot"? I have a backup partition that I could use. Mount the partition then would I be free of the sudo constraints?

    It sounds like you want to be root - yes? If you aren't very experienced with Linux yet, I would stay away from that. Instead, learn sudo and be comfortable with it. What is your trouble with sudo? Is it using visudo / editing the sudo file (/etc/sudoers)? Or is it using sudo to run commands? Give an example.

    If you really want to avoid using sudo, and don't care about wrecking your filesystem accidentally, just su up to root:
    su -
    

    You will be prompted to enter root's password.
  • tw3aktw3ak Posts: 37
    Ok,

    First I'm a Newb, so I don't know what I want. I would think If I'm the owner of a simple "hello world" script while I'm learning how to script I shouldn't have to sudo to run a script I created in my own home directory??? Unless that script is changing a file I'm not the owner of? or don't I have a clue yet?
  • Goineasy9Goineasy9 Posts: 1,116
    Your correct, you shouldn't need to be root to run a script that you create in your own home directory. Unless ... it requires running a command that is owned by root. For example, if I run "apt-get update" (I use Debian) as a user, it does not run, I need to be root to run that command. If that command is in a script I write, I will need to use sudo to run it in a script. A simple "Hello world" script should not need such a command.
  • atreyuatreyu Posts: 216
    tw3ak wrote:
    Ok,

    First I'm a Newb, so I don't know what I want. I would think If I'm the owner of a simple "hello world" script while I'm learning how to script I shouldn't have to sudo to run a script I created in my own home directory??? Unless that script is changing a file I'm not the owner of? or don't I have a clue yet?

    Okay, so if you're writing a simple script, are you have trouble executing it? Make sure the script is executable:
    chmod +x script.sh
    

    Then you can execute the script like this:
    ./script.sh
    

    Or, you can just run the script without it being executable like this:
    sh script.sh
    

    If that's not the problem, the there is something inside the script that requires root? Show us your script!
  • CCCCCC Posts: 12
    atreyu wrote:
    Okay, so if you're writing a simple script, are you have trouble executing it? Make sure the script is executable:
    chmod +x script.sh
    

    This will make the script executable for all users. (To make the script executable only for the owner of the file, use
    chmod u+x script.sh
    
    )

    To find out whether or not the script is executable, you can use
    ls -l script.h
    
    , which should give you a line starting with a bunch of letters and dashes, something like:
    -rwxrwxrwx
    

    Any of those letters may be replaced by dashes. If none of the x's are there, then your file will not be executable. The first x is whether or not the user that owns the file can execute it; the second x is whether a member of the group that owns the file can execute it; and the last x is whether other people can execute it. (The r's and w's indicate whether or not the owner, group, or others have read and write permissions). If the letter is there, so is the permission; if not, then the permission is absent (and you'll need to chmod it before you can run it).
Sign In or Register to comment.