访问手机版  

Linux常用命令|Linux培训学习|考试认证|工资待遇与招聘,认准超级网工!

招聘|合作 登陆|注册

网络工程师培训

当前位置:网络工程师 > 技术课程 > linux > 热点关注 > linux常用命令

linux命令(mv,cp,touch)

时间:2019-09-07

linux格式化命令_linux命令_linux命令

[ligang@centos6 test]$ ll
total 4
-rw-r--r-- 1 ligang trainning    0 Mar 10 00:35 haha.txt
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:19 test1
[ligang@centos6 test]$ cp haha.txt test1/
[ligang@centos6 test]$ ll test1/
total 4
-rw-r--r-- 1 ligang trainning 0 Mar 10 00:36 haha.txt
-rw-r--r-- 1 ligang trainning 7 Mar 10 00:07 log1.txt
-rw-r--r-- 1 ligang trainning 0 Mar 10 00:10 log2.txt
[ligang@centos6 test]$ cp haha.txt test1/
[ligang@centos6 test]$ ll test1/
total 4
-rw-r--r-- 1 ligang trainning 0 Mar 10 00:36 haha.txt
-rw-r--r-- 1 ligang trainning 7 Mar 10 00:07 log1.txt
-rw-r--r-- 1 ligang trainning 0 Mar 10 00:10 log2.txt

linux命令_linux格式化命令_linux命令

(2)cp不能直接把文件夹复制给另外一个文件夹,否者要加参数-rf。如果要把一个文件夹下内容复制给另外一个文件夹则用dir/*

linux命令_linux格式化命令_linux命令

[ligang@centos6 test]$ cp test2/ test1
cp: omitting directory `test2/'
[ligang@centos6 test]$ cp -rf test2/ test1
[ligang@centos6 test]$ ll
total 12
-rw-r--r-- 1 ligang trainning    5 Mar 10 00:37 haha.txt
drwxr-xr-x 3 ligang trainning 4096 Mar 10 00:42 test1
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:40 test2
[ligang@centos6 test]$ mkdir test3
[ligang@centos6 test]$ cp -af test3 test1
[ligang@centos6 test]$ ll test1
total 16
-rw-r--r-- 1 ligang trainning    5 Mar 10 00:37 haha.txt
-rw-r--r-- 1 ligang trainning    7 Mar 10 00:07 log1.txt
-rw-r--r-- 1 ligang trainning    0 Mar 10 00:10 log2.txt
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test2
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test3
[ligang@centos6 test]$ mkdir test4
[ligang@centos6 test]$ c test4
-bash: c: command not found
[ligang@centos6 test]$ cd test4
[ligang@centos6 test4]$ touch test.txt
[ligang@centos6 test4]$ cd ..
[ligang@centos6 test]$ cp -rf test4/ test1
[ligang@centos6 test]$ ll test1
total 20
-rw-r--r-- 1 ligang trainning    5 Mar 10 00:37 haha.txt
-rw-r--r-- 1 ligang trainning    7 Mar 10 00:07 log1.txt
-rw-r--r-- 1 ligang trainning    0 Mar 10 00:10 log2.txt
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test2
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test3
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:45 test4
[ligang@centos6 test]$ cp  test4/* test1
[ligang@centos6 test]$ ll test1
total 20
-rw-r--r-- 1 ligang trainning    5 Mar 10 00:37 haha.txt
-rw-r--r-- 1 ligang trainning    7 Mar 10 00:07 log1.txt
-rw-r--r-- 1 ligang trainning    0 Mar 10 00:10 log2.txt
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test2
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:42 test3
drwxr-xr-x 2 ligang trainning 4096 Mar 10 00:45 test4
-rw-r--r-- 1 ligang trainning    0 Mar 10 00:45 test.txt

linux命令_linux格式化命令_linux命令

9linux命令,touch

linux命令_linux格式化命令_linux命令

功能:用来修改文件时间戳linux命令,或者新建一个不存在的文件。

-r把指定文档或目录的日期时间,统统设成和参考文档或目录的日期时间相同。

-t使用指定的日期时间,而非现在的时间。格式: [[CC]YY]MMDDhhmm[.SS]