Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Wednesday, November 9, 2011

gdb uses your SHELL environment variable!

As I started using a new Ubuntu installation on a 12-core Intel machine, I realized gdb was acting strange. It reads the executable file just fine, but had trouble running the executable - when I said run and hit the return key, it took me back to the command prompt! The executable didn't seem to run at all, although ps command showed it was actually running.


With some help from a friend I decided to change the SHELL environment variable to show the current shell under which gdb was running  - /bin/bash. Voila! gdb started working as expected.

I wondered what was going on and did some online research. According to this resource here:
"Your SHELL environment variable (if it exists) specifies what shell GDB uses. If you do not define SHELL, GDB uses /bin/sh."

That means, when you run the program under gdb, gdb starts executing it under the shell specified by SHELL environment variable; and if it's not the current shell, then it will execute the program in the background.

Friday, March 19, 2010

Changing the default shell without admin privileges

Whenever I get access to a machine for the first time, I always have to search for ways to change my default shell. Most suggestions on the web don't work for me (limited user privileges, missing tools in installation, etc.), so I decided to post what always worked for me so that I (and you) can find later.
Add "exec /bin/bash" (or whatever shell you want to use) to the end of the .login file.
What this command does is actually launching bash from the default shell. Since this is done automatically, the launch process is seamless.
Other people suggest using the following options:
Edit /etc/passwd file and change the last field of the line corresponding to the user whose shell you want to change. This option is useless without administrator privileges.


Use one of the following commands:
chsh -s /bin/bash
usermod -s /bin/bash username
ypchsh, then type the path to the shell.
Next time I know what to do :)