Linux file attribute information

Posted by aynsoft on Mon, 20 Dec 2021 20:48:52 +0100

1, System software installation method:

1. Install software using yum (recommended)

yum install -y Software name		---Install software

advantage:Software dependencies can be resolved
 shortcoming:Unable to implement customized installation

2. rpm installation software

rpm -ivh software package.rpm		  ---Install software

i -- install				---Software installation
v -- verbose				---Displays the installation process
h -- hash					---display hash Tag information

advantage:No need to rely on network installation software
 shortcoming:Software dependencies cannot be resolved

3. Compile and install software

(1) Configuration process:

./configure --prefix=/application/nginx --with-http_ssl_module --with-http_stub_status_module

--prefix=PATH		---Modify program installation path
--with-xxxx			---The software can support functions
--without-xxxx		---Cancel software default function

(2) Compilation process: let the system identify the source code information

make

(3) Installation process: (compile and install)

make install

advantage:Customized installation can be realized
 shortcoming:Software dependencies cannot be resolved
 Installation premise:A compiled software source package is required
 Install software:Trilogy

4. Installing software in binary package mode

advantage:Save software installation time
 shortcoming:Software dependencies cannot be resolved
 Installation premise:Binary package required
 setup script:Unzip--Save the extracted directory to the specified system directory---You can use it directly

2, Detailed description of file attributes:

1. Document type concept description

(1) File type introduction:

The file type information does not change with the file extension name

(2) Document type description:

(1) Ordinary file:(f/-)					/Plain text file/Binary file/Data file

(2) Catalog file:(d)

(3) Link file:(l)	    			Soft link file

(4) Equipment file:(character/block)		Character device file/Block device file

(5) Socket file:(socket)				Socket interface file

(6) Pipeline file:(pipe)	    			Pipeline file

(3) File type viewing method:

file file information:	catalogue	link	to configure	journal	script	compress	...

.conf		---configuration file

.log		---log file

.sh			---Script file

.py			---Script file

2. File directory related commands

(1) Display command absolute path information (which)

Display command file absolute path information (which/whereis):

which timedatectl

which command to view the command file path range:

which sed

The PATH environment variable can specify the PATH range where the command file is saved:

echo $PATH

You can modify the PATH environment variable temporarily or permanently:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local"

which sed

PATH="$PATH:/usr/local"

(2) Quickly locate file path information

When locating the specified file information, you need to retrieve the database file first

updatedb								---Update or create database files

locate fff01.txt						---After the database file is updated, find the file to locate the path of the file

ll /var/lib/mlocate/mlocate.db

file /var/lib/mlocate/mlocate.db

(3) Quick find data information command: find

Command syntax structure:

find Find path range find data criteria			---Quickly find data information
Method 1: find data by name

Given the file name, make an accurate search

find /root/desktop   -name "fff01.txt" 

Unknown file name, fuzzy search

find /root/desktop   -name "ff*.txt" 

find /root/desktop   -name "*.txt" 

find /root/desktop   -name "ff*" 

Ignore file name case lookup

find /root/desktop   -iname "Ff*.txt" 
Method 2: find data according to file type

Recursively find all directory type data

find /etc -type d

find /etc -type d|wc -l

Find data by directory level

find /etc -mindepth 1 -type f

find /etc -mindepth 1 -type f|wc -l

find /etc -maxdepth 1 -type f

find /etc -maxdepth 1 -type f|wc -l
Method 3: find data according to file size

Find less than how much data

find /etc -size -30k|wc -l

Find data larger than how much capacity

find /etc -size +30k|wc -l

Find data of specified capacity

find /etc -size 30k
Method 4: search according to time information

Indicates how many days ago the data was

find /oldboy/ -mtime +60

Data within days

find /oldboy/ -mtime -60

Represents data that is exactly 60 days from the current time

find /oldboy/ -mtime60

(4) Data compression and packaging command tar

Packed compressed data relative path:

tar zcvf /Compressed file save path/Compressed package file information data information to be compressed 01 data information to be compressed 02 03 04 ...

tar zcvf ./ss.tar.gz ./fstab_2021-08-17_08:59:31 ./ifcfg-eth0_2021-08-17_08:59:31

z		---use gzip Compress and pack data
c		---Create a compressed package file
v		---Displays the data compression process
f		---Identify the path information of the compressed package

Absolute path packed compressed data:

tar zcvf /root/backup/ssd.tar.gz /var/log

tar: Removes the beginning from the member name“/"		---Compressed data information. If an absolute path is used, it will be compressed/Directory information removal
 explain:Remove/The root directory information is mainly used to avoid that the data in the original directory will be overwritten after decompression (default setting))

Compressed data exclusion function:

tar zcvf /root/s1.tar.gz /root/backup/ --exclude=/root/backup/fstab_2021-08-18_08:38:43          ---Exclude single data information

tar zcvf /root/s2.tar.gz /root/backup/ --exclude-from=/root/desktop/s.txt							 ---Exclude multiple data information

To view compressed package data information:

tar tf Compressed package file       		   ---View the contents of the compressed package file

t							  ---The list displays the data information in the compressed package,However, the compressed package will not be decompressed

Process of decompressing data information:

tar zxvf

×							  ---Extract data information in pressure sink package

find deletes some data information of the directory

Mode 1:Locate the directory itself for exclusion
find /root/backup/ -mindepth 1 ! -name "*.tar.gz"|xargs rm -rf
xargs	---After the pipe symbol, it means that the result information generated by the command in front of the pipe symbol is converted into parameter information and handed over to the user xargs Subsequent commands are processed

Mode II:Delete some data
find /root/backup/ -mindepth 1 ! -name "*.tar.gz" -delete

Mode III:Delete some data
find /root/backup/ -mindepth 1 ! -name "*.tar.gz" -exec rm -rf {} \;

Compress or decompress data: why move the / directory in front of the data information

The first course: Environmental preparation

Create important profile information:

cat /conf/oldboy.conf
oldboy123

The second process: compress and save backup data information

tar zcvPf /backup/oldboy.tar.gz /conf/oldboy.conf/ 

conf/oldboy.conf

tar tf / backup/oldboy.tar.gz

tar:Removes the beginning from the member name“/"

/ conf/oldboy.conf			---View data not moved out/information

The third process: modify and edit the original configuration file

cat /conf/oldboy.conf

oldboy123 456 789

The fourth process: decompress the data information (do not move out of the root directory)

tar xPf /backup/oldboy.tar.gz

View that the original data information is overwritten

cat /conf/oldboy.conf

oldboy123

3. File permission information

Value information corresponding to permission symbol

r=4		w=2		x=1		- = 0

rw-r---wx	411
-wxr-xr--	367
r--rwx--x	542

conclusion:Under normal circumstances,The file data permission has 9 bits == 3 Special permission bit

4. File users and user groups

File user information

Introduction to user information concept:

user:  Corresponding data users can be managed, and corresponding process users can be managed

	  The system will identify the user according to the user number == UID

User group:Multiple people can manage a data file at the same time, and the permissions of multiple people can be set and adjusted at the same time

	  The system identifies the user group according to the user group number == GID
	  
Hard disk        four hundred     ==  Zhang San bought it            Owner
 Storage server 40000   ==  Zhang San, Li Si, Wang Wu raised money to buy power–group

System user classification:

System super administrator   root(emperor)      0         Have absolute control over the system

System virtual user     nobody(puppet)   1-999      Can manage processes/Data information(Unable to log in to the system/Cannot have home directory)

Ordinary users of the system     admin(minister)    1000+      auxiliary root User management system(Must be root Assign special rights to users)

5. File attribute time information

File time type:

Access time (atime): Access time--The time when the file was viewed and opened

Modify time (mtime): Modification time--The time when the file data content was changed

Change time (ctime): Change time--Change time of file attribute information

Just after creating a file, access the file to view the time information

touch ss.txt

stat ss.txt

Access: 2021-08-19 16:50:53.086154957 +0800
Modify: 2021-08-19 16:50:53.086154957 +0800
Change: 2021-08-19 16:50:53.086154957 +0800


File access view:

cat ss.txt 

stat ss.txt 

Access: 2021-08-19 16:54:29.572770926 +0800		---Access time change
Modify: 2021-08-19 16:50:53.086154957 +0800
Change: 2021-08-19 16:50:53.086154957 +0800

Modify file content information:

vim ss.txt

stat ss.txt 

Access: 2021-08-19 16:57:10.843212956 +0800		---The file was opened and accessed while editing the file
Modify: 2021-08-19 16:57:10.843212956 +0800		---Time after message change
Change: 2021-08-19 16:57:10.843212956 +0800		---File size attribute change


Modify file attribute information::

chown admin ss.txt 

stat ss.txt 

Access: 2021-08-19 16:57:10.843212956 +0800
Modify: 2021-08-19 16:57:10.843212956 +0800
Change: 2021-08-19 17:03:10.491198713 +0800		---When the file permission attribute changes, it will change

View the display time as required

date "+%Y-%m-%d %A %H:%M:%S"	---View the current system time

date "+%F"						---View current system date(specific date)

date "+%T"						---View the current system time(Hour, minute and second)

date -d "-1 day"				---Show how many days ago in the past

date -d "+10 day" 			    ---Displays the number of days in the future


11 00, January 1: 00 Day before data backup(10 March 31) backups-generate hosts-11 January 1

cp /etc/hosts /root/backup/hosts-$(date +%F_%T -d "-1 day") hosts-10 March 31

Modified on:

date -s "2020-12-12 12:12:12"	---Complete adjustment time information