Linux – Unable to execute basic Bash command

Essential Commands Not Found:

  • The ls command is missing, which is a basic utility in Unix-like systems.
  • The nautilus command is also not found, and attempting to install it resulted in further issues.

Shell Problem:

  • When attempting to switch to csh (C shell), the command is also unavailable.
  • This indicates that the shell environment is not properly configured or essential packages are missing.

General Package/System Issues:

  • The server might be in a minimal installation state or lacks critical tools and utilities.
  • It’s possible that the PATH environment variable is misconfigured, leading to the inability to locate standard system commands.

Dependency or Corruption:

  • If the server was recently updated or reconfigured, there may have been issues with the package manager or repository settings, leading to missing binaries.

Solution

Check PATH:

  • Run echo $PATH to verify if the environment paths are set correctly.
  • Typically, it should include paths like /bin, /usr/bin, /sbin, /usr/sbin.
  • nano ~/.bashrc
  • export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • source ~/.bashrc

Reinstall Core Utilities:

  • Try running sudo yum groupinstall "Development Tools" or sudo dnf groupinstall "Development Tools" to restore essential utilities, assuming it’s Red Hat-based.

Ensure Package Manager Functionality:

  • Test if the package manager works: sudo yum update or sudo dnf update
  • If it fails, check for repository issues.

Inspect Shell Configuration:

  • Review the default shell configuration in /etc/passwd for the user rakesh.
  • Revert to bash or another functioning chsh -s /bin/bash username

Check System State:

  • Verify the integrity of installed packages sudo rpm --verify -a
  • Inspect system logs for errors: journalctl -xe