Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction and operation of Linux file directory

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1 describe the system directory name rules and uses of the Linux distribution

Linux's file system uses a tree-structured directory rule so that there is no duplication between directories, where there are the following important directories:

/ boot: the directory where the kernel is loaded when the operating system starts

/ root: the administrator's home directory, which can place some variables configured by the administrator

/ home: the home directory of the ordinary user, which stores the data of the ordinary user

/ etc: configuration file for operating system and software

/ dev: device files of the operating system, such as hard drives, etc.

/ proc: real-time data running in memory

/ run: the file of the running process

/ sys: system files in operation of the system

/ var: changed data files, such as log log related

/ tmp: temporary file

/ usr: stored binaries and lib library files that the program depends on

/ srv: data file of the service provided by the system

2 what is the metadata information of the description file, what does it mean, and how to view it? How do I change the timestamp information of a file?

Files in Linux system are divided into two parts: metadata and data. Metadata is the description of file attributes, including file ownership, file permissions, file timestamp, file size and node number, and so on. The metadata of the file is stored as part of the file index, while the real data part of the file is stored on disk as a block, pointing to all the blocks of the file through a pointer according to the index table of the file. The Stat command can view the metadata information of the file, and the touch command can change the timestamp information of the file.

Timestamp information of the file:

Access time, access time, time to read file contents

Modify time, the time when the file content changes, the time when the data content changes

Change time, file attribute change time, metadata content change time

Use the touch command to create a new file and change the timestamp information of the file to exist; examples are as follows:

Touch ff.txt create file ff.txt

Touch ff.txt updates the atime,mtime and ctime timestamps of the file

Touch-a ff.txt updates only atime and ctime timestamps

Touch-m ff.txt updates only mtime and ctime timestamps

3 summarize the difference between soft connection and hard link, and use an example to illustrate it.

In Linux system, hard links are essentially different names of the same file in the disk file system, while soft links are similar to shortcuts, with the following differences:

(1) the creation command is different:

Ln file name hard link name

Ln-s file name soft link name

The relative path of the source file that creates the soft link, which is referenced relative to the soft link

(2) the file node number is different:

A hard link is a different name of the same file, so the node number is the same; a soft link is a point to the file and has its own node number

(3) the number of links to the file is different:

The number of links in hard links refers to the number of files with different names, and the number of links in soft links is the same as that in general files.

(3) the sizes of files are different:

The hard-linked file size refers to the file size in the metadata information; the soft-linked file size refers to the string length of the linked file

(4) the characteristics are different:

Hard links are files with different names on the same file system, and the inode node information is the same, so hard links cannot be created across disk partitions or folders, but soft links can be created both across partitions and based on folders.

(5) the deletion method is different:

Deleting a hard link with less than one link is equivalent to deleting a file name with a different name, and the file can continue to be accessed; otherwise, the file will not be accessible.

Delete a soft link and delete a file pointing to. When the soft connection is a folder, when the delete operation

Rm-rf ldir_slink/ deletes the contents of the directory, not soft links

Rm-rf ldir_slink removes soft links and does not affect directory content

4 what are the file management commands on Linux, their common usage and related demonstrations.

The file management commands on the Linux system are:

(1) touch f1.txt creation file

(2) create directory for mkdir-p / data/dir1/dir2

(3) cp copies files or directories

Cp-a / etc/fstab. Copy the file to the current directory and keep its original name

Cp-a / etc/fstab fstab_bak copies the file to the current directory and renames it

Cp-a / etc/ etc.bak copy directory and rename it to etc.bak

Cp-a / etc/ etc.bak copy to / etc.bak/ when the etc.bak directory exists

Cp cannot copy hidden files. When you need to copy all files in a directory, you can use the

Cp-a / etc/. Use dots to represent all the contents of the current directory

(4) mv moves files or directories

Mv f1.txt f2.txt moves files and renames them

Mv f2.txt dir1/ moves files to the dir1/ directory

Mv etc.bak dir1/ Mobile etc.bak the name is dir1

Mv etc.bak dir1/ moves etc.bak to dir1/ directory; (dir1 already exists)

5 copy / etc/profile to the / tmp directory and use the find replace command to delete the line leading white space characters in the / tmp/profile file

(1) cp-a / etc/profile / tmp; copy files to the / tmp directory

(2) vim profile enters extended command mode and enter% slots @ ^ [[: space:]] + @ @ g

% full text match, ^ [: space:] + search criteria, with one or more spaces at the beginning, replace with empty content

(3) sed-ri's@ ^ [[: sapce:]] + ([^ [: space:]]. *) @\ 1@g'profile can also be implemented by using a stream editor.

6 set tab indentation to 4 characters in vim

In the Vim file editor, a tab button is 8 spaces by default. You can change the device to 4 characters by setting parameters.

(1) temporary modification: enter: set tabstop=4 in the vim editor extension command mode

(2) the configuration file takes effect permanently. Add set tabstop=4 to the .vimrc file.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report