Not able to execute standard commands on centos 7 server


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 10-13-2018
Not able to execute standard commands on centos 7 server

I am not able to run basic commands on my centos 7 server. The PATH variable looks correct I think. I have not seen this before and not sure what to do next. Thank you Smilie.


Code:
# cd /usr/bin
# ls
bash: ls: command not found...
Similar command is: 'lz'
nano ~/.bashrc
bash: nano: command not found...
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/sbin:/root/bin:/root/bin

# 2  
Old 10-13-2018
Hmmmm.......the first thing to do is to find out whether the 'ls' command executable exists or whether your O/S installation is damaged.

Ask the system for the location of the 'ls' command by either:

Code:
# which ls

or

Code:
# find / -name ls -print

If either of those comes out with a pathname then try to execute:

Code:
# <full pathname of ls command as output>

to see if it works.

If you cannot find where 'ls' is located with the above, then the installation has been damaged resulting in the command 'ls' no longer existing.

The above assumes that you have root access to the system.

Last edited by hicksd8; 10-13-2018 at 04:41 PM..
This User Gave Thanks to hicksd8 For This Post:
cmccabe (10-14-2018)
# 3  
Old 10-13-2018
On many UNIX, Linux, and BSD systems, one would expect the standard commands to be located in /bin or /usr/bin (neither of which are included in the directories in your PATH setting).
This User Gave Thanks to Don Cragun For This Post:
cmccabe (10-14-2018)
# 4  
Old 10-14-2018
Since the commands didn't return anything @hicksd8, the $PATH variable may need to be edited to include /usr/bin where ls and nano reside.

I seem to have issues setting $PATH, so if I do:

Code:
sudo /usr/bino/nano ~/.bashrc

and edit

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/sbin:/root/bin:/root/bin (current PATH)

to include /usr/bin

Code:
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/usr/sbin:/root/bin:/root/bin

Is that the correct place and why are some lines duplicated? Thank you Smilie.

Last edited by cmccabe; 10-14-2018 at 09:42 AM.. Reason: fixed format
# 5  
Old 10-14-2018
Check /etc/profile and /etc/environment files for the statement that sets the PATH variable. Be sure /bin and /usr/bin are included.

Otherwise, if whatever went wrong may have originated there, it will cause more problems on reboot.
This User Gave Thanks to jim mcnamara For This Post:
cmccabe (10-17-2018)
# 6  
Old 10-14-2018
You have /usr/sbin in your PATH setting twice. Having any directory in PATH more than once will slow down access to any utilities found in any directory after the second occurrence of that directory.

Unless you have some utility that appears in more than one of the directories in PATH, you want the directory that contains the most frequently used utilities first in your PATH and the directory containing the utilities that are the least frequently used last in your PATH. Under usual circumstances, you'll want to put /usr/bin first in PATH (and get rid of one of the /usr/sbin entries and one of the /root/bin entries) like:
Code:
/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/root/bin

Given the naming conventions used on the directories in your PATH, is there also a /root/sbin directory containing utilities that you sometimes want to find? And, as Jim suggested, if your system has /bin and /usr/bin as distinct directories, be sure that both of them are included in PATH.
This User Gave Thanks to Don Cragun For This Post:
cmccabe (10-17-2018)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Nim server "Unable to execute remote client commands" getrue AIX 2 12-14-2017 12:53 AM
How to execute telnet commands thru xterm? shopgirl08 Shell Programming and Scripting 2 10-25-2016 10:24 PM
How to execute commands on remote server using expect script? kchinnam Shell Programming and Scripting 1 03-20-2016 10:22 PM
Using sed to execute multiple commands exm Shell Programming and Scripting 11 07-16-2013 02:52 PM
how do i execute a set of commands in telnet?? nikhil jain Shell Programming and Scripting 4 03-22-2012 02:01 AM
Shell: How to execute commands from another file? Alkali Shell Programming and Scripting 3 03-03-2012 06:07 PM
execute multipe commands p_gautham12 Shell Programming and Scripting 3 10-18-2011 12:13 AM
How to execute standard output ? Bertieboy7 Shell Programming and Scripting 3 11-07-2010 10:27 AM
Command to execute commands one after other sriki32 Shell Programming and Scripting 5 09-21-2010 10:34 AM
how to run non-standard commands in bash script? EinsteinMcfly Shell Programming and Scripting 12 08-05-2010 01:25 AM
Execute 2 Commands at the same time DarkSwiss Shell Programming and Scripting 2 07-28-2010 09:48 AM
cron used to execute multiple commands hemaa UNIX for Dummies Questions & Answers 3 02-22-2009 12:20 PM
Can BASH execute commands on a remote server when the commands are embedded in shell bash_in_my_head Shell Programming and Scripting 1 12-04-2008 12:51 AM
code that reads commands from the standard i/p and executes the commands Phrozen Smoke Programming 4 01-22-2007 01:06 AM
Execute commands parallel in a for loop ? networkfre@k Shell Programming and Scripting 3 11-27-2005 06:26 PM