has been used in the college room of the Linux system, a variety of commands can be used directly, but they installed a centOS5.4 after the discovery ifconfig,service these/sbin directory commands can not be used directly, but the/bin directory commands are used normal, The reason is that environment variables are not set.
Take a look at the Export command first:
[[email protected] maheng]# exportdeclare-x colorterm= "gnome-terminal" Declare-x DBUS_SESSION_BUS_ADDRESS= " Unix:abstract=/tmp/dbus-ocfwwnogjt,guid=bd3ae8fdfb5a70107e46f50056469fd2 "Declare-x DESKTOP_SESSION=" Default " Declare-x desktop_startup_id= "" Declare-x display= ": 0.0" declare-x gdmsession= "default" Declare-x Gdm_xserver_ location= "local" Declare-x gnome_desktop_session_id= "Default" Declare-x gnome_keyring_socket= "/tmp/keyring-crlutn/ Socket "Declare-x gtk_rc_files="/etc/gtk/gtkrc:/home/maheng/.gtkrc-1.2-gnome2 "Declare-x G_BROKEN_FILENAMES=" 1 " Declare-x histsize= "Declare-x home="/root "Declare-x hostname=" Localhost.localdomain "Declare-x INPUTRC="/etc/ Inputrc "Declare-x lang=" en_US. UTF-8 "Declare-x lessopen=" |/usr/bin/lesspipe.sh%s "Declare-x logname=" Maheng "Declare-x ls_colors=" no=00:fi=00:di= 00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*. Exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*. tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*. z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00 ; 35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35: "Declare-x mail="/var/spool/mail/maheng "Declare-x Oldpwddeclare-x path= "/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/x11r6/bin:/home/ Maheng/bin "Declare-x pwd="/home/maheng "Declare-x session_manager=" local/localhost.localdomain:/tmp/. ice-unix/4867 "Declare-x shell="/bin/bash "Declare-x shlvl=" 3 "Declare-x ssh_agent_pid=" 4903 "Declare-x SSH_ASKPASS="/ Usr/libexec/openssh/gnome-ssh-askpass "Declare-x ssh_auth_sock="/tmp/ssh-cwirgq4867/agent.4867 "Declare-x TERM=" Xterm "Declare-x user=" Maheng "Declare-x username=" Maheng "Declare-x windowid=" 25165905 "Declare-x XAUTHORITY="/root/. Xauthqennmx "Declare-x xmodifiers=" @im =none "
Can see Declare-x path= "/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/x11r6/bin:/home/ Maheng/bin "In this sentence does not exist/sbin, this time we put/sbin into the environment variable is OK.
Method One:
Export path= $PATH:/sbin Note the PATH to capitalize.
At this point, you can see that/sbin has added environment variables or used echo $path to see the newly added environment variables.
Method Two:
Modify/etc/profile or/ROOT/.BASHRC configuration file, add Export path= "$PATH:/sbin" At the end of the file. This method requires a system restart to take effect.
PS: If you want to add more than one environment variable, you need to: separate, look at the above export path variable content We can draw a conclusion.
Linux under Ifconfig,service and other commands cannot be used directly