Linux Viewing file contents

Source: Internet
Author: User

1. $PATH
2.ls-al ~ (~ Show hidden files)

3 CD ~//back to your own master file
4.cp/var/log/wtmp. Copy to current directory, last "." Don't forget
Ls-l/var/log/wtmp wtmp
Cp-a/var/log/wtmp wtmp_2
Ls-l/var/log/wtmp wtmp_2
The entire data feature is exactly the same, which is the feature of-A.
Cp-r/etc//tmp
-R to copy directory

File Content Lookup
1.CAT Displays the contents of the file starting from the first line
2.TAC: Starting from the last line, you can see that the TAC is the write-down form of cat.
3.nl: When displayed, by the way output line number;
4.more: Page-by-page display of file contents
5.less: Similar to more, but better than more, it can page forward
6.head: Only a few lines
7.tail: Look at the end only a few lines
8.od: Read content in binary way

NL and Cat,tac are a one-time display of data in a breath to the screen

# More/etc/man.config
In more This run process, you can press the key to execute the result:
Space: Represents a page down;
Enter: represents a scrolling line;
/string: In the content that represents this content, query the string "string" down;
: F: Displays the file name immediately and the number of rows currently displayed;
Q: Immediately leave more, no longer display the contents of the file;
b or [Ctrl]-b: Represents the page back, this operation is only useful to the file, the pipeline is useless;

# Less/etc/man.config
In less this run process, you can press the key to execute the result:
Space: Represents a page down;
[PageDown]: flipping down one page;
[PageUp]: Flip up one page;
Enter: represents a scrolling line;
/string: In the content that represents this content, query the string "string" down;
? string: The string representing the contents of this content, up query "string";
Q: Leave less at once and no longer display the contents of the file;
b or [Ctrl]-b: Represents the page back, this operation is only useful to the file, the pipeline is useless;

#tail/etc/man.config
#默认情况下. Show the last 10 lines
#tail-N 20/etc/man.config
#显示最后20行
#tail-N +100/etc/man.config
#列出100行之后的数据
#tail-F/etc/man.config
#持续检测内容, wait until the input [ctrl]-c will leave the tail named detection

Ls
Modification Time (Mtime)
This time is updated when the "content data" of the file is changed. Content data refers to the contents of a file
Status Time (CTime)
When the file status changes, the time is updated, like file permissions and property changes
Access Time (Actime)
This time is updated when the contents of the file are read, such as when the cat reads

Ls-l--time=atime/etc/man.config


The most commonly used cases of touch:
1. Create an empty file;
2. Modify a file date to the current date (Mtime and Atime)


File default Permissions Umask

UMASK Specifies the default value of the current user's permissions when creating a file or directory

$umask
0002
$umask-S
By default:
If the user creates a file, the default is no executable (x) permission, and the maximum is 666, which is-rw-rw-rw-
If the user creates a new directory, the default is all permissions because X is related to whether it can enter this directory, that is, drwxrwxrwx

Umask refers to the permission that the default value needs to be lost (the first group is special permission, regardless of him)

File Hidden Properties
chattr [+-=][asacdistu] file or directory name
+: Add a special parameter
-: Delete a particular parameter
=: Only the following parameters are followed

I: Let a file cannot be deleted, renamed, set the connection can not write or read data. Very helpful for system security, only root can set this property
A: The file will only add data, not delete or modify the data, only the root can set this property

$ cd/tmp
$ touch attrtest//Create an empty file
$ chattr +i attrtest
$RM attrtest//Delete to see the error


$chattr-I attrtest//Cancel the I property of the file

Linux Viewing file contents

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.