I included a command set -o vi & sudo -l user -c script in profile.d and /etc/profile. unfortunately the script has some command that logs me out every time I try to login from all users including root user. this is happening from GUI. can I login to prompt directly? or is there an alternate way out?
If you haven't rebooted the system, your login shell for root is bash , and someone is still logged in, commandeer their terminal and try:
su - root login --noprofile
This will leave you with a bash running as root without the benefit of the actions normally run by /etc/profile , ~/.bash_profile , ~/.bash_login , and ~/.profile . With any luck, that would enable you to remove the disastrous changes you made to /etc/profile .
If root's login shell is not bash , check the man page for the shell root uses on your system and see if it provides a similar way to disable using /etc/profile when you login.
Thanks for the replies, unfortunately I couldn't find a way out so I had to blow it out(forutnately new machine). However, I have to define the same script to run at the startup. Its an executable(db2start). What do you recommend?
I recommend that you seriously reconsider what you're trying to do. Why in the world would you want every user who logs in to a system to be required to assume the duties of database administrator for that system???
If you want to do something when the system reboots, add an init script that runs when the system starts running in multi-user mode (after the necessary filesystems have been mounted, network interfaces initialized, ...).
Can you share the script you are thinking of putting in place? There could be something simple that is missing, such as you source a file that doesn't exist, or an error that is not handled in some way. A description of what you are trying to achieve would be useful to so we can understand why you feel the need to do this.
Hopefully we can then suggest ways to protect yourself.