Linux file Management-related commands

Source: Internet
Author: User

Linux file Management-related commands
  • View of File metadata (properties of the file itself)

    • Stat: Get metadata for the specified file

        $ stat test file: ' Test ' size:0 B locks:0 IO block:4096 Regular empty file device:802h/2050d inode:651942 links:1 Access: (0664/-r w-rw-r--) Uid: (500/centos) Gid: (500/centos) access:2018-08-03 21:57:38.527860605-0700 modify:2018-08-03 21:57:38.527860605-0700 change:2018-08-03 21:57:38.527860605-0700  
      • access:2018-08-03 21:5 7:38.527860605-0700 refers to the time the file was accessed
      • modify:2018-08-03 21:57:38.527860605-0700 refers to the time the file was modified
      • change:201 8-08-03 21:57:38.527860605-0700 refers to file change time
    • File: File content Type view command
      File/path/to/somewhere

        ' $ file test.txt test.txt:ASCII text '  
  • Text File View commands

    • Cat [OPTION] ... [File] ...: Link and display text file

      • Option
        • -E: Display line terminator
        • -T: Show tabs
        • -N: Numbering each line displayed
      [[email protected] Downloads]$ cat test.txt 109876[[email protected] Downloads]$ cat test2.txt 54321[[email protected] Downloads]$ cat test.txt test2.txt 109876   54321
    • More [OPTIONS ...] FILE
      • Option
        • -D: Flip and exit Tips
      • Use the same as man but can't page forward
    • Less [OPTIONS ...] FILE

      • More powerful than more can page forward, using the same as man (the man is called less)
    • Head [OPTION] ... FILE
      • Option
        • -C #: Specifies the contents of the before # bytes obtained
        • -N #: Specifies the first # line to get
    • tail [OPTION] ... [FILE] ...
      • -Just the opposite of head.
      • -F: Trace displays new additions to the file
  • Time Stamp management tool for files
    • Three time stamps
      • Access time: atime, reading file contents
      • Modify Time: Modify Mtime, change file contents
      • Change time: Changing CTime, metadata changes
    • Touch [OPTION] ... FILE ...
        • Option
          • -A: Change access time only
              [[email protected] downloads]# stat-c%x\n test2.txt 2018-08-03 22:26:53.148443735-0700n[[email protected] downloads]# touch-a test2.txt [[email protected] Downloads]# Stat-c%x\n test2.txt 2018-08-04 01:03:40.197146110-0700n  
          • -M: Change only modification time and change time
              [[EMAIL&N Bsp;protected] downloads]# stat-c%y test2.txt 2018-08-03 22:26:08.781013024-0700[[email protected] Downloads]# Touch-m test2.txt [[email protected] downloads]# stat-c%y test2.txt 2018-08-04 01:07:48.250958279-0700  

          • -T: Specify a specific time [[cc]yy]mmddhhmm[]. SS]
              [[email protected] downloads]# stat-c%y test2.txt 2018-08-04 01:09:34.094912552-0700[[email   protected] downloads]# touch-mt 201404052330.50 test2.txt [[email protected] downloads]# stat-c%y test2.txt 2014-04-05 23:30:50.000000000-0700  
          • -C: Do not create if the file does not exist

Linux file Management-related commands

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.