echo $path
可以檢視系統的環境變數path的值,使用which命令可以檢視某個命令所在的絕對路徑;
[root@localhost ~]# echo $path/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost ~]# whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
[root@localhost ~]# which cat
/bin/cat
執行命令
path=$path:/tmp 可以把/tmp目錄加到path裡面
這樣我們可以使用/tmp/下面的可執行檔案作為命令
讓path永久生效的,需要把它加入到/etc/profile 最後一行裡,重啟生效,或者直接執行命令生效:
source /etc/profile = . /etc/profile
[root@localhost ~]# path=$path:/tmp#加入path後/tmp下面的命令可以直接執行。yong相當於cat[root@localhost ~]# echo $path
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/
[root@localhost ~]# cp /bin/cat /tmp/yong
[root@localhost ~]# ls /tmp/
yong yum.log
[root@localhost ~]# yong /tmp/passwd | head -1
root:x:0:0:root:/root:/bin/bash
關於alias別名
查詢別名,只在當前視窗生效。
[root@localhost /]# aliasalias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
自定義alias別名
[root@localhost /]# alias aming='ls /tmp/'alias設定命令的別名,例如 alias aming='ls -lt' 只是臨時使用,重啟不存在。[root@localhost /]# aming
yum.log
[root@localhost /]# ls /tmp/
yum.log
解除別名使用 unalias aming
讓別名永久生效,需要把設定別名的命令,加入到 /root/.bashrc 裡
[root@localhost ~]# cat /root/.bashrc# .bashrc
# user specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias yo='ls -l'
yo=『ls -l' 這一條為新增的;
[root@localhost
~]#source /root/.bashrc
#別名生效需要執行此命令,等同於. /root/.bashrc,或者重啟後生效。
[root@localhost ~]# yoyo別名生效,yo=ls -l 命令;total 24
-rw-------. 1 root root 1090 nov 13 09:29 anaconda-ks.cfg
-rw-r--r--. 1 root root 9119 nov 13 09:29 install.log
-rw-r--r--. 1 root root 3091 nov 13 09:28 install.log.syslog
檢視使用者家目錄的命令 ehco $home
[root@localhost tmp]# echo $home/root
Linux 下 PATH環境變數修改
第一種 root ei nino echo path usr lib qt 3.3 bin usr local sbin usr sbin sbin usr local bin usr bin bin root bin root ei nino path path usr local nginx s...
Linux下修改PATH環境變數
linux下有很多環境變數,path就是其中的一種 path 可執行檔案的搜尋路徑。ls命令也是乙個程式,執行它不需要提供完整的路徑名 bin ls,然 而通常我們執行當前目錄下的程式a.out卻需要提供完整的路徑名.a.out,這是因為path 環 境變數的值裡面包含了ls命令所在的目錄 bin,...
linux環境變數PATH
root cs70 moban echo path usr local sbin usr local bin usr sbin usr bin root bin 命令時從這些環境變數中開始找的 root cs70 moban mv bin cat opt root cs70 moban which ...