Profile.d script logs out

Hi,

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?

Many Thanks,

Can you boot the system in single user mode? The prompt on the console is root user.
I would guess not, but I do not know for sure.

If not you will have to find a way to boot using other media like a DVD or maybe a USB stick. Then mount the system drive as something else.

Either way: edit whatever you changed.

Consider creating alternate boot environments just for this kind of thing.

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.

Good luck...

1 Like

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?

Experiment with putting it in a user's private profile first, before you try putting it in the system one.

I don't suppose putting it in a subshell stops it from quitting, i.e. ( sudo -l user command ) ; true

Or perhaps you have a shell option enabled which causes the user shell to exit on any error.

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.

Robin

If you need an init script to start a DB2 instance at system boot you can use this minimalistic script:

#   chkconfig: - 91 09
DB2BASE=/opt/ibm/db2/V9.7.5
DB2INST=db2inst1
case "$1" in
    start) $DB2BASE/bin/db2gcf -u -i $DB2INST;;
    stop) $DB2BASE/bin/db2gcf -d -i $DB2INST;;
esac

Install this script in /etc/init.d and name it after the DB2 instance (db2inst1, for example) Then you can start DB2 with

service db2inst1 start

To activate the service at boot time use

chkconfig db2inst1 on

If you have RHEL 7.x and want to use a systemd service, you can use this service description:

[Unit]
Description=DB2 Instance db2inst1
[Service]
Type=forking
ExecStart=/opt/ibm/db2/V10.5/bin/db2gcf -u -i db2inst1
ExecStop=/opt/ibm/db2/V10.5/bin/db2gcf -d -i db2inst1
[Install]
WantedBy=multi-user.target

Copy this file to /usr/lib/systemd/system/db2inst1.service , then run

systemctl daemon-reload
systemctl enable db2inst1
systemctl start db2inst1

You will have to adjust the instance name and the directory where DB2 is installed according to your needs.