国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux文件類型(學習筆記六)

2024-06-28 13:21:53
字體:
來源:轉載
供稿:網友
linux文件類型(學習筆記六)一、Linux下的文件類型
  • 普通文件:在由 ls –al 所顯示出來的屬性方面,第一個屬性為 [ - ]
  • 目錄文件:在由 ls –al 所顯示出來的屬性方面,第一個屬性為 [ d ]
  • 設備文件:一般都在dev目錄,有[b][c]
二、普通文件2.1、文本文件

以ASCII碼形式存儲在計算機中

2.2、二進制文件

以文本的二進制形式存儲在計算機中,如聲音,圖像等,只有通過相應的軟件才能將其顯示出來

2.3、連接文件

就是類似 Windows 底下的快捷方式啦!第一個屬性為 [ l ];

三、目錄文件

設計目錄文件的主要目的是用于管理和組織系統中的大量文件,它存儲一組相關文件的位置,大小與文件 有關的信息目錄文件簡稱目錄

四、設備文件

設備文件是Linux系統很重要的一個角色,Linux把每個I/O設備看成一個文件,與普通文件一樣處理,這樣可以使用文件 與設備的操作盡可能統一,從用戶角度來看,對I/O設備的使用和一般文件使用一樣,用戶不必了解I/O細節,

設備文件又為塊設備、和字符設備

4.1、塊設備

成塊讀取數據的設備,硬盤,內存等就是一些儲存數據,以提供系統存取的接口設備,簡單的說就是硬盤啦!

例如你的一號硬盤的代碼是 /dev/hda1 等等的文件啦!第一個屬性為 [ b ]

4.2、字符設備

亦即是一些串行端口的接口設備,例如鍵盤、鼠標等等!第一個屬性為 [ c ]。

五、文件相關的一些命令5.1、touch

創建新文件

touch /data/text.txtals /data 查看或者進入/data目錄后,再創建cd /datatouch text.txt創建多個文件touch 1.txt 2.txt 3.txt或者touch {a,b,c,d}.txttouch /data/{q,w,e,r,t,y}.txt大于號創建>c.txt重定向ehco > a.txt
5.2、cp

復制文件或者目錄

cp a.txt test4   //復制文件到test4文件下
[root@model Documents]# cp a.txt hh.txt test test4/ -icp: overwrite `test4/a.txt'? y    //有相同文件是提示覆蓋[root@model Documents]# ll test4     //查看tests4目錄total 8-rw-r--r--. 1 root root 23 Feb 20 06:09 a.txt-rw-r--r--. 1 root root  0 Feb 20 06:09 hh.txt-rw-r--r--. 1 root root 71 Feb 20 06:09 test[root@model Documents]# 
[root@model Documents]# cp test4/  tests/  -rip     //將test4整個目錄cp到tests目錄下[root@model Documents]# ls tests/a.txt  c.txt  test1  test4  x.txt  z.txt[root@model Documents]# ll tests/total 12-rw-r--r--. 1 root root   23 Feb 20 05:10 a.txt-rw-r--r--. 1 root root    0 Feb 20 05:11 c.txtdrwxr-xr-x. 3 root root 4096 Feb 20 01:55 test1drwxr-xr-x. 2 root root 4096 Feb 20 06:09 test4-rw-r--r--. 1 root root    0 Feb 20 05:11 x.txt-rw-r--r--. 1 root root    0 Feb 20 05:11 z.txt[root@model Documents]# 
5.3、rm

刪除文件或者目錄

[root@model Documents]# lltotal 32-rw-r--r--. 1 root root   23 Feb 19  2015 a.txtdrwxr-xr-x. 4 root root 4096 Feb 20  2015 comdrwxr-xr-x. 3 root root 4096 Feb 20  2015 dir2-rw-r--r--. 1 root root    0 Feb 20  2015 file1.txt-rw-r--r--. 1 root root    0 Feb 20  2015 file2.doc-rw-r--r--. 1 root root    0 Feb 20  2015 hh.txt-rw-r--r--. 1 root root   21 Feb 20  2015 n.txt~-rw-r--r--. 1 root root   71 Feb 20  2015 testdrwxr-xr-x. 3 root root 4096 Feb 20  2015 test1drwxr-xr-x. 2 root root 4096 Feb 20  2015 test4drwxr-xr-x. 4 root root 4096 Feb 20  2015 tests[root@model Documents]# rm -rf n.txt~          //刪除文件不提示[root@model Documents]# lltotal 28-rw-r--r--. 1 root root   23 Feb 19  2015 a.txtdrwxr-xr-x. 4 root root 4096 Feb 20  2015 comdrwxr-xr-x. 3 root root 4096 Feb 20  2015 dir2-rw-r--r--. 1 root root    0 Feb 20  2015 file1.txt-rw-r--r--. 1 root root    0 Feb 20  2015 file2.doc-rw-r--r--. 1 root root    0 Feb 20  2015 hh.txt-rw-r--r--. 1 root root   71 Feb 20  2015 testdrwxr-xr-x. 3 root root 4096 Feb 20  2015 test1drwxr-xr-x. 2 root root 4096 Feb 20  2015 test4drwxr-xr-x. 4 root root 4096 Feb 20  2015 tests[root@model Documents]# 
lsa.txt  dir2       file2.doc  test   test4com    file1.txt  hh.txt     test1  tests[root@model Documents]# rm hh.txt            //刪除文件會默認提示rm: remove regular empty file `hh.txt'? y[root@model Documents]# 
[root@model Documents]# ll test5total 0-rw-r--r--. 1 root root 0 Feb 19 22:26 1.txt-rw-r--r--. 1 root root 0 Feb 19 22:26 2.txt-rw-r--r--. 1 root root 0 Feb 19 22:26 3.txt-rw-r--r--. 1 root root 0 Feb 19 22:26 4.txt-rw-r--r--. 1 root root 0 Feb 19 22:26 5.txt[root@model Documents]# rm -rf test5      //刪除整個目錄不提示文件一起刪除[root@model Documents]# lltotal 28-rw-r--r--. 1 root root   23 Feb 19  2015 a.txtdrwxr-xr-x. 4 root root 4096 Feb 20  2015 comdrwxr-xr-x. 3 root root 4096 Feb 20  2015 dir2-rw-r--r--. 1 root root    0 Feb 20  2015 file1.txt-rw-r--r--. 1 root root    0 Feb 20  2015 file2.doc-rw-r--r--. 1 root root   71 Feb 20  2015 testdrwxr-xr-x. 3 root root 4096 Feb 20  2015 test1drwxr-xr-x. 2 root root 4096 Feb 20  2015 test4drwxr-xr-x. 4 root root 4096 Feb 20  2015 tests[root@model Documents]# 
5.4、mv

移動文件或者目錄

常用參數:

-b:若需覆蓋文件,則覆蓋前先行備份。

-f:force強制的意思,如果目標文件已經存在,不會詢問而直接覆蓋;

-i:若目標文件(destination)已經存在時,就會詢問是否覆蓋!

-u:若目標文件已經存在,且source比較新,才會更新(update)

[root@model Documents]# lltotal 28-rw-r--r--. 1 root root   23 Feb 19  2015 a.txtdrwxr-xr-x. 4 root root 4096 Feb 20  2015 comdrwxr-xr-x. 3 root root 4096 Feb 20  2015 dir2-rw-r--r--. 1 root root    0 Feb 20  2015 file1.txt-rw-r--r--. 1 root root    0 Feb 20  2015 file2.doc-rw-r--r--. 1 root root   71 Feb 20  2015 testdrwxr-xr-x. 3 root root 4096 Feb 20  2015 test1drwxr-xr-x. 2 root root 4096 Feb 20  2015 test4drwxr-xr-x. 4 root root 4096 Feb 20  2015 tests[root@model Documents]# mv a.txt b.doc     //文件重命名[root@model Documents]# lltotal 28-rw-r--r--. 1 root root   23 Feb 19  2015 b.docdrwxr-xr-x. 4 root root 4096 Feb 20  2015 comdrwxr-xr-x. 3 root root 4096 Feb 20  2015 dir2-rw-r--r--. 1 root root    0 Feb 20  2015 file1.txt-rw-r--r--. 1 root root    0 Feb 20  2015 file2.doc-rw-r--r--. 1 root root   71 Feb 20  2015 testdrwxr-xr-x. 3 root root 4096 Feb 20  2015 test1drwxr-xr-x. 2 root root 4096 Feb 20  2015 test4drwxr-xr-x. 4 root root 4096 Feb 20  2015 tests[root@model Documents]# 
[root@model Documents]# lsb.doc  dir2       file2.doc  test1  testscom    file1.txt  test       test4[root@model Documents]# mv b.doc  test4/yy.txt   //移動文件并重命名[root@model Documents]# ll test4/total 12-rw-r--r--. 1 root root 23 Feb 20  2015 a.txt-rw-r--r--. 1 root root  0 Feb 20  2015 hh.txt-rw-r--r--. 1 root root 71 Feb 20  2015 test-rw-r--r--. 1 root root 23 Feb 19  2015 yy.txt[root@model Documents]# 
[root@model Documents]# lltotal 24drwxr-xr-x. 4 root root 4096 Feb 20  2015 comdrwxr-xr-x. 3 root root 4096 Feb 20  2015 dir2-rw-r--r--. 1 root root    0 Feb 20  2015 file1.txt-rw-r--r--. 1 root root    0 Feb 20  2015 file2.doc-rw-r--r--. 1 root root   71 Feb 20  2015 testdrwxr-xr-x. 3 root root 4096 Feb 20  2015 test1drwxr-xr-x. 2 root root 4096 Feb 19 22:32 test4drwxr-xr-x. 4 root root 4096 Feb 20  2015 tests[root@model Documents]# mv dir2/  test1/      //移動整個文件夾[root@model Documents]# ll test1/total 20-rw-r--r--. 1 root root   23 Feb 20  2015 a.txt-rw-r--r--. 1 root root   71 Feb 20  2015 b.txtdrwxr-xr-x. 3 root root 4096 Feb 20  2015 dir2-rw-r--r--. 1 root root   87 Feb 20  2015 n.txtdrwxr-xr-x. 2 root root 4096 Feb 19 22:32 test2[root@model Documents]# 
5.5、find

查找文件或者目錄

  • -name:可以用通配符來查找如:* ?
  • -size:可以用+,-來設置大小+表示大于多少,-表示少于多少
  • -user:屬于哪個用戶
  • -type:文件類型,普通文件有f,目錄用d,塊設備用b,字符設備用c
[root@model Documents]# find /etc/ -name resol*.conf   //-name使用/etc/resolv.conf/etc/sysconfig/networking/PRofiles/default/resolv.conf[root@model Documents]# 
[root@model Documents]# find /boot/ -type d       //-type使用查找boot目錄下的所有目錄/boot//boot/efi/boot/efi/EFI/boot/efi/EFI/redhat/boot/lost+found/boot/grub[root@model Documents]# 
//查找當前目錄中屬于root用戶的.txt的所有文件[root@model test1]# lltotal 20-rw-r--r--. 1 root root   23 Feb 20  2015 a.txt-rw-r--r--. 1 root root   71 Feb 20  2015 b.txtdrwxr-xr-x. 3 root root 4096 Feb 20  2015 dir2-rw-r--r--. 1 root root   87 Feb 20  2015 n.txtdrwxr-xr-x. 2 root root 4096 Feb 19 22:32 test2[root@model test1]# find ./*.txt -user root./a.txt./b.txt./n.txt[root@model test1]# 
5.6、which

查找命令文件的位置

//查找命令所在位置[root@model test1]# which lsalias ls='ls --color=auto'        /bin/ls[root@model test1]# which cat/bin/cat[root@model test1]# which rmalias rm='rm -i'        /bin/rm[root@model test1]# which touch/bin/touch[root@model test1]# which mvalias mv='mv -i'        /bin/mv[root@model test1]# 
5.7、file

查看文件類型

[root@model test1]# file a.txt a.txt: ASCII text[root@model test1]# file dir2/dir2/: directory[root@model test1]# 
[root@model test1]# file lsls: cannot open `ls' (No such file or directory)[root@model test1]# which lsalias ls='ls --color=auto'        /bin/ls[root@model test1]# file /bin/ls/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped[root@model test1]# file /etc/init.d/network /etc/init.d/network: Bourne-Again shell script text executable[root@model test1]# file /dev/sda1/dev/sda1: block special[root@model test1]# file /dev/lp3/dev/lp3: character special[root@model test1]# 
5.8、ln

建立快捷方式:硬連接和符號連接(軟件連接)

不能對目錄,創建硬連接,也不能跨越分區創建硬鏈拉文件

創建軟件連接時需要加參數[-s]

如果你用ls察看一個目錄時,發現有的文件后面有一個@的符號,那就是一個用ln命令生成的文件

[root@model Downloads]# ln ../Documents/test1/a.txt [root@model Downloads]# lltotal 4-rw-r--r--. 2 root root 23 Feb 20  2015 a.txt

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴南区| 紫阳县| 石门县| 科尔| 淮滨县| 忻州市| 石渠县| 吉木萨尔县| 普洱| 抚宁县| 西乌珠穆沁旗| 呼伦贝尔市| 威远县| 清水河县| 诸暨市| 抚顺县| 行唐县| 隆德县| 错那县| 南和县| 岫岩| 文登市| 白沙| 靖江市| 新龙县| 宁波市| 旬阳县| 荃湾区| 顺平县| 泰顺县| 宁德市| 丰都县| 墨竹工卡县| 大兴区| 沈丘县| 安徽省| 惠水县| 二手房| 潞西市| 安福县| 永德县|