LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   .login file (https://www.linuxquestions.org/questions/linux-newbie-8/login-file-936579/)

Micky12345 03-26-2012 08:23 PM

.login file
 
My terminal want to display username, time and date whenever logged into the terminal.
For that i made a script which displays username and date
My script is as follows
Code:

who am i | cut -d " " -f1
date

This sript name is userdate
I want to run this script whenevr i log in
So i want to put 'userdate' into .login file

But how can i do that
Where can i find .login file

whansard 03-26-2012 08:27 PM

look in your home directory.

divyashree 03-26-2012 10:38 PM

Quote:

Originally Posted by Micky12345 (Post 4637137)
My terminal want to display username, time and date whenever logged into the terminal.
For that i made a script which displays username and date
My script is as follows
Code:

who am i | cut -d " " -f1
date

This sript name is userdate
I want to run this script whenevr i log in
So i want to put 'userdate' into .login file

But how can i do that
Where can i find .login file


run ls -la in you r home dir , it may be there.
if not there create a file on that name and and put the script in that file, make it executable and make an entry in profile/rc file in your home dir to execute .login.

catkin 03-26-2012 10:46 PM

In case you are using bash ...

Bash does not use a .login file. It uses the first (if any) of ~/.bash_profile, ~/.bash_login and ~/.profile

Micky12345 03-27-2012 02:45 AM

I got login file inside bin
i copied my file into login


but then also when i am logging in i didnt get the desired output

catkin 03-27-2012 04:34 AM

Changing files in /bin (or /usr/bin, /sbin and /usr/sbin) can break your system. Even if it works, such can be lost on routine system upgrade.

It is not necessary to change /bin/login to achieve what you want. Earlier replies in this thread have suggested appropriate ways.

Micky12345 03-27-2012 07:33 PM

make an entry in profile/rc file in your home dir to execute .login.


HOW ITS POSSIBLE?

suicidaleggroll 03-27-2012 08:02 PM

What shell are you running (sh, bash, tcsh, etc.)?

divyashree 03-28-2012 02:27 AM

Quote:

Originally Posted by Micky12345 (Post 4638215)
make an entry in profile/rc file in your home dir to execute .login.


HOW ITS POSSIBLE?

Dear Micky, what shell do you use ?

Run this to get:

Quote:

echo $SHELL
If BASH then the files are : ~/.bashrc and ~/.bash-profile
If ksh the the files are : ~/.profile and ~/.kshrc or ~/.login file may be there.
if csh the files are : ~/.cshrc

You can add an entry like this:

Code:

. ~/.login
in the profile/rc file in your home dir if you dont have .login.

where .login contains the script you want to excute.

When you login the these rc/profile file executes whatever written in them.


All times are GMT -5. The time now is 04:57 AM.