export is not working on command prompt

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
devarishi
Forum Contributor
Posts: 101
Joined: Fri Feb 05, 2010 7:15 pm

export is not working on command prompt

Post by devarishi »

Hi,


The command export is working inside a shell script, but when I type it at the command prompt / terminal it doesn't work. "export: The command not found" error is displayed instead.

I tried this:

cat test.sh

Code: Select all

abc=123
export abc
echo "Exit status of export abc: $?"

Code: Select all

# bash test.sh
Exit status of export abc: 0
But when I type it at the command prompt:

Code: Select all

# export abc=123
I get the "the command not found" error.

Code: Select all

man export
is also working fine.

I tried it before on my RHEL system and it was working. I have checked the $PATH variable also it is okay. What could be the problem?
devarishi
Forum Contributor
Posts: 101
Joined: Fri Feb 05, 2010 7:15 pm

Re: export is not working on command prompt

Post by devarishi »

The problem is solved now. So, I want to post here the solution I found:

I have just found that my shell got changed to csh and it was creating the problem.

Code: Select all

[root@localhost ~]# grep ^"$USER" /etc/passwd
root:x:0:0:root:/root:/bin/csh
I changed it to bash and the problem was resolved!

Code: Select all

[root@localhost ~]# type export
export is a shell builtin

I experimented with these commands:

Code: Select all

[root@localhost ~]# csh
[root@localhost ~]# type export
type: Command not found.
[root@localhost ~]# bash
[root@localhost ~]# type export
export is a shell builtin
[root@localhost ~]# grep ^"$USER" /etc/passwd
root:x:0:0:root:/root:/bin/bash

The problem has taught me some troubleshooting techniques

Code: Select all

type <command> <enter>
and first where to check when a command is not working, i.e. the log-in shell.

Code: Select all

grep ^"$USER" /etc/passwd
or

Code: Select all

echo $SHELL
Post Reply