linux 命令 边用边记
2021/5/24 7:29:35
本文主要是介绍linux 命令 边用边记,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
摘自鸟站
http://linux.vbird.org/
创建目录
第六章、Linux 檔案與目錄管理
- 6.1.2 目錄的相關操作: cd, pwd, mkdir, rmdir
- mkdir (建立新目錄)
[root@study ~]# mkdir [-mp] 目錄名稱 選項與參數: -m :設定檔案的權限喔!直接設定,不需要看預設權限 (umask) 的臉色~ -p :幫助你直接將所需要的目錄(包含上層目錄)遞迴建立起來! 範例:請到/tmp底下嘗試建立數個新目錄看看: [root@study ~]# cd /tmp [root@study tmp]# mkdir test <==建立一名為 test 的新目錄 [root@study tmp]# mkdir test1/test2/test3/test4 mkdir: cannot create directory ‘test1/test2/test3/test4’: No such file or directory # 話說,系統告訴我們,沒可能建立這個目錄啊!就是沒有目錄才要建立的!見鬼嘛? [root@study tmp]# mkdir -p test1/test2/test3/test4 # 原來是要建 test4 上層沒先建 test3 之故!加了這個 -p 的選項,可以自行幫你建立多層目錄! 範例:建立權限為rwx--x--x的目錄 [root@study tmp]# mkdir -m 711 test2 [root@study tmp]# ls -ld test* drwxr-xr-x. 2 root root 6 Jun 4 19:03 test drwxr-xr-x. 3 root root 18 Jun 4 19:04 test1 drwx--x--x. 2 root root 6 Jun 4 19:05 test2 # 仔細看上面的權限部分,如果沒有加上 -m 來強制設定屬性,系統會使用預設屬性。 # 那麼你的預設屬性為何?這要透過底下介紹的 umask 才能瞭解喔! ^_^
复制档案或目录
- 6.2.2 複製、刪除與移動: cp, rm, mv
- cp (複製檔案或目錄)
[root@study ~]# cp [-adfilprsu] 來源檔(source) 目標檔(destination) [root@study ~]# cp [options] source1 source2 source3 .... directory 選項與參數: -a :相當於 -dr --preserve=all 的意思,至於 dr 請參考下列說明;(常用) -d :若來源檔為連結檔的屬性(link file),則複製連結檔屬性而非檔案本身; -f :為強制(force)的意思,若目標檔案已經存在且無法開啟,則移除後再嘗試一次; -i :若目標檔(destination)已經存在時,在覆蓋時會先詢問動作的進行(常用) -l :進行硬式連結(hard link)的連結檔建立,而非複製檔案本身; -p :連同檔案的屬性(權限、用戶、時間)一起複製過去,而非使用預設屬性(備份常用); -r :遞迴持續複製,用於目錄的複製行為;(常用) -s :複製成為符號連結檔 (symbolic link),亦即『捷徑』檔案; -u :destination 比 source 舊才更新 destination,或 destination 不存在的情況下才複製。 --preserve=all :除了 -p 的權限相關參數外,還加入 SELinux 的屬性, links, xattr 等也複製了。 最後需要注意的,如果來源檔有兩個以上,則最後一個目的檔一定要是『目錄』才行! |
这篇关于linux 命令 边用边记的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-0600-macOS和Linux安装和管理多个Python版本
- 2024-03-30[译]漫画SELinux概念
- 2024-03-29linux 移动文件
- 2024-03-28linux .so file
- 2024-03-28Linux 磁盘管理
- 2024-03-28Linux学习笔记(十三)磁盘管理(一):磁盘分区
- 2024-03-26linux 创建 文件
- 2024-03-25使用SecureCRT对Linux vim进行颜色设置
- 2024-03-202019-2020-12 20199317 《Linux内核原理与分析》 第十二周作业
- 2024-03-20Linux运维的第二周总结