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

Thread: Commands in Bashrc

  1. #1
    Join Date
    Oct 2013
    Beans
    25

    Commands in Bashrc

    Hi,

    I've put two commands in bashrc but only one of them will execute.

    How can we execute both?


    - cd /home/user/Desktop
    - sudo -i

  2. #2
    Join Date
    Apr 2012
    Beans
    7,256

    Re: Two commands in Bashrc

    What exactly are you trying to achieve? Putting sudo -i in your .bashrc file sounds like a TERRIBLE idea to me

    FWIW it almost certainly IS executing both commands - however 'sudo -i' changes to root's home directory (/root) immediately negating the previous 'cd'

  3. #3
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Two commands in Bashrc

    They probably are both executing but the -i in makes the new shell with the same settings as if it were a fresh login. So that overrides the previous cd. Try it without the -i, unless there is a specific reason you have it.

  4. #4
    Join Date
    Oct 2013
    Beans
    25

    Re: Two commands in Bashrc

    Thanks for the answers.

    I'm trying to open terminal as root.

    Without -i it just spits out the options and with -s it freezes up.

  5. #5
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Two commands in Bashrc

    Try using it to launch a shell instead.

    Code:
    cd /home/user/Desktop
    sudo /bin/bash
    Or are you talking about launching the graphical terminal?

    Code:
    gksudo "gnome-terminal --working-directory=/home/user/Desktop"

  6. #6
    Join Date
    Oct 2013
    Beans
    25

    Re: Two commands in Bashrc

    No, thanks, was talking about command line.

    sudo /bin/bash asks for password but then it freezes up too.

  7. #7
    Join Date
    Oct 2013
    Beans
    25

    Re: Two commands in Bashrc

    It's working if I do a 'Ctrl-c' after it. Thanks!
    Last edited by ubu88; December 1st, 2013 at 07:09 PM.

  8. #8
    Join Date
    Sep 2007
    Location
    Oklahoma, USA
    Beans
    2,378
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Two commands in Bashrc

    Try your original commands, but swap their sequence so that you do the "sudo" first. That may not work, because of the switch to root being immediate and thus cutting off access to the rest of .bashrc, but if .bashrc is executing from RAM rather than from the disk, it might do what you want. In any case, were I doing this, I would make these the final two commands in the file. And as noted above, it's a really BAD idea since it puts you in root mode every time you log in!
    --
    Jim Kyle in Oklahoma, USA
    Linux Counter #259718
    Howto mark thread: https://wiki.ubuntu.com/UnansweredPo.../SolvedThreads

  9. #9
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Two commands in Bashrc

    Having it jump directly to root isn't the best idea. What problem are you actually trying to solve?

  10. #10
    Join Date
    Apr 2011
    Location
    Maryland
    Beans
    1,461
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Two commands in Bashrc

    Quote Originally Posted by Lars Noodén View Post
    Having it jump directly to root isn't the best idea. What problem are you actually trying to solve?
    This +1,000,000! Why would you want to set it up so that each terminal session automatically opens up a root shell? That's not very wise at all, and given the simplicity of switching to a root login whenever you need, there's really never a reason to do this.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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