第二周作業
1、Linux上的文件管理類命令有哪些,其常用的使用方法及其相關示例演示
文件管理類命令:cp,mv,rm
cp: 源文件;目標文件
[root@localhost
~]# cp /etc/issue /tmp/test1/
cp:是否覆蓋“/tmp/test1/issue”? y
[root@localhost
~]# ls /tmp/test1
issue
[root@localhost
~]#
mv: move (rename) files
[root@localhost
~]# cd /tmp/
[root@localhost
tmp]# ls
hello.txt log mysysroot system-release test1 tom
hi.txt m system.rel test test2
[root@localhost
tmp]# ls test1
issue
[root@localhost
tmp]# mv /tmp/test
test/ test1/ test2/
[root@localhost
tmp]# mv /tmp/test1/issue /tmp/test2/
[root@localhost
tmp]# ls /tmp/test2/
issue
[root@localhost
tmp]#
rm: 命令 remove rm [OPTION]… FILE…
[root@localhost
tmp]# ls /tmp
hello.txt log mysysroot system-release test1 tom
hi.txt m system.rel test test2
[root@localhost
tmp]# rm -fr /tmp/test1
[root@localhost
tmp]# ls
hello.txt log mysysroot system-release test2
hi.txt m system.rel test tom
[root@localhost
tmp]#
2、bash的工作特性之命令執行狀態返回值和命令行展開所涉及的內容及其示例演示
bash通過狀態返回值來輸出此結果;
成功:0
失?。?/span>1-255
命令執行完成之后,其狀態的返回值保存于bash的特殊變更 $? 中;
用echo $? 來查看
bash的命令行展開:
~:自動展開為用戶的家目錄,或指定的用戶的家目錄;
{} 可承載一個以(,)逗號分隔的路徑列表,并能夠將其展開為多個路徑
[root@localhost
~]# cd /tmp
[root@localhost
tmp]# ls
hello.txt log mysysroot system-release test2
hi.txt m system.rel test tom
[root@localhost
tmp]# mkdir /tmp/{a,b}_{c,d}
[root@localhost
tmp]# ls
a_c b_c hello.txt log mysysroot system-release test2
a_d b_d hi.txt m system.rel test tom
[root@localhost
tmp]#
3、使用命令行展開功能來完成練習:
[root@localhost
~]# cd /tmp
[root@localhost
tmp]# ls
hello.txt log mysysroot system-release test2
hi.txt m system.rel test tom
[root@localhost
tmp]# mkdir /tmp/{a,b}_{c,d}
[root@localhost
tmp]# ls
a_c b_c hello.txt log mysysroot system-release test2
a_d b_d hi.txt m system.rel test tom
[root@localhost
tmp]#
[root@localhost
~]# mkdir -pv
/tmp/mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig/network-scripts},lib/modules,lib64,proc,sbin,sys,tmp,usr/local/{bin,sbin},var/{local,log,run}}
mkdir: 已創建目錄 “/tmp/mylinux”
mkdir: 已創建目錄 “/tmp/mylinux/bin”
mkdir: 已創建目錄 “/tmp/mylinux/boot”
mkdir: 已創建目錄 “/tmp/mylinux/boot/grub”
mkdir: 已創建目錄 “/tmp/mylinux/dev”
mkdir: 已創建目錄 “/tmp/mylinux/etc”
mkdir: 已創建目錄 “/tmp/mylinux/etc/rc.d”
mkdir: 已創建目錄 “/tmp/mylinux/etc/rc.d/init.d”
mkdir: 已創建目錄 “/tmp/mylinux/etc/sysconfig”
mkdir: 已創建目錄 “/tmp/mylinux/etc/sysconfig/network-scripts”
mkdir: 已創建目錄 “/tmp/mylinux/lib”
mkdir: 已創建目錄 “/tmp/mylinux/lib/modules”
mkdir: 已創建目錄 “/tmp/mylinux/lib64”
mkdir: 已創建目錄 “/tmp/mylinux/proc”
mkdir: 已創建目錄 “/tmp/mylinux/sbin”
mkdir: 已創建目錄 “/tmp/mylinux/sys”
mkdir: 已創建目錄 “/tmp/mylinux/tmp”
mkdir: 已創建目錄 “/tmp/mylinux/usr”
mkdir: 已創建目錄 “/tmp/mylinux/usr/local”
mkdir: 已創建目錄 “/tmp/mylinux/usr/local/bin”
mkdir: 已創建目錄 “/tmp/mylinux/usr/local/sbin”
mkdir: 已創建目錄 “/tmp/mylinux/var”
mkdir: 已創建目錄 “/tmp/mylinux/var/local”
mkdir: 已創建目錄 “/tmp/mylinux/var/log”
mkdir: 已創建目錄 “/tmp/mylinux/var/run”
[root@localhost ~]# tree /tmp/mylinux
/tmp/mylinux
├── bin
├── boot
│ └── grub
├── dev
├── etc
│ ├── rc.d
│ │ └── init.d
│ └── sysconfig
│ └── network-scripts
├── lib
│ └── modules
├── lib64
├── proc
├── sbin
├── sys
├── tmp
├── usr
│ └── local
│ ├── bin
│ └── sbin
└── var
├── local
├── log
└── run
24 directories, 0 files
[root@localhost ~]#
4、文件的元數據信息有哪些,分別表示什么含義,如何查看?如何修改文件的時間戳信息
文件的數據分兩種:一種元數據,既屬性數據;一種就是數據本身;可使用stat命令查看文件的元數據:
[root@localhost
~]# stat /tmp/functions
文件:“/tmp/functions”
大?。?/span>13948 塊:32 IO 塊:4096 普通文件
設備:803h/2051d Inode:2842 硬鏈接:1
權限:(0644/-rw-r–r–) Uid:( 0/ root) Gid:( 0/ root)
環境:unconfined_u:object_r:user_tmp_t:s0
最近訪問:2017-08-07 16:34:48.718955739 +0800
最近更改:2017-08-07 16:34:48.718955739 +0800
最近改動:2017-08-07 16:34:48.718955739 +0800
創建時間:–
[root@localhost ~]#
修改文件的時間戳信息:
可以使用touch命令更改文件的時間戳:
語法:
touch [OPTION]… FILE…
常用選項:
-c: 指定的文件路徑不存在時不予創建;
-a: 僅修改access time;
-m:僅修改modify time;
-t:使用指定的日期時間,而非現在的時間;[[CC]YY]MMDDhhmm[.ss];
原創文章,作者:N27_yangjifeng,如若轉載,請注明出處:http://www.www58058.com/84288
理論性的知識和實操一樣重要,再接再勵。