LINUX file attributes in detail

A file attribute detailed
hardness links:
LS -Li detail information file includes an inode number
file 111 and 333 are hardwired same inode number
file 111 and 444 are connected to the inode number of different software - data file corresponding to the shortcut

2, the type of file attribute information file detailed ---

  • Common file
    d directory
    l link file software
    c / b device file
    s socket file socket (network transmission)
    | pipe file

3, view the command belongs directory
which + mv command mkdir cp
whereis + command
locate --- query ordinary file path where the
yum install -y mlocate
updatedb --- view the file information needs to be updated database theory: and find different, locate from / var / lib / mlocate / mlocate.db library to find records
rather than find the same look in the system. Use locate to find when a new file is created must updatedb
Refresh library to find

find command:
find / The -type d -name "directory name" according to the file name to find
find / -type f -name "username" according to the directory name lookup
find / -type f -iname "User Name" ignore case Find

size find / -type f -size +100 lookup based on file size greater than the size of 100KB refers inod
find / -type f -size 100 to find the file size is equal to 100KB according to
find / -type f -size -100 lookup based on file size less than 100KB of
find / -type f -mtime +7 find files 7 days before the
find / -type f -mtime 7 Find exactly 7 days file
find / -type f -mtime -7 to find files 7 days

Create archive file
tar -zcvf /xxx/xxx.tar.zip / xxx / xxx compressed first, after the file to be compressed
z: indicates compressed data mode
c: represents the creation of a compressed packet
v: displaying the compression process
f : specify a cabinet path
extracting
tar -zxvf /xxx/xxx.tar.zip
the X-: express-extracting
Note: when data compression than me I'll kick out inside a directory or file does not compress
it with (--exclute) the parameters of a directory or file to exclude

4, file permissions attributes detailed
r4 read read
w2 write write
x1 excute the implementation of
the file's owner rwx 777
all group files rwx 777
others file rwx 777
Note: The owner of the file permissions to the general high, the other will not give 777 permissions

User Classification:
root user system superuser lawless id (0)
virtual users without a home directory in the system, the system can not log in / etc / passwd users can see a lot of sense that the virtual user id range (1-999 )
normal user privileges limited id (1000-)

Directory or file permissions belongs relationship:
owner creates a user directory or file
all belong to the default group for all group and owner of his namesake (any user can join all the groups, so that the users have the same rights to all groups of
other people

Three kinds of timestamps of files or directories:
STAT XXX view commands
Access means "access."
A cat, more, less, grep, sed, cp, when a document file, Access file at the time of this record will be updated on a terminal
with ls -lu see the file access time is the last time. For the catalog, place), access time of this directory will be updated
just enter the directory would not change its access time, but as long as ls to view the contents of this directory (wherever
Modify means "change (Content ), "or" write. "
when you change the contents of a file time, modify this file time records will be updated

Change change (state or property).
To a file or directory as mv, chown, chgrp after operation, its time record is updated Change

Check the system time set

Use of defined time format: to do at the time of subsequent data backup apply, the system can generate a file or directory according to the date of the backup
files to be backed up cp's / etc / date ‘+%F %T’
set the system time
data -s '20200202' to set the date
data -s '20200202 15:02:02' to set the date and the hour, minute
dATE -d "+ 1'd Day"
dATE -d "-1 Day"
settings NTP time synchronization service
ntpdate IP (NTP server) (yum -y install ntpdate)

Details inode file block and
iNode: storage file details
stored in the pointer information file
formatted disk, the file system defined iNode formed
block: storing content information
formatted disk block form definition file system
directories and files and the block contains information iNode
directory under the directory inode attribute information block catalog file name contains the
data file inode file attribute information block file contains
disk capacity is enough? There are two factors: iNode and block. If the number is not enough disk iNode will report insufficient disk space
reasons: a, too many small files take up a lot iNode
b, data block too many take up a lot
of disk partition size is not enough to delete a large file method:
A, find large files full partition: find / mnt -f -size + 100M to find files larger than the 100M
b, find large files full partition: du -sh / mnt | sort -h first find and then sort by file size Sort du

See the iNode df -i disk
block a block = 4096 bytes default
disk to optimize
the file size of a single block size require several block
655K data 100k / block 7 th block
the getconf view of PAGESIZE block size
mke2fs -b 4096 / dev / hda6 adjust the block size
so that: optimization larger single block, block requires fewer, the less disk I / O
10K data 100k / block 1 th block
so that: a single block may be set smaller save disk space

The difference between hard and soft details of file attributes connected
hard-wired: iNode same number multiple files, the source file is deleted file has no effect on hard-wired
ln filename hard-wired file name
Soft connection: the equivalent of a shortcut file, the source file is deleted soft link file gone
ln -s filename soft link file name
NOTE: the directory can create a soft link, you can not create hard links
to add:

Interview questions: under ll / etc / -d command '80' hard connections What does it mean? Express / 78 the number of subdirectories (each file has a directory essentially iNode links etc directory, remove itself / etc and these two directories total of 78

The system symbol information:
a basic information symbol
$ variable information to
take the specified column (awk)
identification information of the user

! Negated, exclude mean
taking the most recent command (history)
indicates a mandatory (text editor)
| results will be handed out in front of the pipe behind the command command processing,
often with | xargs representing the display line can also be | xargs -n1 It indicates a packet

Indicates a comment (script)

表示root用户                                

"" Resolved double quotation marks output
'single quotation marks indicates normal output
反引号 表示优先处理a command in

Standard output redirection symbol

Standard LINUX file attributes in detailreference output redirection symbol added
2> represents redirect the error output parameter 2
2 >> additional error output redirection symbol
<redirect stdin
xargs </oldboy.txt
TR 'replacement information' replaced information '</ oldboy. TXT
<< command to write multiple lines using the contents of the documents
CAT oldboy.txt >> << EOF
xxx
xxx
xxx
EOF
PS: you can write in the script menu
Second, the logic symbol series
&& represents the logical and relations
|| represents a logical or relationship

Guess you like

Origin blog.51cto.com/13858002/2421435