Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I installed a package s2cmd on my unix machine. It works fine when I run it from the folder it resides in, but it did not run from other locations so I set the PATH using the command export PATH=$PATH:/opt/bitnami/S3Tools/s3cmd-1.5.0-alpha1 there is a file s3cmd inside this folder which has to be executed.

The problem now is when I do a which s3cmd, I get the correct path as output but when I run it using, say sudo s3cmd, it says command not found. If I give the absolute path and try to run it, its runs from any location.

What am I doing wrong?

EDIT : I just noticed that there are 2 PATH variables with the same path. Is that causing the problem? If yes, how do I correct it?

$ set | grep PATH
PATH=/opt/bitnami/rvm/bin:/opt/bitnami/memcached/bin:/opt/bitnami/varnish/bin:/opt/bitnami/redis/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/mercurial/bin:/opt/bitnami/perl/bin:/opt/bitnami/git/bin:/opt/bitnami/nginx/sbin:/opt/bitnami/frameworks/laravel/app/Console:/opt/bitnami/frameworks/cakephp/app/Console:/opt/bitnami/frameworks/codeigniter/bin:/opt/bitnami/frameworks/symfony/bin:/opt/bitnami/frameworks/zendframework/app/Console:/opt/bitnami/sphinx/bin:/opt/bitnami/sqlite/bin:/opt/bitnami/apps/django/bin:/opt/bitnami/php/bin::/opt/bitnami/java/bin:/opt/bitnami/mysql/bin:/opt/bitnami/postgresql/bin:/opt/bitnami/apache2/bin:/opt/bitnami/python/bin:/opt/bitnami/subversion/bin:/opt/bitnami/ruby/bin:/opt/bitnami/common/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/bitnami/S3Tools/s3cmd-1.5.0-alpha1:/opt/bitnami/S3Tools/s3cmd-1.5.0-alpha1
_=PATH                                                                                                                                                                                 
    export PATH;                                                                                                                                                                       
            PATH="$2:$PATH"                                                                                                                                                            
            PATH="$PATH:$2"                                                                                                                                                            
        PATH="${rvm_user_path_prefix}:$PATH";                                                                                                                                          
    PATH="$(printf "%b" "$PATH"           | awk -v RS=: -v ORS=: '!($0 in a){a[$0];print}')";                                                                                          
    PATH="${PATH/%:/}";                                                                                                                                                                
    export PATH;                                                                                                                                                                       
    if printf "%b" "${PATH//:/ }" | GREP_OPTIONS="" \grep -vF "${rvm_bin_path}" > /dev/null 2>&1; then                                                                                 
                PATH="$PATH:${rvm_bin_path}"                                                                                                                                           
                PATH="${rvm_bin_path}:$PATH"                                                                                                                                           
        printf "%b" "export PATH ; PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path}:\$PATH\"\n" > "$file_name";                   
        for variable in rvm_env_string rvm_path rvm_ruby_string rvm_gemset_name RUBY_VERSION GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC MAGLEV_HOME RBXOPT;                                  
    export PATH;                                                                                                                                                                       
            \awk '/PATH/' < "$actual_file";                                                                                                                                            
            rvm_error "Neither md5 nor md5sum were found in the PATH";                                                                                                                 
            rvm_error "Neither md5 nor md5sum were found in the PATH";                                                                                                                 
    export PATH;                                                                                                                                                                       
    PATH=":$PATH:";                                                                                                                                                                    
    PATH="${PATH//:$1:/:}";                                                                                                                                                            
    PATH="${PATH//::/:}";                                                                                                                                                              
    PATH="${PATH%:}";                                                                                                                                                                  
    PATH="${PATH#:}"                                                                                                                                                                   
    PATH="$(printf "%b" "$PATH"           | awk -v RS=: -v ORS=: "/${rvm_path//\//\/}/ {next} {print}")";                                                                              
    PATH="${PATH/%:/}";                                                                                                                                                                
    export PATH;                                                                                                                                                                       
    export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION IRBRC;                                                                                                                          
                rvm_error "Neither sha256sum nor shasum found in the PATH";                                                                                                            
                rvm_error "Neither sha256sum nor shasum found in the PATH";                                                                                                            
        export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION IRBRC;                                                                                                                      
        GEM_PATH="$rvm_ruby_gem_path";                                                                                                                                                 
        unset BUNDLE_PATH;                                                                                                                                                             
            GEM_PATH="$GEM_PATH:$MAGLEV_HOME/lib/maglev/gems/1.8/";                                                                                                                    
            new_path="$GEM_HOME/bin:$rvm_ruby_global_gems_path/bin:$MY_RUBY_HOME/bin:${rvm_bin_path}:$(__rvm_remove_rvm_from_path ;printf "%b" "$PATH")";                              
            new_path="$GEM_HOME/bin:$MY_RUBY_HOME/bin:${rvm_bin_path}:$(__rvm_remove_rvm_from_path ;printf "%b" "$PATH")";                                                             
        export PATH="$new_path";                                                                                                                                                       
    unset GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION IRBRC;                                                                                                                           
    new_path="$(__rvm_remove_rvm_from_path ; printf "%b" "$PATH"):${rvm_bin_path}";                                                                                                    
    new_path="$PATH:${rvm_bin_path}";                                                                                                                                                  
    COMPREPLY=($( eval PATH="$PATH:/sbin" $cmd 2>/dev/null |         awk '/^[^ \t]/ { print $1 }' ));                                                                                  
    if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then                                                                                                                            
    for i in ${CDPATH//:/'                                                                                                                                                             
    if [ "${INFOPATH: -1:1}" == ':' ]; then                                                                                                                                            
        infopath=${INFOPATH}${infopath};                                                                                                                                               
        if [ ${INFOPATH:+set} ]; then                                                                                                                                                  
            infopath=$INFOPATH;                                                                                                                                                        
    COMPREPLY=($( compgen -W "$( PATH="$PATH:/sbin" lsmod |         awk '{if (NR != 1) print $1}' )" -- "$1" ))                                                                        
    [ -z "$classpath" ] && classpath=$CLASSPATH;                                                                                                                                       
    local PATH="$PATH:/sbin:/usr/sbin";                                                                                                                                                
        manpath=$MANPATH;                                                                                                                                                              
    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W         "$( PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur" ))                                                               
    local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin;                                                                                                                                  
    COMPREPLY=("${COMPREPLY[@]}" $( compgen -W         "$( PATH="$PATH:/sbin" ifconfig -a |         sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p'             -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )"         -- "$cur" ))
    COMPREPLY=($( compgen -W         "$( PATH="$PATH:/sbin" sysctl -N -a 2>/dev/null )" -- "$cur" ));                                                                                  
    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W         "$( PATH="$PATH:/sbin" lsusb | awk '{print $6}' )" -- "$cur" ))                                                                 
                        GEM_PATH="$rvm_ruby_gem_home:$rvm_ruby_gem_home${rvm_gemset_separator:-"@"}global";                                                                            
                        export rvm_ruby_gem_home GEM_HOME GEM_PATH;  
share|improve this question

migrated from stackoverflow.com Feb 27 '13 at 21:53

This question came from our site for professional and enthusiast programmers.

1  
When you invoke sudo, the PATH is not normally reset. However it is possible to set an option which resets it. Check if env_reset is set in the sudoers file. –  William Pursell Feb 27 '13 at 20:17
    
you'll have to give us an example of '2 PATH variables with the same path' Edit your question to include the output of set | grep PATH. Good luck. –  shellter Feb 27 '13 at 20:21
    
Note that env_reset may or may not reset PATH, depending on how sudo was compiled. –  William Pursell Feb 27 '13 at 20:31
    
If you’re going to talk about shell builtin commands like set, you need to say what shell you’re using (e.g., bash, csh, ksh, zsh, etc.) It looks like you’re running a shell where the set command outputs all variables and shell functions –– so you’re getting every line from every shell function that contains the string PATH, including some that set PATH. This is a red herring. If you distrust echo "$PATH", try env | grep "^PATH=". –  Scott Feb 27 '13 at 22:53
    
You say, “It works fine when I run it from the folder it resides in.” Do you mean with sudo? What happens if you run it without sudo? … if you run it without sudo from another directory? (If you get a permissions error, that confirms that you set PATH correctly; if you get a “not found” error, that suggests that you didn’t.) Can you do sudo sh, sudo bash, sudo -s, or equivalent? If so, do that and then repeat the other steps (s3cmd, which s3cmd, echo "$PATH"). If your PATH variable has been replaced by a default, go back and try sudo -E to preserve the environment. –  Scott Feb 27 '13 at 22:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.