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

Linux system directory and common file management commands

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Linux system naming rules

1, the file name is up to 255 bytes

2, the file name, including the path, is up to 4095 bytes

3, blue-- > directory green-- > executable red-- > compressed file light blue-- > linked file gray-- > other files.

4, except for slashes and null, all characters are valid, but directory names and files that use special characters are not recommended, and some characters need quotation marks to refer to them

5. Standard Linux file system with case-sensitive filename

Linux system directory usage

/ boot: the directory where boot files are stored, including kernel files (vmlinuz) and boot loader (BootLoader,gtrub,grub2).

/ bin: basic commands used by all users; programs that cannot be associated to a separate partition and will be used when OS starts

/ sbin: basic commands for managing classes; programs that cannot be associated to a stand-alone partition and will be used when OS starts

/ lib: basic shared library files and kernel module files that the program depends on at startup (/ lib/modules)

/ lib64: a location dedicated to the storage of auxiliary shared library files on X86room64 systems

/ etc: configuration file directory

/ home: home directory for ordinary users

/ root: administrator's home directory

/ media: portable mobile device mount point

/ mnt: temporary file mount point

/ dev: storage location of device files and special files

/ opt: location where third-party applications are installed

/ srv: data used by services running on the system

/ tmp: temporary file storage location

/ usr: universal shared, read-only data

Bin: an application that ensures the full functionality of the system

Sbin:

Lib:32 bit usage

Lib64: only 64-bit systems exist

Include: the header file (header files) of the C program

Share: structured independent data, such as doc, man, etc.

Local: where third-party applications are installed

Bin, sbin, lib, lib64, etc, share

/ var: variable data files

Cache: application cache data directory

Lib: application state information data

Local: dedicated to storing variable data for applications under / usr/local

Lock: lock files log: log directories and files

Opt: designed to store variable data for applications under / opt

Run: running process-related data, usually used to store process pid files

Spool: application data pool

Tmp: save the temporary data generated between system restarts

/ proc: used to output the virtual file system related to the kernel process information

/ sys: used to output information about hardware devices on the current system, virtual file system

/ selinux: storage location of security enhanced Linux,selinux-related security policies and other information

View of file metadata information and field meaning

Stat command view

File: file name

Size: file size Blocks: number of disk blocks occupied by storage

Device: device information Inode:inode number Links: number of links

Access: permission Uid: owner Gid: group

Access: atime, last visit time

Modify: mtime, the time when the file content was modified

Change: ctime, modify file metadata

Use the touch command to modify timestamp information

Touch [OPTION]... FILE...

-a change only atime and ctime

-m changes only mtime and ctime

-t [[CC] YY] MMDDhhmm [.ss]

Specify timestamps for atime and mtime

The difference between soft links and hard links

1, essence: hard links: the same multiple names, soft links to different files

2. Hard links cannot cross partitions, while soft links can

3. The directory cannot create hard links, while soft links can

4. Interrelationship: soft links depend on the original file, while hard links do not.

5. Create hard links with the same inode number and soft links.

6. Create hard links, the number of links will be increased by 1, but soft links will not

7. The relative path of the soft link: the path of the original file relative to the linked file, and the relative path of the hard link is relative to the current path

8, file type, the hard link file type is the same as the original file, and the soft link file type is l

9. Command different ln-s to create soft links and ln to create hard links.

[root@mage01] # ln-s.. / F1 tst/f1.slk

[root@mage01 ~] # ln F1 tst/f1.hlk

[root@mage01] # ll-I F1 tst/f*

203900854-rw-r--r-- 2 root root 4 Feb 24 20:58 F1

203900854-rw-r--r-- 2 root root 4 Feb 24 20:58 tst/f1.hlk

67404995 lrwxrwxrwx 1 root root 5 Feb 24 21:01 tst/f1.slk->.. / F1

[root@mage01 ~] #

Common file management commands

Pwd displays the current working directory

Basename file base name

Dirname directory name

Cd switch working directory

Use absolute or relative paths:

Cd / home/wang/

Cd home/wang

Change to the parent directory: cd..

Switch to the current user home directory: cd

Switch to the previous working directory: cd-

Ls lists directory contents

S-a contains hidden files

Ls-l displays additional information

Ls-R directory recursion

Ls-ld directory and symbolic link information

Ls-1 file branch display

Ls-S is sorted from largest to smallest

Ls-t sort by mtime

Ls-u with the-t option, display and sort by atime from new to old

Ls-U is displayed in directory storage order

Ls-X sorts by file suffix

Cp replication

Common option

-I prompt before overwriting

-n does not cover, pay attention to the order of the two

-r,-R recursively copy the directory and all its internal contents

-an archive, equivalent to-dR-- preserv=all

-d-- no-dereference-- preserv=links does not copy the original file, only the link name

-p equals-- preserv=mode,ownership,timestamp

-- preserv [= ATTR_LIST]

Mode: permission

Ownership: belong to the main group

Timestamp:

Links

Xattr

Context

All

-f-- force

-u-- update only copies files where the source is newer than the destination or where the destination does not exist

-b destination exists, backup before overwriting, in the form of filename~

-- backup=numbered destination exists. Backup with digital suffix before overwriting

For example, cp-rv / etc/ / data/backupdate +% F # backs up all files under the / etc/ directory to a separate subdirectory of / data, and requires the subdirectory format to be backupYYYY-mm-dd. The backup process is visible.

Cp-a/root / / data/rootdir and copy all the files under / root to this directory, requiring that the original permissions be retained

Mv moves or renames files

-I interactive

-f compulsion

-b destination exists. Backup before overwriting

Rm deletion

-I interactive

-f forcibly delete

-r recursion

-- no-preserve-root deletion /

Rm-rf / * Delete all files

[root@xxx ~] # sed-ir's / ^ [[: space:]] + ([^ [: space:]]. +) $/\ 1Universe g'/ tmp/profile removes line leading white space characters

Set table to 4 characters in [root@xxx ~] # echo "set ts = 4" > > ~ / .vimrc vim

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