Linux command--view file contents

  

  • cat: display file content from the first line;
  • tac: display from the last line, you can see that tac and cat are in reverse alphabetic order; Br>
  • nl: output line number when displayed;
  • more: one page to display the contents of the file;
  • less similar to more, but it can page forward;
  • head: just look at the first few lines;
  • tail: just look at the last few lines;
  • od: binary way to read the file;

    Command Details

    cat –n filename # Output line number when displayed, same as nl

    cat is a shorthand for Concatenate (continuous), the main function is to have a file The content is continuously displayed on the screen.

    tac (reverse display) is opposite to the display direction of Cat

    nl (adding line number when displaying) It is a one-time display of data to the screen with cat, tac, etc. Page turning

    Linux commands--modifying file time and creating new files

    Three time states of files

    Modification time(mtime) modification time

    status time (ctime) status time

    access time (atime) access time

    The time to view with the ls -l command is mtime

    touch -a only modify access Time

    touch –c only modify the time without creating a file

    touch –m only modify mtime

    The usual use of the touch command is:

  • Create an empty file
  • to modify a file date to the current date (mtime and atime)

    the default file permissions

    If the user establishes When the file is used, there is no executable (x) permission by default, that is, only two permissions of rw (-rw-rw-rw 666)

    If the user establishes the "directory", because x is possible or not Enter this directory, This default permissions are open to all, namely 777 (drwxrwxrwx)

    umask specified is & ldquo; the default values ​​need to lose privileges & rdquo ;. Since r, w, and x are 4, 2, and 1, respectively, that is, when the write permission is to be removed, 2 is entered, and when the read permission is removed, 4 is entered. Because umask is 022, user does not remove the attribute, but the attributes of group and others are removed by 2 (that is, the attribute of w)


    When the user creates a file: -rw- R--r--

    When creating a directory: drwxr-xr-x


    How to modify umask, if you want to change to 002

    Use umask command 002 to

    hidden file attribute

  • chattr (hidden attribute setting file)

    parameters used

    chattr & ndash; a : After setting, this file can only add data, not delete data

    chattr –i : it can make a file "cannot be deleted, renamed, set connection, can not be written or added Data”.

  • lsattr (hidden attribute display file)

    lsattr & ndash; a: the hidden file property page is displayed.

    Search for files

    find is not commonly used, slow

    whereis

    locate

    which (find executable file)

    which –a command List all commands

    whereis (find a specific file)

    whereis [-bmsu]file and directory name

    -b: Just find the binary file

    -m: only find the file in the manual path of the help file

    -s: only find the source file

    -u: the file without help < Br>

    Simple operation of the file system

    df directory or file name




  • Copyright © Windows knowledge All Rights Reserved