以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.txt5.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
查找文件或者目錄

[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
新聞熱點
疑難解答