This is the old SliTaz forum - Please use the main forum.slitaz.org

define shell profile for root
  • joe_2000joe_2000 February 2011
    Ok guys, I give up :-)

    This is probably a very stupid question but I've spent several hours today and yesterday now searching this forum and the web in general, but couldn't figure it out.

    I want to define aliases for the root account. I tried creating a .profile, a .login and a .bashrc in the /root/
    I also tried defining the in aliases /etc/profile. Everything is ignored. What am I missing? Can't believe that slitaz doesn't allow for this...
    When I source them it obviously works but when I exit the shell and su back in I it's not working anymore...

    Thanks in advance for help!
  • Trixar_zaTrixar_za February 2011
    Which aliases are you trying to add?
  • joe_2000joe_2000 February 2011
    Hi Trixar, thanks for the reply.

    Standard stuff actually.
    Things like la for ls -a. But I also tried to put a line
    echo "this file was read at login"
    to see if the file is actually read. But it seems to be completely ignored.
    For the normal user everything works without problems.
  • claudineiclaudinei February 2011
    Hi,

    putting your aliases in the /root/.profile file should work:


    I'm using cooking and it works. 
  • mojomojo February 2011
    slitaz-3.0 or cooking:
    Can't login to root from xterm(Login incorrect),have to use sudo su but alias doesn't work.
    Login for tux or another regular user works from xterm
    Adding alias to /root/.profile only works after login root from console(screen=text)or vt (ctrl-alt-F1->F6)
  • Trixar_zaTrixar_za February 2011
    @mojo er... what? Do you have the sudo package installed and setup correctly? Are you doing su root <enter/return key> or are using just su <enter/return key>? Are you using the correct password? In SliTaz you can set both the root and user password to be different - in my case theirs the same.

    @joe_2000 - try the following:
    1. su to root
    2. leafpad la
    3. Write the following in leafpad and save:
    #!/bin/sh
    ls -a $1
    4. chmod +x la
    5. mv la /bin

    and now you should have an la command that works like you'd expect - it uses a cheap bash script to get things to work. This will work with or without a path specified. You can use similar scripts to create aliases like this and they'll work instantly. Hope it helps
  • joe_2000joe_2000 February 2011
    Hi Trixar!
    Thank you for your hint. Yes that would be an alternative but I tend to define many aliases :-)

    However, while reading on something unrelated on the web today I came across something about the files being read upon login depending on whether or not the shell is started as a login shell using "su -" rather than only "su"

    And yes - when I start the root shell using "su -s" the files /etc/profile and /root/.profile are read! So I could define an alias su='su -s' in my normal user .profile and that should do it.
    Is that "quick and dirty"? Am I missing anything? Introducing security risks or whatever?
    And to be honest it is still bothering me I don't seem to have properly understood the issue. The bash manpage also suggests a .bash_profile so I tried that as well - without success.

    Thanks in advance!
  • joe_2000joe_2000 February 2011
    edit: I meant "su -", not "su -s". sorry
  • mojomojo February 2011
    @Trixar_za
    My mistake was using login command :P
    When I'm logged in with slim as user tux joe_2000 login directions for root shell works in xterm.
    I have sudo installed with NOPASSWD, it skips the password prompt,goes straight to root prompt.
    tux@slitaz:~$sudo su -
    (enter)
    root@slitaz:~#
    My alias in /root/.profile works.
    When logged into xsession as root with slim and open xterm alias doesn't work.
    I have to exit which kills xterm and reopen xterm for alias to work.
  • OldGuyOldGuy February 2011
    I had a quit look in what busybox would/could recognize:
    ( strings /bin/busybox | grep -iE "profil|bash|login" )

    It seems that busybox only recognizes /etc/profile and .profile. :-(

    Therefore you shoudn't have any luck with ~/.bash_profile, .~/.bash_login or any off the 'no-login-shell' files like /etc/bash.bashrc or ~/.bashrc.

    Cheers
  • joe_2000joe_2000 February 2011
    Ok, thanks for these additional explanations.
  • Trixar_zaTrixar_za February 2011
    Possibly because it uses BusyBox's Ash shell instead of Bash?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

SliTaz Social