what is the use of each login related files present in users home directory

# ls -l
total 10
-rw-r--r--   1 dummy2   other        140 Jun 19 21:37 local.cshrc
-rw-r--r--   1 dummy2   other        136 Jun 19 21:37 local.cshrc~
-rw-r--r--   1 dummy2   other        157 Jun 19 21:37 local.login
-rw-r--r--   1 dummy2   other        178 Jun 19 21:37 local.profile
-rw-r--r--   1 dummy2   other        174 Jun 19 21:37 local.profile~
# pwd
/usr/users/dummy2
#

i know .profile is loaded automatically when user logs into his account. what is the user of the remaining files that i have mentioned. i tried to remove all the files. and then logged in back . i saw all files gone but .profile file was automatically created..

My doubt

  1. what is the use of each file mentioned above? do we really need it?
  2. How the .profile file is created automatically?

Strictly speaking none of these are really needed I think,though they may include useful defaults. They don't look like the normal ~/.profile files and so forth that get loaded by ksh or what have you, but remember, shell profiles are scripts -- they can instruct your shell to run commands, including creating files and sourcing things your shell wouldn't otherwise do by default. I think that, either on login or logout, one of your global profile scripts is copying them in from defaults somewhere.

The .cshrc and .login are for csh, the c-shell, which has a very different syntax from the bourne shell hence can't use the same login scripts. It also has its own equivalent of /etc/profile somewhere, though its exact name depends on your variety of csh.

The ~ files look like backups. cp makes files like that when you do cp -b source destination when destination already exists, the old file will be renamed to destination~ and the new one put in its place.

1.so even though i deleted my .profile file from where it is getting created automatically?

  1. If we create some user and later change his home directory to some other directory.. here in my case i changed user home dir to a mount point.. still his login works .. how??? when user tries to login he would intially land up into his home dir and the .profile file present in home dir would be loaded right? but when i change home dir .profile would be present in the old location only. so if edit the old location would i feel the difference in new location. if yes please let me know how.
my old location : /home/dummy2       my new location : /newpartition

local.cshrc, local.login, local.profile are template files which are copied to new user's home directory.

1 Like

It would be one of the global config files, I'm thinking, perhaps /etc/profile or something it includes. See the manual page for your shells for details on what global and local files they use.

There's no magic communication between old location and new, no. But since, as you noticed, it can create new script files when it wants, that's hardly a problem.

1 Like

I think even you delete the .profile file there is /etc/profile for all users on the system , the system first look at user .profile to see if there is any settings, if not he will look at /etc/profile , if no setting it will load without any problems .

1 Like

Thanks as always guys..