精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 >

      linux的刪除文件日志命令是什么

      時(shí)間: 加城1195 分享

        Linux系統(tǒng)下我們經(jīng)常使用到刪除操作,包括刪除文件目錄,日志等,那么用什么命令實(shí)現(xiàn)呢,具體有哪些用法?下面由學(xué)習(xí)啦小編為大家整理了linux的刪除命令的相關(guān)知識,希望對大家有幫助!

        linux的刪除命令實(shí)例

        實(shí)例一:刪除文件file,系統(tǒng)會先詢問是否刪除。

        命令:

        rm 文件名

        輸出:

        [root@localhost test1]# ll

        總計(jì) 4

        -rw-r--r-- 1 root root 56 10-26 14:31 log.log

        root@localhost test1]# rm log.log

        rm:是否刪除 一般文件 “log.log”? y

        root@localhost test1]# ll

        總計(jì) 0[root@localhost test1]#

        說明:

        輸入rm log.log命令后,系統(tǒng)會詢問是否刪除,輸入y后就會刪除文件,不想刪除則數(shù)據(jù)n。

        實(shí)例二:強(qiáng)行刪除file,系統(tǒng)不再提示。

        命令:

        rm -f log1.log

        輸出:

        [root@localhost test1]# ll

        總計(jì) 4

        -rw-r--r-- 1 root root 23 10-26 14:40 log1.log

        [root@localhost test1]# rm -f log1.log

        [root@localhost test1]# ll

        總計(jì) 0[root@localhost test1]#

        實(shí)例三:刪除任何.log文件;刪除前逐一詢問確認(rèn)

        命令:

        rm -i *.log

        輸出:

        [root@localhost test1]# ll

        總計(jì) 8

        -rw-r--r-- 1 root root 11 10-26 14:45 log1.log

        -rw-r--r-- 1 root root 24 10-26 14:45 log2.log

        [root@localhost test1]# rm -i *.log

        rm:是否刪除 一般文件 “log1.log”? y

        rm:是否刪除 一般文件 “log2.log”? y

        [root@localhost test1]# ll

        總計(jì) 0[root@localhost test1]#

        實(shí)例四:將 test1子目錄及子目錄中所有檔案刪除

        命令:

        rm -r test1

        輸出:

        復(fù)制代碼代碼如下:

        [root@localhost test]# ll

        總計(jì) 24drwxr-xr-x 7 root root 4096 10-25 18:07 scf

        drwxr-xr-x 2 root root 4096 10-26 14:51 test1

        drwxr-xr-x 3 root root 4096 10-25 17:44 test2

        drwxrwxrwx 2 root root 4096 10-25 17:46 test3

        drwxr-xr-x 2 root root 4096 10-25 17:56 test4

        drwxr-xr-x 3 root root 4096 10-25 17:56 test5

        [root@localhost test]# rm -r test1

        rm:是否進(jìn)入目錄 “test1”? y

        rm:是否刪除 一般文件 “test1/log3.log”? y

        rm:是否刪除 目錄 “test1”? y

        [root@localhost test]# ll

        總計(jì) 20drwxr-xr-x 7 root root 4096 10-25 18:07 scf

        drwxr-xr-x 3 root root 4096 10-25 17:44 test2

        drwxrwxrwx 2 root root 4096 10-25 17:46 test3

        drwxr-xr-x 2 root root 4096 10-25 17:56 test4

        drwxr-xr-x 3 root root 4096 10-25 17:56 test5

        [root@localhost test]#

        實(shí)例五:rm -rf test2命令會將 test2 子目錄及子目錄中所有檔案刪除,并且不用一一確認(rèn)

        命令:

        rm -rf test2

        輸出:

        復(fù)制代碼代碼如下:

        [root@localhost test]# rm -rf test2

        [root@localhost test]# ll

        總計(jì) 16drwxr-xr-x 7 root root 4096 10-25 18:07 scf

        drwxrwxrwx 2 root root 4096 10-25 17:46 test3

        drwxr-xr-x 2 root root 4096 10-25 17:56 test4

        drwxr-xr-x 3 root root 4096 10-25 17:56 test5

        [root@localhost test]#

        實(shí)例六:刪除以 -f 開頭的文件

        命令:

        rm -- -f

        輸出:

        復(fù)制代碼代碼如下:

        [root@localhost test]# touch -- -f

        [root@localhost test]# ls -- -f

        -f[root@localhost test]# rm -- -f

        rm:是否刪除 一般空文件 “-f”? y

        [root@localhost test]# ls -- -f

        ls: -f: 沒有那個(gè)文件或目錄

        [root@localhost test]#

        也可以使用下面的操作步驟:

        [root@localhost test]# touch ./-f

        [root@localhost test]# ls ./-f

        ./-f[root@localhost test]# rm ./-f

        rm:是否刪除 一般空文件 “./-f”? y

        [root@localhost test]#

        實(shí)例七:自定義回收站功能

        命令:

        myrm(){ D=/tmp/$(date +%Y%m%d%H%M%S); mkdir -p $D; mv "$@" $D && echo "moved to $D ok"; }

        輸出:

        復(fù)制代碼代碼如下:

        [root@localhost test]# myrm(){ D=/tmp/$(date +%Y%m%d%H%M%S); mkdir -p $D; mv "$@" $D && echo "moved to $D ok"; }

        [root@localhost test]# alias rm='myrm'

        [root@localhost test]# touch 1.log 2.log 3.log

        [root@localhost test]# ll

        總計(jì) 16

        -rw-r--r-- 1 root root 0 10-26 15:08 1.log

        -rw-r--r-- 1 root root 0 10-26 15:08 2.log

        -rw-r--r-- 1 root root 0 10-26 15:08 3.log

        drwxr-xr-x 7 root root 4096 10-25 18:07 scf

        drwxrwxrwx 2 root root 4096 10-25 17:46 test3

        drwxr-xr-x 2 root root 4096 10-25 17:56 test4

        drwxr-xr-x 3 root root 4096 10-25 17:56 test5

        [root@localhost test]# rm [123].log

        moved to /tmp/20121026150901 ok

        [root@localhost test]# ll

        總計(jì) 16drwxr-xr-x 7 root root 4096 10-25 18:07 scf

        drwxrwxrwx 2 root root 4096 10-25 17:46 test3

        drwxr-xr-x 2 root root 4096 10-25 17:56 test4

        drwxr-xr-x 3 root root 4096 10-25 17:56 test5

        [root@localhost test]# ls /tmp/20121026150901/

        1.log 2.log 3.log

        [root@localhost test]#

        相關(guān)閱讀:Linux系統(tǒng)常見故障現(xiàn)象

        1. MBR中g(shù)rub損壞,1_5階段的數(shù)據(jù)損壞,2階段的grub損壞

        2. initramfs*.img文件損壞,內(nèi)核文件損壞

        3. /boot/grub/grub.conf文件丟失

        4. /etc/fstab丟失,無法掛載根等文件系統(tǒng)

        5. /boot 目錄全部的文件丟失

        6. root密碼忘記

        7. 為grub設(shè)置密碼,開機(jī)時(shí)生效,保護(hù)root密碼被惡意修改等

        二、常見故障的分析解決:

        1. 1階段和1_5階段出問題時(shí)會開機(jī)執(zhí)行完BIOS自檢后直接報(bào)錯(cuò)

        2. 前面兩個(gè)階段順利通過,到了執(zhí)行/boot/ 下面的第二個(gè)階段時(shí)的程序調(diào)用/boot/grub/grub.conf 時(shí)文件丟失或者/boot/下內(nèi)核文件和initramfs*.img 文件丟失都會造成卡在第二個(gè)階段:丟失initramfs文件時(shí)會在過了開機(jī)選擇內(nèi)核啟動之后卡住不動,沒有任何提示(在/boot/grub /grub.conf 配置文件中定義了timeout時(shí)間,會過了倒計(jì)時(shí),然后沒有任何提示)如果是丟失grub.conf 是會進(jìn)入grub>提示符由管理員指定內(nèi)核文件和initramfs文件位置

        3. /etc/fstab丟失:

        系統(tǒng)可以開機(jī),但是開機(jī)時(shí)會卡好長時(shí)間,因?yàn)樵S多服務(wù)等待超時(shí)無法啟動,此時(shí)磁盤按照默認(rèn)以只讀掛載根,這個(gè)掛載是在開機(jī)時(shí)掛載的,因?yàn)闆]有fstab文件所以無法重新掛載根文件系統(tǒng)以及其他的系統(tǒng),沒有運(yùn)行級別

        4. 為grub設(shè)置了密碼會在開機(jī)進(jìn)入內(nèi)核啟動時(shí),想要修改grub和內(nèi)核的參數(shù)或者進(jìn)入系統(tǒng)時(shí)需要輸入密碼,當(dāng)然忘記這樣的密碼也只能使用光盤引導(dǎo)進(jìn)入救援模式修改配置文件/etc/grub/grub.conf 把相應(yīng)的密碼行刪除即可。

      3996324