檔案系統小結2

來源:互聯網
上載者:User

標籤:alias

alias:定義別名

顯示當前shell下所有可用的命令別名

[[email protected] ~]# alias

alias cp=‘cp -i‘

alias egrep=‘egrep --color=auto‘

alias fgrep=‘fgrep --color=auto‘

alias grep=‘grep --color=auto‘

alias l.=‘ls -d .* --color=auto‘

alias ll=‘ls -l --color=auto‘

alias ls=‘ls --color=auto‘

alias mv=‘mv -i‘

alias rm=‘rm -i‘

alias which=‘alias | /usr/bin/which--tty-only --read-alias --show-dot --show-tilde‘

 

 

定義別名NAME,相當於執行命令VALUE

[[email protected] ~]#alias mv=‘mv -i‘(單引號)

 

在命令列中定義的別名,僅在當前shell進程中有效,若要永久有效,需定義在設定檔中

(PS:切換shell執行~]#bin/csh,即執行csh,exit退出此shell)

對目前使用者的設定檔:~/.bashrc

對所有使用者的設定檔:/etc/bashrc(需有管理員權限)

(需重新登入後生效,或執行source/path/to/config_file   ./path/to/config_file)

 

rm:刪除檔案

常用選項

-i:互動式

-f:強制移除

-r:遞迴刪除

eg:~]#rm –rf /,刪除全部檔案

 

mv:移動並重新命名檔案

~]#mv a b,在目前的目錄下,將a重新命名為b

常用選項

-i:互動式

-f:強制

 

tree:顯示分類樹

常用選項

-d:只顯示目錄

-L(level):指定顯示層級數目

-p(pattern):只顯示由指定萬用字元匹配的路徑

 

mkdir:建立目錄

常用選項

-p:自動建立所需各目錄

-v:顯示詳細資料

-m(mode):指定建立目錄的許可權

rkdir:刪除空目錄

常用選項

-p:遞迴刪除空目錄

-v:顯示詳細資料

rm –r:遞迴刪除分類樹

 

inode:索引節點編號

[[email protected] ~]# ls –i(查看檔案inode)

201364469 anaconda-ks.cfg  201453315 Downloads   67354234 Public

134361364 Desktop          201453316 Music           1704 Templates

134361365 Documents             1705 Pictures    67354235 Videos

不同分區內檔案的inode編號可能相同

同一分區內檔案的inode編號不能相同,若有相同,則為同一檔案

[[email protected] testdir]# cat aa

kkk

aaa

aaa

[[email protected]]# ln aa bb(ln建立檔案永久連結,永久連結不能跨分區)

[[email protected] testdir]# ls

aa bb

[[email protected] testdir]# ls -l

total 8

-rw-r--r-- 2 root root 12 Jul 31 20:14 aa

-rw-r--r-- 2 root root 12 Jul 31 20:14 bb

[[email protected] testdir]# stat aa bb

 File: ‘aa’

 Size: 12                 Blocks: 8          IO Block: 4096   regular file

Device: 802h/2050d         Inode: 134333665  Links: 2

Access: (0644/-rw-r--r--)  Uid: (   0/    root)   Gid: (   0/    root)

Access: 2016-07-31 20:14:57.895309997 +0800

Modify: 2016-07-31 20:14:54.642310202 +0800

Change: 2016-07-31 20:15:06.910309428 +0800

 Birth: -

 File: ‘bb’

 Size: 12                 Blocks: 8          IO Block: 4096   regular file

Device: 802h/2050d         Inode: 134333665  Links: 2

Access: (0644/-rw-r--r--)  Uid: (   0/    root)   Gid: (   0/    root)

Access: 2016-07-31 20:14:57.895309997 +0800

Modify: 2016-07-31 20:14:54.642310202 +0800

Change: 2016-07-31 20:15:06.910309428 +0800

 Birth: -

可見aa與bb除檔案名稱不同外,中繼資料完全相同

 

~]#ln –s:建立軟連結

用法:~]#ln –s filename[linkname](注意路徑)

[[email protected] testdir]# touch f1

[[email protected] testdir]# ls

f1

[[email protected] testdir]# ln -s f1 f2

[[email protected] testdir]# ll -i f1 f2

134333665 -rw-r--r-- 1 root root 0 Jul 3120:35 f1

134333666 lrwxrwxrwx 1 root root 2 Jul 3120:35 f2 -> f1

[[email protected] testdir]# cat f2

[[email protected] testdir]# echo xxx > f1

[[email protected] testdir]# ls -l -i f1 f2

134333665 -rw-r--r-- 1 root root 4 Jul 3120:36 f1

134333666 lrwxrwxrwx 1 root root 2 Jul 3120:35 f2 -> f1

[[email protected] testdir]# cat f2

xxx

軟連結可跨分區

軟連結檔案路徑的路徑應是相對於軟連結檔案的路徑,或者可以寫絕對路徑

 

每個分區提供的inode數量固定

df –i:可查看分區的inode編號數量值

[[email protected] ~]# df -i

Filesystem       Inodes     IUsed     IFree    IUse%   Mountedon

/dev/sda2      41943040   6388    41936652    1%      /

devtmpfs        121534    379      121155     1%      /dev

tmpfs           125166     1        125165    1%      /dev/shm

tmpfs           125166     495      124671    1%      /run

tmpfs           125166    13       125153     1%      /sys/fs/cgroup

/dev/sda3      20971520   87328     20884192  1%      /usr

/dev/sda1       499712    329      499383     1%      /boot

tmpfs           125166     1        125165    1%      /run/user/0

 

file:查看檔案類型

文法:~]#file [option] <filename>

OPTION:

 

[[email protected] testdir]# file f1

f1: ASCII text

 

[[email protected] testdir]# cat f1

/etc/issue

/testdir/f1

-b:列出檔案辨識結果,不顯示檔案名稱

[[email protected] testdir]# file -b f1

ASCII text

-c:詳細顯示指令執行過程

[[email protected] testdir]# file -c f1

contoffset        typeopcode     mask         value         desc

-f:列出檔案所包含檔案內容所指的檔案類型

[[email protected] testdir]# file -f f1

/etc/issue:  ASCII text

/testdir/f1: ASCII text


檔案系統小結2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.