Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to use rc as my login shell in Ubuntu (using chsh). I noticed that it does not read $HOME/.rcrc file on startup. The documentation says that if invoked as a login shell with either *argv[0] == '-' or with -l flag, it reads the .rcrc file, and I can verify that by executing it directly by $ rc -l. or from zsh ARGV0=-rc /usr/bin/rc.

However when executed on login, it does not read the .rcrc file, and ps output indicates that the shell name is just "rc" not "-rc". Thus my question is, how to get /usr/bin/rc to read .rcrc at startup? and why is ubuntu not prefixing "-" to the shell? Is there a different way to detect the shell is a login shell?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Linux terminal emulators on the GUI do not usually open login shells by default as opposed to e.g. OS X's Terminal.

If you press CtrlAltF1 and log in on the command line, you'll have a login shell whose .rcrc commands will be executed.


In Ubuntu's Terminal, go to Edit » Profile Preferences » Title and Command » Run command as a login shell.

Alternatively, your terminal emulator might support execution of an arbitrary command. Use /usr/bin/rc -l.


You can also create a short script that simply launches rc as a login shell:

#!/bin/bash
exec -l /usr/bin/rc "$@"

This will start bash to execute the script, and the script replaces it completely with rc invoked as a login shell (-l argument), plus all other arguments to this script. You could also add the -c argument to sanitize the environment.

Save as /usr/bin/rcl, make executable, and add a corresponding entry to /etc/shells.

share|improve this answer
    
thanks, so are there any solutions for rc shell to read a user's initialization file (like .rcrc)? What do I do if I want to set the prompt in rc? –  rahul May 4 '12 at 20:28
    
Did you read the last paragraph, I.e. the actual answer? Do that and it'll load rcrc. –  Daniel Beck May 4 '12 at 20:33
    
Yes, unfortunately it does not help me because :- I do not use gnome-terminal (my question was about generic shell and not on a specific emulator). I was hoping for an /etc/passwd based solution. I was able to work around my problem using a wrapper script. But thank you for your answer. It confirmed what I suspected (in other unixes like solaris, the same thing works). –  rahul May 5 '12 at 16:50
    
@blufox Most Terminals should allow execution of specific commands instead of the default shell. /usr/bin/rc -l would work in your case. Of course, this'll circumvent /etc/passwd/chsh. // You could also, of course, write a one-line script that just runs /usr/bin/rc -l, save it to /usr/bin/rcl, make it executable and add it to /etc/shells. Instant new shell! –  Daniel Beck May 5 '12 at 17:02
    
xterm doesn't :), and I used the same solution - a wrapper. –  rahul May 6 '12 at 3:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.