這篇文章主要講解了“inux常用命令總結(jié)”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“inux常用命令總結(jié)”吧!
linux文件中存在^M
使用shell命令tr可以實(shí)現(xiàn)去除,具體命令如下:
代碼如下:
cat -v yourfile | tr -d "^M" > targetfile
VIM中選定某個(gè)單詞
在ESC之后,使用w或者wi或者vwi可以選擇某個(gè)單詞
在控制臺(tái)中快速移動(dòng)光標(biāo)
1.刪除
1.1 ctrl + d 刪除光標(biāo)所在位置上的字符相當(dāng)于VIM里x或者dl
1.2 ctrl + h 刪除光標(biāo)所在位置前的字符相當(dāng)于VIM里hx或者dh
1.3 ctrl + k 刪除光標(biāo)后面所有字符相當(dāng)于VIM里d,shift+$
1.4 ctrl + u 刪除光標(biāo)前面所有字符相當(dāng)于VIM里d,shift+^
1.5 ctrl + w 刪除光標(biāo)前一個(gè)單詞相當(dāng)于VIM里db
1.6 ctrl + y 恢復(fù)ctrl+u上次執(zhí)行時(shí)刪除的字符
1.7 ctrl + ? 撤消前一次輸入
1.8 alt + r 撤消前一次動(dòng)作
1.9 alt + d 刪除光標(biāo)所在位置的后單詞
2.移動(dòng)
2.1 ctrl + a 將光標(biāo)移動(dòng)到命令行開(kāi)頭相當(dāng)于VIM里shift+^
2.2 ctrl + e 將光標(biāo)移動(dòng)到命令行結(jié)尾處相當(dāng)于VIM里shift+$
2.3 ctrl + f 光標(biāo)向后移動(dòng)一個(gè)字符相當(dāng)于VIM里l
2.4 ctrl + b 光標(biāo)向前移動(dòng)一個(gè)字符相當(dāng)于VIM里h
2.5 ctrl + 方向鍵左鍵 光標(biāo)移動(dòng)到前一個(gè)單詞開(kāi)頭
2.6 ctrl + 方向鍵右鍵 光標(biāo)移動(dòng)到后一個(gè)單詞結(jié)尾
2.7 ctrl + x 在上次光標(biāo)所在字符和當(dāng)前光標(biāo)所在字符之間跳轉(zhuǎn)
2.8 在vim中的命令輸入模式中,輸入gg,可以快速跳轉(zhuǎn)到文件開(kāi)頭
2.9 在vim中的命令輸入模式中,輸入GG,可以快速跳轉(zhuǎn)到文件結(jié)尾
3.0 在vim中返回上一個(gè)的編輯的位置,在輸入命令模式使用 ctrl+o
3.1 在vim中返回下一個(gè)的編輯的位置,在輸入命令模式使用 ctrl+i
3.統(tǒng)計(jì)
3.1 例如在vim中統(tǒng)計(jì)某個(gè)字符串的數(shù)量,可以使用命令
代碼如下:
:%s/Name//gn
防止被某個(gè)文件被刪除
1.使用一個(gè)shell命令來(lái)防止文件下的文件不能被刪除
sudo chattr +a Downloads cd Downloads rm Ngix.pdf mv: cannot move ‘Ngix.pdf' to ‘/home/gpx/.trash/Ngix.pdf': Operation not permitted sudo rm Ngix.pdf rm: cannot remove ‘Ngix.pdf': Operation not permitted
2.使用alias命令來(lái)去除rm
alias rm='rm -i' or alias rm=trash trash() { mv "$@" trash/ } or alias rm='cp $@ ~/backup; rm $@'
數(shù)據(jù)同步命令
#!/bin/sh date -d 'now' > /mnt/hd/data/log/rsync.log index=1 while : do rsync -azvh --compress-level=0 --progress gpx@ip:/mnt/hd/data/PriceAdj_data/ /mnt/hd/data/PriceAdj_data/ >> /mnt/hd/data/log/rsync.log if [ $? -ne 0 ];then sleep 5m else break fi let "index++" if [ $index -eq 5 ];then curl -d "operator=alert&phone=number&msg=rsync-dell-data-Failed" "http://ip:port/sendmessage" echo "rsync data Failed !" >> /mnt/hd/data/log/rsync.log exit 1 fi done date -d 'now' > /mnt/hd/data/log/log_save_dateData.log nohup python /mnt/hd/data/code/load_Today_Data.py >> /mnt/hd/data/log/log_save_dateData.log
linux中去除文件中的重復(fù)行
代碼如下:
sort -n Yourfile | uniq > save_path
更新Linux系統(tǒng)時(shí)間
代碼如下:
sudo ntpdate cn.pool.ntp.org
亞洲地區(qū)的ntp服務(wù)器
代碼如下:
. Bangladesh — bd.pool.ntp.org . China — cn.pool.ntp.org . Hong Kong — hk.pool.ntp.org . India — in.pool.ntp.org . Indonesia — id.pool.ntp.org . Iran — ir.pool.ntp.org . Israel — il.pool.ntp.org . Japan — jp.pool.ntp.org . Korea — kr.pool.ntp.org . Malaysia — my.pool.ntp.org . Philippines — ph.pool.ntp.org . Singapore — sg.pool.ntp.org . Taiwan — tw.pool.ntp.org . Thailand — th.pool.ntp.org . Turkey — tr.pool.ntp.org . United Arab Emirates — ae.pool.ntp.org
在vim中進(jìn)行完整單詞的匹配
使用命令行輸入模式
/\<這里輸入你要匹配的單詞\>
如果在單文件中使用進(jìn)行查找和匹配
直接使用在命令輸入模式下 對(duì)某個(gè)單詞使用 *
使用scp和rsync進(jìn)行數(shù)據(jù)的內(nèi)網(wǎng)數(shù)據(jù)傳輸和備份
代碼如下:
rsync -azvh --delete --compress-level=0 --progress username@hostname(ip):file_path save_path >> log_path
參數(shù)解釋:
-v: --verbose increase verbosity --info=FLAGS fine-grained informational verbosity --debug=FLAGS fine-grained debug verbosity --msgs2stderr special output handling for debugging -a: --archive archive mode; equals -rlptgoD (no -H,-A,-X) --no-OPTION turn off an implied OPTION (e.g. --no-D) -z: --compress compress file data during the transfer --compress-level=NUM explicitly set compression level --skip-compress=LIST skip compressing files with suffix in LIST -h: --human-readable output numbers in a human-readable format --progress show progress during transfer --delete delete extraneous files from dest dirs scp mode remote_username@remote_hostname(or ip):remote_file_path dest_file_path >> run_log_path example: name@host:/mnt/hd/data/code/shell$ scp sql_rsync.sh name@host:/tmp/ name@host's password: sql_rsync.sh 100% 149 0.2KB/s 00:00 name@host:/mnt/hd/data/code/shell$接下來(lái)給大家總結(jié)了10條linux常用命令
1.》將原文件清空,并且內(nèi)容寫(xiě)入到文件中,》》將內(nèi)容放到文件的尾部
代碼如下:
echo “aa” 》 test.txt 和 echo “bb” 》》 test.txt
2 給組用戶和其他用戶添加寫(xiě)的權(quán)限
代碼如下:
chmod go+w -R /home/zhangy
3. 列出歸檔內(nèi)容
代碼如下:
tar -tzvf test.tar.gz
4.查看文件列表大
代碼如下:
du -ah
5. 查看所有文件的大小總和
代碼如下:
du -sh
6.數(shù)學(xué)運(yùn)算
代碼如下:
echo ‘1+2'|bc -l
7. //查看linux內(nèi)核等的一些信息
代碼如下:
uname -a
8.壞道掃描時(shí)顯示進(jìn)度
代碼如下:
badblocks -s /dev/sda
9.查看命令的運(yùn)行時(shí)間
代碼如下:
time command
10.按時(shí)間的倒序排序
代碼如下:
ls -lrt
感謝各位的閱讀,以上就是“inux常用命令總結(jié)”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)inux常用命令總結(jié)這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
網(wǎng)站欄目:總結(jié)inux常用的命令-創(chuàng)新互聯(lián)
分享地址:http://jinyejixie.com/article42/psiec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、移動(dòng)網(wǎng)站建設(shè)、網(wǎng)站策劃、營(yíng)銷型網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容