Linux初入6 工作目錄命令與文字編輯命令

2021-09-10 01:15:31 字數 3227 閱讀 3701

[huang@localhost ~]$ pwd

/home/huang

目錄本身也是乙個檔案,它也存在於磁碟上,它的內容是目錄包含的檔案位置的索引,指向了磁碟上其他的檔案。通過vim就可以看見它的內容

目錄顏色與普通的檔案顏色也不一樣。

[huang@localhost ~]$ mkdir eagle

[huang@localhost ~]$ ls

doc eagle

1,每個使用者都有乙個家目錄,root的家目錄是/root,普通使用者的家目錄是/home/使用者名稱

2.相對路徑和絕對路徑

絕對路徑:能詳細描述乙個目錄的位置,無論當前工作目錄在**都能通過絕對路徑切換到指定目錄

相對路徑:相對於當前工作目錄所在的路徑,切換了當前所在目錄後,相對路徑也會改變

3.快速到達特殊路徑的方法

(1)快速到達家目錄,兩種方法

[root@localhost ~]

# cd ~

[root@localhost ~]

# cd

(2)快速到達上一級目錄

[root@localhost ~]

# cd ..

[root@localhost /]

# ls

(3)快速到達上一次所在的目錄

[root@localhost ~]

# cd ..

[root@localhost /]

# cd -

/root

(4)快速到達本目錄(似乎好像沒有用),但在執行本目錄下的程式,/程式。

[root@localhost ~]

# cd .

[root@localhost ~]

# cd ./

1.基本命令: ls [option]… [file]…

選項-a,檢視可見的,不可見的所有檔案

-l,檢視所有檔案的詳細資訊

-d,檢視目錄屬性

-h,檢視檔案

-l,檢視檔案的編號

2.檔案的詳細屬性包含什麼

檔案型別所有者所屬組其他項許可權 檔案編號 所有者 所屬組 檔案大小 建立時間 檔名

[root@localhost ~]

# ls -l

total 4

-rw-------. 1 root root 1481 jan 17 15:24 anaconda-ks.cfg

drwxr-xr-x. 2 root root 6 jan 17 16:41 desktop

drwxr-xr-x. 2 root root 6 jan 17 16:41 documents

drwxr-xr-x. 2 root root 6 jan 17 16:41 downloads

drwxr-xr-x. 2 root root 6 jan 17 16:41 music

drwxr-xr-x. 2 root root 6 jan 17 16:41 pictures

drwxr-xr-x. 2 root root 6 jan 17 16:41 public

drwxr-xr-x. 2 root root 6 jan 17 16:41 templates

drwxr-xr-x. 2 root root 6 jan 17 16:41 videos

[huang@localhost ~]$ cat doc
[huang@localhost ~]$ more doc
(1)tail預設一直讀取檔案的後十行,可以加引數-n 數字x,檢視後x行的文字內容。

[huang@localhost ~]$ tail -n 5 doc01

23

(2)tail命令一般不會單獨使用,一般會加上-f引數或者直接使用tailf追蹤動態變化的文字文件,可以實時的看到文件的變化。

.常用管道符搭配使用把某個檔案的內容列印到螢幕上,並且修改其中的字元。

[huang@localhost ~]$ cat doc |

tr[0-9]

[a-j] bc

defg

hija

bcd

引數 作用

-l 只顯示行數

-w 只顯示單詞數

-c 只顯示位元組數

[huang@localhost ~]$ wc -l doc

14 doc

[huang@localhost ~]$ wc -w doc

13 doc

[huang@localhost ~]$ wc -c doc

27 doc

[root@localhost ~]

# cut -d: -f1 /etc/passwd

root

bindaemon

admlp

sync

shutdown

halt

mail

operator

[huang@localhost ~]$ stat doc

file: 『doc』

size: 27 blocks: 8 io block: 4096 regular file

device: fd00h/64768d inode: 51035189 links: 1

access: (0664/-rw-rw-r--) uid: ( 1000/ huang) gid: ( 1000/ huang)

context: unconfined_u:object_r:user_home_t:s0

access: 2019-01-19 17:51:21.003381170 +0800

modify: 2019-01-19 17:51:08.726388984 +0800

change: 2019-01-19 17:51:08.733402118 +0800

birth: -

[huang@localhost ~]$ diff doc1 doc

6 工作目錄切換命令

ls 命令用於查詢目錄中檔案資訊 語法 ls 選項 檔案或目錄 ls l dev 詳細顯示 dev目錄的詳細資訊 ls lh install.log ll 為 ls l 別名 選項 目錄 類似win中資料夾 處理命令 檔案處理命令 鏈結命令 mkdir 命令 make directories 用於新...

linux工作目錄切換命令

1 pwd命令 pwd命令用於顯示使用者當前所處的工作目錄,格式為 pwd 選項 2 cd命令 cd命令用於切換工作路徑,格式為 cd 目錄名稱 這個命令應該是最常用的乙個linux命令了。可以通過cd命令迅速 靈活地切換到不同的工作目錄。除了常見的切換目錄方式 cd 命令返回到上一次所處的目錄,c...

6 Linux檔案與目錄管理 命令

目錄 2.檔案與目錄管理 3.檔案內容查詢 4.檔案與目錄 預設許可權與隱藏許可權 4.3.檔案特殊許可權 suid,sgid,sbit 4.4.觀察檔案型別 file 5.指令與檔案的搜尋 6.許可權與指令的關係 參考 linux 學習筆記.md linux 命令大全 概述 本文基本為 檔案與目錄...