In Linux, the following command cannot be found: bash: command not found.

Source: Internet
Author: User

In Linux, the following command cannot be found: bash: command not found.

When you enter some commands in Linux, the following prompt is displayed: bash: command not found.

First, check whether the $ PATH contains these commands.

$ PATH: determines which directories The shell uses to search for commands or programs. The PATH value is a series of directories. When running the program, linux searches for the compilation links under these directories.

Format:

PATH = $ PATH: <PATH1 >:< PATH2 >:< PATH3 >:...: <path n>

You can add the specified PATH to the PATH, separated by a colon. After the environment variable is changed, it will take effect the next time the user logs on. to take effect immediately, you need to execute:

1 $ source .bash_profile

After that, you can view the current search PATH through echo PATH. In this way, you can avoid frequent startup of programs located outside the shell search path.

View the PATH value:

Method 1: export

 1 [root@localhost /]# export 2 declare -x BASH_ENV="/root/.bashrc" 3 declare -x G_BROKEN_FILENAMES="1" 4 declare -x HISTSIZE="1000" 5 declare -x HOME="/root" 6 declare -x HOSTNAME="localhost.localdomain" 7 declare -x INPUTRC="/etc/inputrc" 8 declare -x LANG="zh_CN.GB18030" 9 declare -x LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"10 declare -x LESSOPEN="|/usr/bin/lesspipe.sh %s"11 declare -x LOGNAME="root"12 declare -x LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:"13 declare -x MAIL="/var/spool/mail/root"14 declare -x OLDPWD="/"15 declare -x PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin"16 declare -x PWD="/"17 declare -x SHELL="/bin/bash"18 declare -x SHLVL="1"19 declare -x SSH_ASKPASS="/usr/libexec/openssh/gnome-ssh-askpass"20 declare -x SSH_CLIENT="192.168.199.107 63049 22"21 declare -x SSH_CONNECTION="192.168.199.107 63049 192.168.199.10 22"22 declare -x SSH_TTY="/dev/pts/2"23 declare -x TERM="vt100"24 declare -x USER="root"25 declare -x USERNAME="root"26 [root@localhost /]# 


Method 2: echo PATH

1 [root@localhost /]# echo $PATH2 /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin3 [root@localhost /]# 

Add $ PATH environment variable:

[Root @ localhost u-boot-sh4] # export PATH =/opt/STM/STLinux-2.3/devkit/sh4/bin: $ PATH

View again:

1 [root@localhost u-boot-sh4]# echo $PATH2 /opt/STM/STLinux-2.3/devkit/sh4/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

The PATH is successfully added.

The PATH added in the preceding method disappears after the terminal is closed. We recommend that you modify the PATH by editing/etc/profile, or modify the. bashrc in the/home directory.

1 [root @ localhost etc] # vim/etc/profile 2 #/etc/profile 3 4 # System wide environment and startup programs, for login setup 5 # Functions and aliases go in/etc/bashrc 6 7 pathmunge () {8 if! Echo $ PATH |/bin/egrep-q "(^ |:) $1 ($ |:)"; then 9 if ["$2" = "after"]; then10 PATH = $ PATH: $111 else12 PATH = $1: $ PATH13 fi14 fi15} 16 17 # Path manipulation18 if ['id-U' = 0]; then19 pathmunge/sbin20 pathmunge/usr/sbin21 pathmunge/usr/local/sbin22 fi23 24 pathmunge/usr/samples/bin after25 26 unset pathmunge27 28 # No core files by default29 ulimit-S- c 0>/dev/null 2> & amp; 130 31 "/etc/profile" [converted] 49L, 842C

Add at the end:

1 export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH"

Save and exit. Run the following command:

1 [root@localhost etc]# source /etc/profile

If no error is reported, the operation is successful.

$ PATH Directory Overview

The PATH contains the following four directories:

/Bin,/usr/bin,/sbin,/usr/sbin

Main storage items:

./Bin:

The short description of "bin" as "binary" mainly stores the necessary execution files of some systems. Such as cat, cp, chmod df, dmesg, gzip, kill, ls, mkdir, more, mount, rm, su, tar, etc.

/Usr/bin:

It mainly stores some necessary execution files for application software tools. For example: c ++, g ++, gcc, chdrv, diff, dig, du, eject, elm, free, gnome *, gzip, htpasswd, kfm, ktop, last, less, locale m4, make, man, mcopy, ncftp, newaliases, nslookup passwd, quota, smb *, and wget.

/Sbin:

It mainly contains some necessary programs for system management. For example: cfdisk, dhcpcd, dump, e2fsck, fdisk, halt, ifconfig, ifup, ifdown, init, insmod, lilo, lsmod, mke2fs, modprobe, quotacheck, reboot, rmmod, runlevel and shutdown.

/Usr/sbin:

Place some necessary programs for network management. Such as dhcpd, httpd, imap, in. * d, inetd, lpd, named, netconfig, nmbd, samba, sendmail, squid, swap, tcpd, and tcpdump.

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.