TheNovice Posted February 1, 2006 Report Share Posted February 1, 2006 I am going through some tutorials and one of them was to modify the .bash_profile in order to add some commands. I have entered the following one but it is not working any ideas why?: alias today='date +"%A, %B %-d, %Y"' It is supposed to give you the date with nice formatting. Thanks TheNovice Quote Link to comment Share on other sites More sharing options...
arctic Posted February 1, 2006 Report Share Posted February 1, 2006 Did you do this as root or normal user? AFAIK, you need to be root for launching alias. Quote Link to comment Share on other sites More sharing options...
pmpatrick Posted February 1, 2006 Report Share Posted February 1, 2006 Try it after rebooting. Changes to bashrc and bash_profile don't take effect until you reboot. There's a command you can run to make them take effect immediately but I don't recall what it is. Also, in mandriva, user specific aliases are normally put in bashrc IIRC. I think putting them in either file should work however. Quote Link to comment Share on other sites More sharing options...
Guest silverback011 Posted February 1, 2006 Report Share Posted February 1, 2006 You can just issue this in the terminal that you are using: alias today='date +"%A, %B %-d, %Y"' Then when you issue the command 'today' it will work for that terminal. I just tried it on my machine and it works. This is a good way to test out your aliases before you commit to them. You do need root if you are doing this in the system wide configuration file. To make it permanent you need to add it to your bash config file. Instead of rebooting. You can just: source .bashrc If you added it to your user bashrc file. That will read it for the current shell. In Konsole any newly opened terminals will read the new bashrc so you don't need to do that. But for any shells already opened you need to source it. Of course this all assuming you are using the bash shell echo $SHELL will tell you what terminal you are using. I hope this helps. Any other questions just ask. Quote Link to comment Share on other sites More sharing options...
TheNovice Posted February 1, 2006 Author Report Share Posted February 1, 2006 Artic & pmpatrick thanks for the answer but it is still not working. I logged on as root modify the .bash_profile and rebooted but no. It recognises the alias "l" i made (for l=ls -l) but not today. ??? Any other idea? Thanks TheNovice Quote Link to comment Share on other sites More sharing options...
chalex20 Posted February 2, 2006 Report Share Posted February 2, 2006 For system-wide aliases, you need to modify /etc/bashrc or /etc/profile as root. If you modify .bashrc or .bash_profile, there is no need to be root ( unless you want to modify root's .bashrc etc), but the alias would be defined only for the user whose .bashrc is modified. Quote Link to comment Share on other sites More sharing options...
neddie Posted February 2, 2006 Report Share Posted February 2, 2006 Step1: type your alias command directly into the console. Does it give an error or is it ok? Step2: type "today" into your console. Does it recognise your alias? Step3: double check what you put in your bash profile with what just worked in the console. Are you sure the single and double quotes are the right way round? Quote Link to comment Share on other sites More sharing options...
TheNovice Posted February 3, 2006 Author Report Share Posted February 3, 2006 Chalex20, followed your advice and it is working now, thanks a lot! TheNovice PS: Thanks to everybody for their input too Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.