1. 程式人生 > >Linux學習筆記第二周第五次課(2月2日)

Linux學習筆記第二周第五次課(2月2日)

type 指定 內容 退出 var 中斷 清屏 命名 type類

2.23/2.24/2.25 find命令


which搜索文件及文件別名,命令為#which ls

where根據庫找,要更新,有局限性#whereis ls

locate模糊搜索,不精準#locate ls

安裝locate,命令為#yum install -y mlocate

依賴數據庫文件/var/lib/mlocate/mlocate.db,這個文件每天淩晨4點生成更新;

手動生成,命令為#updatedb

清屏ctrl+l,退出ctrl+d,不執行或中斷ctrl+c,光標前字符刪除ctrl+u,光標移到字符最後ctrl+e,光標移到開頭ctrl+a;


find,搜索文件,

搜索文件指定目錄下,指定文件名,命令為#find /etc/ -name "sshd_config"

搜索文件指定目錄,指定模糊文件名,* ,命令為# find /etc/ -name "sshd*"

搜索文件指定目錄,指定模糊目錄,命令為# find /etc/ -type d -name "sshd*"

type類型,d目錄,f文件,l鏈接文件,s socket文件,b塊設備,

find命令格式,#find 目錄 -type -name -mtime -ctime -atime

顯示文件詳細時間#stat 文件名

訪問時間access atime,權限更改時間modify mtime,修改內容時間change ctime

-1減一,一天以內更改權限;+1,大於一天,#find / -type f -mtime -1

一小時以內文件,min分鐘,#find / -type f -mmin -60

一小時以內文件,找到後詳細列出文件,#find / -type f -mmin -60 -exec ls -l {} \;

一小時以內文件,找到後文件重命名,#find / -type f -mmin -60 -exec mv {} {}.bak \;

或者-o,o為or ,例如##find / -type f -o -mtime -1 -o -name "*.conf"

-size文件大小,-10k小於10k,+10k大於10k, +10M大於10兆;


find找硬鏈接文件,

查看inode號,#ls -i 1_heard.txt

依inode號找硬鏈接文件,#find / -inum 33583395


2.26 文件名後綴


文件名後綴不嚴謹,可以自定義;

約定,txt文本,log日誌,gz壓縮文件,conf配置文件,

date時間

LANG語言

查看語言,#echo $LANG


2.27linux和windows互相傳文件

用xshell軟件

#yum install -y lrzsz

linux傳到windows,命令為#sz a.txt 按提示保存到windows

windows傳到linux,命令為#rz 選擇windows文件,之後保存到當前目錄


Linux學習筆記第二周第五次課(2月2日)