Not able to execute standard commands on centos 7 server


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Not able to execute standard commands on centos 7 server
# 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 05:41 PM..
This User Gave Thanks to hicksd8 For This Post:
# 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:
# 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 10: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:
# 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:
# 7  
Old 10-17-2018
Thank you all for your help Smilie.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Nim server "Unable to execute remote client commands"

Hello, What is its mean? Could you please help me? Best regards, root@nimserver:/> nimadm -j nimadmvg -c dev4 -s spot1 -l lpp_source1 -d "hdisk7" -Y Initializing the NIM master. Initializing NIM client dev4. 0042-006 c_rsh: (exec_nimsh_cmd) exec_cmd Error 0 poll: setup failure... (2 Replies)
Discussion started by: getrue
2 Replies

2. Shell Programming and Scripting

How to execute commands on remote server using expect script?

I need to copy python script file to around 100 servers using expect script. 1. Copy script to my user home first(/home/myhome) on each remote server 2. change permissions on copied file to 766. 3. sudo to appuser1 account on remote server. copy script file from my user home to /usr/bin/... (1 Reply)
Discussion started by: kchinnam
1 Replies

3. Shell Programming and Scripting

Shell script to copy a file from one server to anther server and execute the binary

Hi , Is there any script to copy a files (weblogic bianary + silent.xml ) from one server (linux) to another servers and then execute the copy file. We want to copy a file on multiple servers and run the installation. Thanks (1 Reply)
Discussion started by: Nawrajesh
1 Replies

4. Shell Programming and Scripting

execute multipe commands

I would like to execute multipe commands in a shell script. Please provide the commands for the below scenario: Execute command1 if command1 is succesfull, then execute command2, command3,command4 in parallel if command2, command3,command4 are success then run command 5 (3 Replies)
Discussion started by: p_gautham12
3 Replies

5. Shell Programming and Scripting

How to execute standard output ?

Alright so i got this script genpipe: echo "$*" |sh genscript file vi file << 'HERE' :%s/^/echo /g :%s/ $//g :%s/ /&\| xargs \.\/plus /g :wq HERE cat file Which generates output like echo 1 | xargs ./plus 2 | xargs ./plus 3 and so on Now i got the next script multiplus, who should... (3 Replies)
Discussion started by: Bertieboy7
3 Replies

6. Shell Programming and Scripting

Command to execute commands one after other

I am writng a script in which there is an installation file.The installer runs good. But after the installer command there are some files and commands which are based on those installed files. Now problem is the commands get executed before the installer is totally installed. So is there any... (5 Replies)
Discussion started by: sriki32
5 Replies

7. Shell Programming and Scripting

how to run non-standard commands in bash script?

Hello All. I suspect that this will be a clear noob question, but I haven't been able to figure it out using the usual methods, so I turn to you. I've written a script to create input files for the quantum chemistry program NWCHEM. Generally you create an input file and then execute it by... (12 Replies)
Discussion started by: EinsteinMcfly
12 Replies

8. Shell Programming and Scripting

Execute 2 Commands at the same time

Hi @all I have got the following problem: I want my Master-Script to execute 2 Sub-scripts at the same time. How can i realize that? Thx for your help Greez Roger (2 Replies)
Discussion started by: DarkSwiss
2 Replies

9. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

10. Programming

code that reads commands from the standard i/p and executes the commands

Hello all, i've written a small piece of code that will read commands from standard input and executes the commands. Its working fine and is execting the commands well. Accepting arguments too. e.g #mkdir <name of the directory> The problem is that its not letting me change the directory i.e... (4 Replies)
Discussion started by: Phrozen Smoke
4 Replies
Login or Register to Ask a Question