Linux Learning Commands Summary ⑤

Source: Internet
Author: User
Tags touch command

#stat命令: Viewing file information

[Email protected]_168_102_centos ~]# stat Test.log  File: ' Test.log'  size:0             blocks:0          IO block:4096   Regular Empty filedevice:ca01h /51713d    inode:483339      links:1Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (  500/2014-08-11 14:27:24.000000000 +08002014-08-11 14:27:24.000000000 +0800  2014-08-11 14:27:24.000000000 +0800

Description

Access: Visit time Modify: Modify time change: state changing time

Stat *: View all file information in the current directory

[Email Protected]_168_102_centos ~]# ls2014-05-16Test.log[[email Protected]_168_102_centos~]# Stat *File: '2014-05-16'size:4096 blocks:8 IO block:4096directorydevice:ca01h/51713d inode:483336 Links:2Access: (0755/drwxr-xr-x) Uid: (0/root) Gid: (0/root) Access:2014-05-16 15:01:40.000000000 +0800Modify:2014-05-16 15:01:40.000000000 +0800Change :2014-05-16 15:01:40.000000000 +0800File: ' Test.log'size:0 blocks:0 IO block:4096Regular Empty filedevice:ca01h/51713d inode:483339 links:1Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (500/Wanghan) Access:2014-08-11 14:27:24.000000000 +0800Modify:2014-08-11 14:27:24.000000000 +0800Change :2014-08-11 14:27:24.000000000 +0800[[Email Protected]_168_102_centos~]#

#touch命令: Modify the file timestamp, or create a new file that does not exist (file size, block information, file permissions, timestamp)

Create a new file:

[Email protected]_168_102_centos ~]# ls2014-05-16~~]# ls2014-05-16   ~]#

Touch–c: Do not create empty files

The file timestamp is typically updated with the touch command, and if the file does not exist, the touch command automatically creates the specified file. If you do not want to create any empty files by using the Touch command, use the TOUCH-C command.

[Email Protected]_168_102_centos ~]# Clear [[Email Protected]_168_102_centos~]# stat test.log File: ' Test.log'size:0 blocks:0 IO block:4096Regular Empty filedevice:ca01h/51713d inode:483339 links:1Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (500/Wanghan) Access:2014-08-11 15:00:56.000000000 +0800Modify:2014-08-11 15:00:56.000000000 +0800Change :2014-08-11 15:00:56.000000000 +0800[[Email Protected]_168_102_centos~]# Touch-c Test.log [[Email Protected]_168_102_centos~]# stat test.log File: ' Test.log'size:0 blocks:0 IO block:4096Regular Empty filedevice:ca01h/51713d inode:483339 links:1Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (500/Wanghan) Access:2014-08-11 15:03:34.000000000 +0800Modify:2014-08-11 15:03:34.000000000 +0800Change :2014-08-11 15:03:34.000000000 +0800[[Email Protected]_168_102_centos~]# ls0812080808 2014-05-16Test.log[[email Protected]_168_102_centos~]# Touch-C Ceshi.sh[[email Protected]_168_102_centos~]# ls0812080808 2014-05-16Test.log[[email Protected]_168_102_centos~]#

TOUCH-T: Modify the timestamp to modify the specified date time

[Email Protected]_168_102_centos ~]# stat test.log File: ' Test.log'Size:8 blocks:8 IO block:4096regular filedevice:ca01h/51713d inode:483343 links:1Access: (0644/-rw-r--r--) Uid: (500/wanghan) Gid: (500/Wanghan) Access:2014-08-11 15:16:06.000000000 +0800Modify:2014-08-11 15:16:06.000000000 +0800Change :2014-08-11 15:16:06.000000000 +0800[[Email Protected]_168_102_centos~]# touch-c-T 08080808Test.log [[Email Protected]_168_102_centos~]# stat test.log File: ' Test.log'Size:8 blocks:8 IO block:4096regular filedevice:ca01h/51713d inode:483343 links:1Access: (0644/-rw-r--r--) Uid: (500/wanghan) Gid: (500/Wanghan) Access:2014-08-08 08:08:00.000000000 +0800Modify:2014-08-08 08:08:00.000000000 +0800Change :2014-08-11 15:16:30.000000000 +0800

Touch–a: Modify Access time only

[Email Protected]_168_102_centos ~]# stat test.log File: ' Test.log'Size:8 blocks:8 IO block:4096regular filedevice:ca01h/51713d inode:483343 links:1Access: (0644/-rw-r--r--) Uid: (500/wanghan) Gid: (500/Wanghan) Access:2014-08-11 15:26:48.000000000 +0800Modify:2014-08-11 15:26:48.000000000 +0800Change :2014-08-11 15:26:48.000000000 +0800[[Email Protected]_168_102_centos~]# touch-c-a-t 08080808Test.log [[Email Protected]_168_102_centos~]# stat test.log File: ' Test.log'Size:8 blocks:8 IO block:4096regular filedevice:ca01h/51713d inode:483343 links:1Access: (0644/-rw-r--r--) Uid: (500/wanghan) Gid: (500/Wanghan) Access:2014-08-08 08:08:00.000000000 +0800Modify:2014-08-11 15:26:48.000000000 +0800Change :2014-08-11 15:27:44.000000000 +0800

Touch-m: Modify only modified time

[Email Protected]_168_102_centos ~]# stat test.log File: ' Test.log'Size:8 blocks:8 IO block:4096regular filedevice:ca01h/51713d inode:483343 links:1Access: (0644/-rw-r--r--) Uid: (500/wanghan) Gid: (500/Wanghan) Access:2014-08-08 08:08:00.000000000 +0800Modify:2014-08-11 15:26:48.000000000 +0800Change :2014-08-11 15:27:44.000000000 +0800[[Email Protected]_168_102_centos~]# touch-c-m-t 09090909Test.log [[Email Protected]_168_102_centos~]# stat test.log File: ' Test.log'Size:8 blocks:8 IO block:4096regular filedevice:ca01h/51713d inode:483343 links:1Access: (0644/-rw-r--r--) Uid: (500/wanghan) Gid: (500/Wanghan) Access:2014-08-08 08:08:00.000000000 +0800Modify:2014-09-09 09:09:00.000000000 +0800Change :2014-08-11 15:29:03.000000000 +0800

#cp命令: Copying Files or directories

Copying a single file

Description: If the target is a file and does not exist, create a file

[email protected]_168_102_centos tmp]# ls2014-08-04-212053  a  agent_cmd.sock  ap_1002.pid  ap_1004.pid  ap_1005.pid  ap_1007.pid  ap_1008.pid  ap_1014.pid  ceshi  test  test.sh  test_1.sh  wanghan  wanghan110[[email protected]_168_102_centos tmp]# CP test.sh openstack[[ email protected]_168_102_centos tmp]# ls2014-08-04-212053  agent_cmd.sock  ap_1004.pid  ap_ 1007.pid  ap_1014.pid  openstack  test.sh    wanghana                  ap_1002.pid     ap_1005.pid  ap_ 1008.pid  ceshi        test       test_1.sh  wanghan110[[email protected]_168_102_centos tmp]#

Description: If the target is a file and exists, it will prompt whether to overwrite

[ email Protected]_168_102_centos tmp]# cat test_1.sh123 [email Protected]_168_102_centos tmp]# Cat Wanghan//usr/local/sa/agent/log, prefix sap1002, lognum, LogSize, loglevel 2[[Email protected]_ 168_102_centos tmp]# CP test_1.sh Wanghan/test.shcp:overwrite ' Wanghan/test.sh '? Y[[email Protected]_168_102_centos tmp]# cat wanghan/test.sh123

Description: If the target exists and is a directory, copy the file to the destination directory and keep the original

[Email protected]_168_102_centos tmp]# CP test_1.sh wanghan/[[email protected]_168_102_centos tmp]# ls WANGHANAP_ 1014.pid  ceshi  test  test.sh  test_1.sh[[email protected]_168_102_centos tmp]#

Copying multiple files

Description: If the target exists and is a file, replication cannot be made

[[email protected]_168_102_centos tmp]# ls wanghanap_1014.pid  ceshi  test  test.sh  test_1.sh[[ Email Protected]_168_102_centos tmp]# cp test.sh test_1.sh Wanghan/test.shcp:target ' Wanghan/test.sh ' is Not a directory

Description: If the target exists and is a directory, copy the files to the destination directory and keep the original

[Email protected]_168_102_centos tmp]# cp test.sh test_1.sh wanghan/ceshi[[emailprotected]_168_102_centos tmp]# LS Wanghan/Ceshi123  test.sh  test_1.sh

Description: If the target does not exist, replication cannot be performed

[email protected]_168_102_centos tmp]# cp test_1.sh test.sh lianxicp:target ' Lianxi' is not a directory[[emai L Protected]_168_102_centos tmp]#

Copy a separate directory

Description: If the target exists and is a file, replication cannot be made

[Email protected]_168_102_centos tmp]# cp-r Test wanghan/test.shcp:cannot overwrite non-directory ' wanghan/ test.sh ' with directory ' test '

Description: If the target does not exist, create a new directory

[[email protected]_168_102_centos tmp]# ls wanghanap_1014.pid  ceshi  test  test.sh  -R test wanghan/openstack[[email protected]_168_102_centos tmp]# ls wanghanap_1014.pid  ceshi  OpenStack  Test  test.sh  test_1.sh[[email protected]_168_102_centos tmp]# ls wanghan/openstack/

Description: If the target exists and is a directory, copy the source directory to the destination directory and keep the original

[[Email protected]_168_102_centos tmp]# cp-r test wanghan/openstack[[email protected]_168_102_centos tmp]# ls Wanghan/openstacktest[[email protected]_168_102_centos tmp]#

Cp-r: Recursively handles files in the specified directory with subdirectories

[[Email protected]_168_102_centos tmp]# cp-r test wanghan/openstack[[email protected]_168_102_centos tmp]# ls Wanghan/openstacktest[[email protected]_168_102_centos tmp]#

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.