werid behavior of sudo

view full story

http://stackoverflow.com – In my linux machine, path are configured as follows non-root user: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/java root user: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin when i tried to sudo echo $PATH it shows non-root user path only not root path but when i put echo $PATH in script and tried to execute with sudo, it gives root path. Do anyone knows this reason? Actually sudo is for executing command as root but in my first case it is not working fine. (HowTos)