when running my script below

as root on test files with

!#/bin/bash -x

I get my env echoed back to the screen, Have I wrote code that
is dangerous??
this dosen't show up if ran as non root user
heres what I get back:

test> ./rootf off
+ alias 'rm=rm -i'
+ alias 'cp=cp -i'
+ alias 'mv=mv -i'
+ '[' -f /etc/bashrc ']'
+ . /etc/bashrc
+++ id -gn
+++ id -un
+++ id -u
++ '[' root = root -a 0 -gt 99 ']'
++ umask 022
++ '[' '' ']'
+ wdir=/root/test
+ tmpd=/tmp
+ file=proftpd.conf
+ word=RootLogin off
+ word2=RootLogin on
+ tfile=temp.txt
+ msg1=Root Can Now FTP In
+ msg2=Root FTP Is Now Unavailable
+ msg3=You Must specifiy on or off
+ '[' off == on ']'
+ '[' off == off ']'
+ cd /root/test
+ cp -f proftpd.conf /tmp
+ sleep 1
+ sed -e 's/RootLogin on/RootLogin off/' proftpd.conf
+ sleep 1
+ mv -f /tmp/temp.txt /root/test/proftpd.conf
+ rm -f /tmp/proftpd.conf
+ echo 'Root FTP Is Now Unavailable'
Root FTP Is Now Unavailable

here is the complete code:

#!/bin/bash -x
#work directory
wdir="/root/test"

#temp directory
tmpd="/tmp"

#original file
file="proftpd.conf"

word="RootLogin off"

word2="RootLogin on"

#temp file
tfile="temp.txt"

#message-1
msg1="Root Can Now FTP In"

#message-2
msg2="Root FTP Is Now Unavailable"

#message-3
msg3="You Must specifiy on or off"

    if [ "$1" == on ]; 
       then
        cd $wdir
        cp -f $file $tmpd
        sed -e "s/$word/$word2/" $file > $tmpd/$tfile
        sleep 1
        mv -f $tmpd/$tfile $wdir/$file
        # rm -f $tmpd/$file
            echo "$msg1"
            
    elif [ "$1" == off ]; 
         then
          cd $wdir
          cp -f $file $tmpd
          sleep 1
          sed -e "s/$word2/$word/" $file > $tmpd/$tfile
          sleep 1
          mv -f $tmpd/$tfile $wdir/$file
          rm -f $tmpd/$file
            echo "$msg2"

     else 
          echo "$msg3"        
   fi

you are using the debugging mode to run the script.....

remove the -x option from the shell and then run the script....

yes, But what I was wondering is,
why the debug out put was showing the env for root, But it doesnt when ran as any other user
Thanks for your reply

i dont understand what u mean.....

"env" what u meant by that???? i dont understand that abbreviation. can u specify the line that u have a doubt with...

sorry..
my shell environment gets echoed back at me..

test> ./rootf off
+ alias 'rm=rm -i'
+ alias 'cp=cp -i'
+ alias 'mv=mv -i'
+ '[' -f /etc/bashrc ']'
+ . /etc/bashrc
+++ id -gn
+++ id -un
+++ id -u
++ '[' root = root -a 0 -gt 99 ']'
++ umask 022
++ '[' '' ']'

in the first line of your script, use #!/bin/bash rather than #!/bin/bash -x and then in your second line of the script give "set -x"

also start the script using bash <script name> or by setting the execute permission of the script and typing the script name alone...

1) change #!/bin/bash to #!/bin/bash -x in the first line and then include "set -x" as the second line of the script

2) a) execute by using bash <script name>
(or)
b) by setting execute permission and typing the script name alone