Calling a script from within rc.local does not work.
Hi,
I have a simple script names 'aliases' under /home/oferu/: #!/bin/sh alias cdforms='cd /usr/local/forms' alias cdhome='cd /home/oferu' In rc.local, on the last line I have source /home/oferu/aliases But after I boot, the aliases do not exist. Why? Thanks. |
I'm guessing that rc.local, like any scripts in /etc/rc.d (or /etc/init.d for that matter) only get executed when the runlevel changes. So, yes, the script probably does run and sources your aliases stuff.
However, the aliases settings are not retained to your login shell probably. So, when you start a shell, you will not inherit them either. To fix this, put the "source ..." command not in /etc/rc.local but rather in /home/you/.profile, /home/you/.<your_shell>rc (ie /home/you/.bashrc) if they are only to be applied to your user. If you want to apply the aliases for all users, put them in /etc/profile or /etc/<some_shell>rc (ie /etc/bashrc). |
If you want the user oferu to be able to use those aliases, you should probably place the commands in /home/oferu/.profile, /home/oferu/.bash_profile or /home/oferu/.alias, depending on your configuration. There's also a file for system-wide settings like these (probably /etc/profile).
Edit: Well, at least the answer I gave looks similar to that of timmeke:D |
hi,
I would do it like this: 1st: remove the first line from "/home/oferu/aliases" which is "#!/bin/sh" 2nd: instead of "source /home/oferu/aliases" use ". /home/oferu/aliases" (dot space filename), this is the include statement for bash. it should work this way. edit: NOTE: source command will execute the command line given to it and exit (like exec command), any commands below the source command in your rc.local will not be executed. Regards. |
Quote:
Quote:
Code:
`. (a period)' As timmeke and spirit receiver have noted, aliases set from within a startup shell script (or any shell script, for that matter) will not be inherited by the login shell. Simply moving the source (or .) line into /etc/profile or ~/.profile will solve your problem. |
Thank You all for your quick replies.
|
home directory
To change quickly to your home directory from anywhere you can do this:
cd ~ A small thing I know, but it could be worthwhile!:D |
@worzel68:
Code:
cd |
Excellent!! ha ha ha ha
Maybe we should explain to oferu that one can use the ~ to expand to one's home directory like this: instead of; cd /home/dave/kdevelop or cd cd kdevelop I could do this cd ~/kdevelop also one can join commands together with a semi-colon like this: cd; ls -l or just do this ls -l ~ there are many ways of doing stuff |
New and simple
Nice to learn new and simple little commands that make navigation easier.
Thanks all. |
All times are GMT -5. The time now is 08:44 PM. |