sudo command not found when i ssh into the server

Collapse

Unconfigured Ad Widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Jimmy_Carter
    Member
    • Feb 2025
    • 49

    sudo command not found when i ssh into the server

    VPS Hosting
    Hi,
    I am trying to install composer on my server so that i can host my Laravel project onto it. I ssh into the server and after installation of composer when I run sudo mv composer.phar /usr/local/bin/composer I am getting a message in the terminal:

    -bash: sudo: command not found


    I need some help.

    Thank you in advance
  • Christian J
    Senior Member
    • Sep 2022
    • 168

    #2
    The error "-bash: sudo: command not found" is likely due to:
    • Missing sudo
    • User not in the sudoers group
    Steps to Fix:

    1. Check if sudo is Installed

    sudo --version
    • If there is no output, it means sudo is not installed.
    • If sudo is installed but still not found, it may not be in the system's PATH.
    2. Switch to Root User (If Possible)


    If you have root access, try switching to root and running the command without sudo:

    su -

    mv composer.phar /usr/local/bin/composer

    Then exit root mode using:

    exit

    3. Install sudo (If Not Installed)

    If sudo is missing, install it based on your Linux distribution:

    For Debian/Ubuntu-based servers

    su -c "apt update && apt install sudo -y"

    Once installed, exit the root shell and retry the command.

    4. Check Your User Privileges

    If you still can’t use sudo, your user may not be in the sudoers group.

    To add it:

    Switch to root:

    su -

    Add your user to the sudo group (replace yourusername):


    usermod -aG sudo yourusername

    Apply changes:

    su - yourusername

    Now, try running sudo mv composer.phar /usr/local/bin/composer again.

    5. If sudo is Completely Unavailable

    If sudo is completely disabled, log in as root and directly move the file:

    mv composer.phar /usr/local/bin/composer

    chmod +x /usr/local/bin/composer


    Then, verify Composer installation:

    composer --version

    Final Check


    Once Composer is properly installed, navigate to your Laravel project directory and run:

    composer install


    This will install all Laravel dependencies.

    Comment

    Working...
    X