linux常用命令

來源:互聯網
上載者:User

標籤:linux命令

man:查看協助文檔

touch:建立檔案

touch test.txt

ls:顯示列表 list 

ls -l

ls -ld

ls -a 

mkdir:建立目錄 make directory

mkdir /data

cp:拷貝

cp /data/test.txt /tmp/ 

cp -rf 拷貝不出現提示

\cp /tmp/test.txt /mnt/test.txt

/bin/cp  /tmp/test.txt /mnt/test.txt 覆蓋不提

拷貝/data/目錄下的test.txt檔案到 /tmp/目錄下

cd:切換目錄

cd . 切換到目前的目錄

cd .. 切換到上級目錄

cd ~ 切換到使用者主目錄

cd ~ 使用者名稱 切換到指定使用者的目錄

cd - 返回進入此目錄之前所在的目錄

cd !$ 把上個命令的參數作為cd的參數

rm:刪除檔案

rm /data/test.txt 

刪除/data/目錄下的test.txt檔案

mv:移動檔案

mv /data/test.txt /tmp/ 

移動test.txt檔案到/tmp/目錄下

echo:輸入什麼顯示什麼

echo {a..z}顯示a到z

pwd:顯示目前的目錄

cat:一次性輸出

alias:定義別名

alias ley=‘cat /etc/sysconfig/network-scripts/ifcfg-eth0‘

直接輸入ley即可顯示網卡配置資訊

ulias:取消別名的定義

ulias ley

head:從行首開始顯示

head -5 /etc/passwd

顯示/etc/passwd檔案前5行

tail:從行尾開始顯示

tail -5 /etc/passwd

顯示/etc/passwd檔案後5行

tree:顯示樹結構

需安裝:yum install -y tree

rmdir:刪除空目錄

rmdir /data/

刪除/data/空目錄

xargs:用於把find/ls等命令輸出交給後面處理

find / -type f(檔案或者目錄d)  -name "test.txt" | xargs rm -f

find / -type f(檔案或者目錄d)  -name "test.txt" | xargs cat(ls)

find:尋找

sed:取各種內容

sed -n 取消預設輸出

sed -n 20,30p ett.txt

sed -n s/a/b/g ett.txt 在ett.txt中的a全域替換成b

sed -n 20,30p ett.txt 取ett.txt中20到30之間的行

awk:比sed進階

awk /[^o]/ oldboy.txt 

取oldboy.txt中以o開頭的行

NR:行號

awk ‘{if(NR>19 && NR<31) print $0}‘ ett.txt

grep:過濾命令

grep -v

grep -v root /etc/passwd 

直接過濾 /etc/passwd 中含有root的檔案

vi:編輯器

vim:比vi進階的編輯器

seq:列印數字序列

[[email protected] ~]# seq 2

1

2



本文出自 “營運不是事” 部落格,請務必保留此出處http://liangey.blog.51cto.com/9097868/1570929

linux常用命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.