search
HomeSystem TutorialLINUXIn-depth analysis of Linux directory structure: root directory, user directory, system configuration, etc.

1. Linux directory structure

linux在目录中查找文件_linux搜索文件所在目录_linux搜索目录命令

2. Directory purpose

/Root directory

/rootroot administrator home directory

/boot stores Linux startup files

/etcStorage system and software configuration files

/usr User command program storage directory

/homeGeneral home owner directory

/mnt device/file system mount point

/bin stores the most commonly used operating commands

/optApplication software installation directory, such as database, etc.

/tmp temporary directorylinux searches the directory where the file is located, stores temporary files

/var variable information storage area (system logs, website files, etc.)

/proc virtual file systemThe directory where the Linux search file is located, including process information

/sbin system administrator command storage directory

/dev device file, (hard disk is more common)

/libThe most basic dynamic link shared library

Common files in/etc directory

/etc/sshSSH remote shell configuration directory

/etc/shadow, /etc/passwd user configuration file, user password configuration file

/etc/NetworkManager/Network configuration directory of the NetworkManager program of Unongxin UOS

/etc/group user group configuration file

/etc/servicesService and port information

Common files in/proc directory

/proc/cpuinfo file to view detailed information about the cpu

All file systems currently mounted in the /proc/mounts system

/proc/version The kernel version number currently running on the system

/proc/vmstat Statistics of the current system virtual memory.

Common files in/dev directory

/dev/sda represents the first hard drive

linux在目录中查找文件_linux搜索文件所在目录_linux搜索目录命令

/dev/sda1 represents the first partition of the first hard disk

/dev/sda2 represents the second partition of the first hard disk

/dev/sdb represents the first hard drive

/dev/cdrom represents the hard disk

/dev/zero is used for null character output

/dev/null is used to be input, similar to the trash can

3. Directory path

Pathname

Absolute path: Start with the root directory.

Relative path: Start with the current directory.

Current directory..Superior directory.

[Note] When accessing a file, the user must provide the path where the file is located.

Paths are divided into relative paths and absolute paths.

The absolute path refers to the path starting from the "root" linux system tutorial, also known as the full path;

The relative path is the path starting from the user's working directory.

It should be noted that there is only one absolute path and one relative path to a certain file in the tree directory structure. The absolute path is deterministic and unchanged, while the relative path changes continuously as the user's working directory changes. When users want to access a file, they can refer to it by path name. And you can reference the file to be accessed based on its relative position to the user's working directory, without enumerating the full path name of the file.

Absolute path, relative path

➢Absolute path

Full path starting with /

[admin@linux]$cd/u01/app/oracle

[oracle@OEL64oracle]$pwd

/u01/app/oracle

➢Relative path

Does not start with /, only relative to the current working directory

[oracle@OEL64oracle]$cd/u01/app

[oracle@OEL64app]$cd./oracle

[oracle@OEL64oracle]$pwd

/u01/app/oracle

..Indicates the upper-level directory of the current directory, that is, the parent directory

[root@OEL64tmp]#cd/u01/app/oracle

[root@OEL64oracle]#pwd

/u01/app/oracle

[root@OEL64oracle]#cd..

[root@OEL64app]#pwd

/u01/app

.Indicates the current directory

[root@OEL64app]#pwd

/u01/app

[root@OEL64app]#cd./oracle

[root@OEL64oracle]#pwd

/u01/app/oracle

4. File name

File case resolution

Files starting with "." are implicit files

File name can be up to 255 characters (all characters are valid except forward slashes)

[oracle@OEL64~]$ls-al

total152

drwx------.26oracleoinstall4096Sep1915:59.

drwxr-xr-x.6rootroot4096Jun272013..

-rw-r--r--.1oracleoinstall685Sep1817:35.bash_profile

5. Basic directory file type-flag

File type representative characters:

Normal file-

Directory file d

Linked file l

Block device file b

Character device c

6. Directory file type-color

File type color:

Normal file--------------------Black

Directory file--------------------Black

linux搜索目录命令_linux搜索文件所在目录_linux在目录中查找文件

Symbolic link file--------------black

Device File--------------------Black

Executable file-----------------green-red

Picture file--------------------Pink green

Compressed file---------------------black

7. Common commands

Basic command: lspwd

Directory operation command: cdmkdirrmdirrmcpmv

File operation command: lessmorelessnanocattouchfile

Basic command: ls

ls command is used to display the target list, which is a highly used command in Linux.

The output information of the ls command can be displayed with color highlighting to partition different types of files.

Sentence pattern

ls(options)(parameters)

usage:

ls only lists visible files in the current directory

ls-l lists detailed information about files visible in the current directory

ls-hl lists detailed information and displays file size in readable size

ls-al lists detailed information of all files (including hidden)

Basic commands: pwd, cd

pwd displays the current path

$cd/u01/app/oracle

$pwd

/u01/app/oracle

cd changes the current working directory

$pwd

/u01/app/oracle

$cd/etc

$pwd

/etc

linux在目录中查找文件_linux搜索文件所在目录_linux搜索目录命令

Create and delete directory commands: mkdirrmdir

mkdir creates new directory

rmdir delete empty directory

Delete command: rm

rm delete files and directories

Note: Be careful when using the rm command. Because once a file is deleted, it is difficult to recover it.

For example: rm-rf/

Sentence pattern

rm(option)(parameter)

Options

-d: Delete the directory;

-f: Forcefully delete files or directories;

-i: Ask the user before deleting existing files or directories;

-r or -R: Recursive processing, processing all files and subdirectories in the specified directory together;

-v: Display the detailed execution process of the command.

Common usage:

rm-rf does not ask, delete all files under directory a

Copy command: cp

The cp command is used to copy one or more source files or directories to the specified destination file or directory.

Sentence pattern

cp(option)(parameter)

Options

-f: Forcefully copy files or directories, regardless of whether the target file or directory already exists;

-i: Ask the user before overwriting existing files

-R/r: Recursive processing, processing all files and subdirectories in the specified directory together;

-v: Display the operations performed by the command in detail.

Common usage:

cp-rf/a/b

or

cp-r-f/a/b

Commands: mv, touch, file

linux在目录中查找文件_linux搜索目录命令_linux搜索文件所在目录

mv Unicom or rename file

#mv/tmp/b.txt/home/oracle/.

#cd/home/oracle

#ls-alb.txt

-rw-r--r--.1rootroot0Sep2216:30b.txt

touch creates an empty file

#cd/tmp

#touchc.txt

#ls-alc.txt

-rw-r--r--.1rootroot0Sep2216:36c.txt

file detection file type

#filec.txt

c.txt:ASCIItext

Text display command: catlessmore

cat displays file content

#cat/tmp/alert.log

less displays the file content line by line. The function of the less command is very similar to that of more. Both can be used to browse the contents of text files. The difference is that the less command allows the user to browse the file forward or backward, while the more command can only browse the file forward. Browse before.

When using the less command to display a file, use the PageUp key to page down and the PageDown key to page up. To exit the less program, press the Q key.

#less/tmp/alert.log

moreDisplay file content screen by screen

#more/tmp/alert.log

Text editing command: nano

nano is a character terminal text editor. It is much simpler than vi/vim and is more suitable for Linux beginners. (You can use the nano editor in the early stage, and you must be able to use vi in ​​the middle and later stages, which is more common in Linux text control)

Sentence pattern:

nano file name

control:

Use Ctrl+O to save changes

Press Ctrl+X to exit

If you change the file, you will be asked if you need to save the changes. Enter Y to confirm saving, enter N not to save, and press Ctrl+C to cancel and return. If you enter Y Chinese linux operating system, the next step will ask you to enter the file name you want to save. If you do not need to change the file name, just press Enter; if you want to save it under another name (that is, save as), enter the new name and confirm. At this time, you can also use Ctrl+C to cancel the return.

ln: Shortcut method to create a directory or file

Construct a symbolic link file abc in the directory /usr/liu so that it points to the directory /usr/mengqc/mub1

ln-s/usr/mengqc/mub1/usr/liu/abc

The above is the detailed content of In-depth analysis of Linux directory structure: root directory, user directory, system configuration, etc.. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is the main purpose of Linux?What is the main purpose of Linux?Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

Does the internet run on Linux?Does the internet run on Linux?Apr 14, 2025 am 12:03 AM

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

What are Linux operations?What are Linux operations?Apr 13, 2025 am 12:20 AM

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Boost Productivity with Custom Command Shortcuts Using Linux AliasesBoost Productivity with Custom Command Shortcuts Using Linux AliasesApr 12, 2025 am 11:43 AM

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

What is Linux actually good for?What is Linux actually good for?Apr 12, 2025 am 12:20 AM

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

Essential Tools and Frameworks for Mastering Ethical Hacking on LinuxEssential Tools and Frameworks for Mastering Ethical Hacking on LinuxApr 11, 2025 am 09:11 AM

Introduction: Securing the Digital Frontier with Linux-Based Ethical Hacking In our increasingly interconnected world, cybersecurity is paramount. Ethical hacking and penetration testing are vital for proactively identifying and mitigating vulnerabi

How to learn Linux basics?How to learn Linux basics?Apr 10, 2025 am 09:32 AM

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

What is the most use of Linux?What is the most use of Linux?Apr 09, 2025 am 12:02 AM

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor