環境變量:PATHlinux
[root@lizhipeng01 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/binbash
[root@lizhipeng01 ~]# which ls 查看ls命令在哪裏
alias ls='ls --color=auto'
/usr/bin/ls
[root@lizhipeng01 ~]# ls /usr/bin/ls
/usr/bin/ls
[root@lizhipeng01 ~]# cp /usr/bin/ls /tmp/ls2 拷貝一份
[root@lizhipeng01 ~]# /tmp/ls2 執行一下,效果和ls同樣
1.txt anaconda-ks.cfg a.txt bb split_dir testb.txt testc.txt 學習計劃安排.txt
[root@lizhipeng01 ~]# ls
1.txt anaconda-ks.cfg a.txt bb split_dir testb.txt testc.txt 學習計劃安排.txt
[root@lizhipeng01 ~]#less
[root@lizhipeng01 ~]# ls2
-bash: ls2: 未找到命令學習
[root@lizhipeng01 ~]# PATH=$PATH:/tmp/ 把/tmp/加入到路徑當中
[root@lizhipeng01 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/
[root@lizhipeng01 ~]# ls2
1.txt anaconda-ks.cfg a.txt bb split_dir testb.txt testc.txt 學習計劃安排.txtblog
[root@lizhipeng01 ~]# ls2 打開另外一個終端,發現ls2並無生效
-bash: ls2: 未找到命令
[root@lizhipeng01 ~]#ip
[root@lizhipeng01 ~]# /tmp/ls2
1.txt anaconda-ks.cfg a.txt bb split_dir testb.txt testc.txt 學習計劃安排.txt文檔
要使ls2在另外一個終端生效,修改/etc/profile文件,使其開機就生效字符串
[root@lizhipeng01 ~]# ls2
1.txt anaconda-ks.cfg a.txt bb split_dir testb.txt testc.txt 學習計劃安排.txtit
[root@lizhipeng01 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/
[root@lizhipeng01 ~]# PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin 使其不生效,取消路徑,/etc/profile裏面一樣修改一下
[root@lizhipeng01 ~]# ls2
-bash: ls2: 未找到命令test
cp命令 copy
[root@lizhipeng01 ~]# cp /etc/passwd /tmp/1.txt
[root@lizhipeng01 ~]# ls /tmp/1.txt
/tmp/1.txt
[root@lizhipeng01 ~]# cp -r /tmp/lizhipenglinux/ /tmp/lizhipeng
[root@lizhipeng01 ~]# tree /tmp/lizhipeng/
/tmp/lizhipeng/
0 directories, 0 files
[root@lizhipeng01 ~]# tree /tmp/lizhipenglinux
/tmp/lizhipenglinux
0 directories, 0 files
[root@lizhipeng01 ~]# cp -r /tmp/lizhipenglinux/ /tmp/lizhipeng1/
[root@lizhipeng01 ~]# tree !$ 上一條命令的最後一個參數
tree /tmp/lizhipeng1/
/tmp/lizhipeng1/
0 directories, 0 files
[root@lizhipeng01 ~]# which cp
alias cp='cp -i'
/usr/bin/cp
[root@lizhipeng01 ~]# which rm
alias rm='rm -i'
/usr/bin/rm
[root@lizhipeng01 ~]# cp /etc/passwd /tmp/1.txt
cp:是否覆蓋"/tmp/1.txt"? ^C
[root@lizhipeng01 ~]# /usr/bin/cp /etc/passwd /tmp/1.txt 不會問是否覆蓋
[root@lizhipeng01 ~]# tree /tmp/lizhipeng1/
/tmp/lizhipeng1/
0 directories, 0 files
[root@lizhipeng01 ~]# cp -r /tmp/lizhipenglinux/ /tmp/lizhipeng1/
[root@lizhipeng01 ~]# ls /tmp/lizhipeng1/ 當目標目錄已經存在時,會把原目錄放到目標目錄下;若是目標目錄不存在,會把原目錄拷貝過來,改個名字,改爲目標目錄的名字
lizhipenglinux
mv命令
[root@lizhipeng01 ~]# cd /tmp/
[root@lizhipeng01 tmp]# ls
1.txt bb lizhipeng lizhipeng1 lizhipenglinux ls2 split_dir test
[root@lizhipeng01 tmp]# mv 1.txt /root/2.txt 把/tmp/1.txt放到/root/下,並更名2.txt
[root@lizhipeng01 tmp]# ls /root/
1.txt 2.txt anaconda-ks.cfg a.txt bb split_dir testb.txt testc.txt 學習計劃安排.txt
[root@lizhipeng01 tmp]# mv ls2 lizhipeng/
[root@lizhipeng01 tmp]# ls lizhipeng/
ls2
[root@lizhipeng01 tmp]# touch ls2
[root@lizhipeng01 tmp]# mv ls2 lizhipeng/
mv:是否覆蓋"lizhipeng/ls2"? n
[root@lizhipeng01 tmp]# ls
bb lizhipeng lizhipeng1 lizhipenglinux ls2 split_dir test
[root@lizhipeng01 tmp]# mv lizhipeng/ lzp/ 目標目錄不存在,原目錄更名字
[root@lizhipeng01 tmp]# ls
bb lizhipeng1 lizhipenglinux ls2 lzp split_dir test
[root@lizhipeng01 tmp]# tree lzp/
lzp/
└── ls2
0 directories, 1 file
[root@lizhipeng01 tmp]# mv lizhipeng1/ lzp/ 目標目錄存在時,會把原目錄放到目標目錄下
[root@lizhipeng01 tmp]# tree lzp/
lzp/
├── lizhipeng1
│ └── lizhipenglinux
└── ls2
2 directories, 1 file
[root@lizhipeng01 tmp]# mkdir lizhipeng1/
[root@lizhipeng01 tmp]# touch lizhipeng1/1.txt
[root@lizhipeng01 tmp]# tree lizhipeng1/
lizhipeng1/
└── 1.txt
0 directories, 1 file
[root@lizhipeng01 tmp]# mv lizhipeng1/ lzp/
mv:是否覆蓋"lzp/lizhipeng1"? y
mv: 沒法將"lizhipeng1/" 移動至"lzp/lizhipeng1": 文件已存在 由於lizhipeng1/下面有lizhipenglinux,因此沒法覆蓋。
[root@lizhipeng01 tmp]# cd lzp
[root@lizhipeng01 lzp]# ls
lizhipeng1 ls2
[root@lizhipeng01 lzp]# cd lizhipeng1
[root@lizhipeng01 lizhipeng1]# ls
lizhipenglinux
[root@lizhipeng01 lizhipeng1]# rm -rf *
[root@lizhipeng01 lizhipeng1]# ls
[root@lizhipeng01 lizhipeng1]# mv lizhipeng1/ lzp/
mv: 沒法獲取"lizhipeng1/" 的文件狀態(stat): 沒有那個文件或目錄
[root@lizhipeng01 lizhipeng1]# cd ..
[root@lizhipeng01 lzp]# cd ..
[root@lizhipeng01 tmp]# mv lizhipeng1/ lzp/
mv:是否覆蓋"lzp/lizhipeng1"? y
[root@lizhipeng01 tmp]# ls lzp/lizhipeng1/
1.txt
[root@lizhipeng01 tmp]# tree lzp/
lzp/
├── lizhipeng1
│ └── 1.txt
└── ls2
1 directory, 2 files
文檔查看cat_more_less_head_tail
cat用於查看一個文件的內容並將其顯示在屏幕上
-n:查看文件時,把行號也顯示到屏幕上。
[root@lizhipeng01 ~]# echo '1111' > 1.txt
[root@lizhipeng01 ~]# echo '2222' >> 1.txt
[root@lizhipeng01 ~]# cat 1.txt
1111
2222
[root@lizhipeng01 ~]# cat -n 1.txt
1 1111
2 2222
-A:顯示全部的內容,包括特殊字符。
[root@lizhipeng01 ~]# cat -A 1.txt
1111$
2222$
[root@lizhipeng01 ~]# cat -nA 1.txt
1 1111$
2 2222$
less
/字符串,而後回車,這樣就能夠查找這個字符串。若是是查找多個該字符串,能夠按n鍵顯示下一個,N向上;也能夠用?鍵代替/鍵來搜索字符串,/是在當前行向下搜索,而?是在當前行向上搜索。g行首,G行尾
head
用於顯示文件的前10行,後面直接跟文件名。若是加-n選項,則顯示文件的前幾行。
tail
用於顯示文件的最後10行,後面直接跟文件名。若是加-n選項,則顯示文件的最後幾行。
tail -f能夠動態顯示文件的最後10行。tail -f /var/log/message能夠動態、實時地查看文件/var/log/message中的內容