login message shell script?
I am a newbie to the Linux world, and I need to make a shell script that will display "Welcome (username), today is (date), and it is now (time)"
I went and bought 3 books, with not much help there, and did search after search, and can't figure it out. Please Help! thanks jczr2 |
How about this?
Code:
#!/bin/bash |
i have been trying it sort of like that, but where do i save it and what extension do i save it as?
thanks |
Just put the last 2 lines of the code at the end of each users ~/.bash_profile script. Or probably better is to save the above code into a file called "/bin/welcome.sh", chmod the file 755 and then you just need to put "welcome.sh" at the bottom of the users .bash_profile files. This also gives you the option to change it for all users in one place.
If you want to make it the default for new users then put the per user code at the bottom of: /etc/skel/.bash_profile |
i am way confused, i understand the script, but there are 15 users and how do i use pico to edit thst snd add those lines of code to it. I just started learning linux 1 month ago, so i'm not too great with it.
thanks |
you should add it to /etc/bashrc, not to everyones own bashrc.
|
Quote:
As a side note you could also shorten the code I suggested earlier. Code:
date +"Welcome $USER. Today is %A %D, and it is now %R"; |
i will try that, but i want it to say welcome to each username, not a gereric for each one.'
thanks |
The $USER will pull the username that you are logged in as so you can put it in /etc/bashrc like acid_kewpie said if you want.
|
ok, i added the shortened line to the end of the /etc/bashrc in pico, and logged out and back in , and nothing came up.
|
are you using bash? show us what the last few lines of bashrc are.
|
when i open the terminal window, it says welcome root. date +"Today is %A %D, and it is now %R"
at the top of the window. I was hoping to get it on the gui when it starts up |
on what gui??
|
at the terminal, i typed pico /etc/bashrc and a long script came up, and the last line before i added one says : # vim:4:sw=4
|
sorry, in the red hat 7.3 linux gui
|
All times are GMT -5. The time now is 01:09 AM. |