-   Linux - Software (
-   -   login without using .profile (

shobhit 05-28-2007 08:30 AM

login without using .profile
Have a very simple problem, which maybe someone has already encountered and resolved.
Is there anyway you can login to a box, with a user id, without executing its .profile file. 05-28-2007 09:31 AM

No. You can, however, modify .profile to ask the user whether he wants to do the stuff therein. With some C programming skills, you can even get .profile to even time out, so that if the user doesn't respond in, say, five seconds, the stuff gets executed anyway.

Hope this helps.

shobhit 05-29-2007 11:03 PM

This sounds promising.
Can you further elaborate on this.
I am fairly good in C and shell, so I may be able to do what is needed.
But I need to know what I need to do :-) 05-31-2007 05:24 PM

This seems to be divided into two parts.

The first part is to modify file .profile so that it asks the user whether he wants to execute its content.

The second part is to modify that so it times out after so many seconds, and just goes ahead and does the script.

Since you're familiar with bash scripts, use the if and read statements to get what you need. If you need to get even more familiar, google for this:


bash script tutorial
You'll find a host of resources there.

When you have that working, if you wish to push along to the part where response timeout is involved, you'll probably have to do something more advanced. I'd recommend C for that, especially since you're already familiar with it. I'd be happy to help you with that once you have the basic stuff done in the script.

Hope this helps. Have fun!

chrism01 05-31-2007 08:01 PM

1. why would you not want to run the .profile??
2. .profile is for the ksh shell; do you mean .bash_profile (bash shell)?

dasy2k1 06-01-2007 06:22 AM

try logging on a sombody elce, (their profile gets used) the su to whatever user you want

i regually do this to remotly log on to some old unix boxes at work with telnet so that the .cshrec does not get run as for the main user it tries to start a system, which you ahve to be at a graphical login to use, and so gives you and error and tehn logs you out 06-01-2007 12:14 PM

As to the name of the file in question, I quote from the O'Reilly bash book by Cameron Newham and Bill Rosenblatt:


bash allows two synonyms for .bash_profile: .bash_login, derived from the C shell's file .login, and .profile, derived from the Bourne shell and Korn shell files named .profile. Only one of these three is read when you log in. If .bash_profile doesn't exist in your home directory, then bash will look for .bash_login. If that doesn't exist it will look for .profile.

One advantage of bash's ability to look for either synonym is that you can retain your .profile if you have been using the Bourne shell. If you need to add bash-specific commands, you can put them in .bash_profile followed by the command source .profile. When you log in, all the bash-specific commands will be executed, and bash will source .profile, executing the remaining commands.

shobhit 06-01-2007 10:53 PM

I see's point, about putting the whole of .profile in an if condition. But I think I did not make the problem clear. What if my .profile contains 'exit' in it. I get thrown out as soon as I login!!!!
Getting root to modify my .profile is an option, is there something else?

A little clarification I am working in ksh and not bash, so .profile is what I want. 06-02-2007 12:39 PM

If that really is your situation, that you're running ksh and your .profile is executing an exit so you can't get all the way logged in, I can think of only one way to avoid going to a root guy to fix this. If you're working in a company whose system administrator is kinda testy, you might want to do just this:

Go to a friend who has a different account. Explain the situation. Ask him to log in to his account, do a


su fred
at the shell prompt, and then ask him to


cd home_directory_of_fred
mv -i .profile old_profile

and then ask him to exit twice.

You'll need to give him your password, so change it when you're done.

Hope this helps.

All times are GMT -5. The time now is 03:25 AM.