search
HomeOperation and MaintenanceLinux Operation and MaintenanceLinux study notes file system (organized and shared)

This article brings you relevant knowledge about the file system in Linux, including some directory descriptions and related issues about file operations. I hope it will be helpful to you.

Linux study notes file system (organized and shared)

Memory usage


Partial directory description

  • /bin

    • bin is the abbreviation of Binary. This directory stores the most commonly used commands
  • /boot

    • Stores some core files used when starting Linux, including some connection files and image files
  • /etc

    • is used to store All configuration files and subdirectories required by the system administrator
  • /lib

    • store the most basic dynamic link shared libraries of the system. The function is similar to the DLL file in Windows. Almost all applications require these shared libraries.
  • /lost found

    • Normally it is empty. When the system is shut down illegally, some files are stored here
  • /media

    • The Linux system will automatically recognize some devices, such as U disks, CD-ROM drives, etc. After recognition, Linux will mount the recognized devices. Go to this directory
  • /mnt

    • The system provides this directory to allow users to temporarily mount other file systems. You can put the optical drive Mount it to /mnt/, and then enter the directory to view the contents of the optical drive
  • /opt

    • This is for the host The directory where additional installed software is placed. For example, if you install an ORACLE database, you can put it in this directory. It is empty by default.
  • ##/proc

      This directory is a virtual directory. It is a mapping of system memory. You can obtain the system memory by directly accessing this directory. information.
    • The contents of this directory are not on the hard disk but in the memory. Some files in it can be modified directly.
    • For example, you can use the following command to block the ping command of the host so that others cannot ping your machine
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
  • /root

      This directory is the user home directory of the system administrator, also known as the super privileged person
  • /sbin

      s means Super user. The system management program used by the system administrator is stored here.
  • /srv

      This directory stores Some data that need to be extracted after starting some services
  • ##/sys
  • This is a big change in the linux2.6 kernel. In this directory Installed sysfs, a new file system in the 2.6 kernel.
    • The sysfs file system integrates the information of the following three file systems, the proc file system for process information, the devfs file system for devices, and the devpts file system for pseudo terminals. The file system is a visual reflection of the kernel device tree.
    • When a kernel object is created, the corresponding files and directories are also created in the kernel object subsystem
  • /tmp
  • This directory is used to store some temporary files
  • /usr
  • This is a very important directory for users Many applications and files are placed in this directory, similar to the program files directory under Windows
  • /usr/bin
  • System Applications used by users
  • /usr/sbin
  • Relatively advanced management programs and system daemons used by super users
  • /usr/src
  • Default placement directory for kernel source code
  • /var
  • This directory stores ever-expanding things. It is customary to place directories that are frequently modified in this directory, including various log files
  • /run
  • is a temporary file system that stores information other than system startup. When the system restarts, the files in this directory should be deleted or cleared.
File operations

    ll

File attributes:

Linux files are basically divided into 3 attributes: readable (r), writable (w), executable (x) . The sorting order of permission positions is (taking -rw-r--r-- as an example): -rw (user)-r (user group in the same group)--r (other users)--

User can read and write, users in the same group can read, and other users can read

Number of files:

If it is a file, the number of files is 1; if it is a directory , the number of files is the number of files in the directory

The group it belongs to:

Each owner can have more than one group, but most users should only belong to the same group group, only when the system administrator wants to give the user special permissions, he may give him another group

File size:File size is expressed in bytes. Empty directories are generally 1024byte

Creation date:In the format of "month, day and time"

  • cd

##cd Change directory command
cd / Return to the root directory
cd /home Switch to the home directory
cd .. Return to the upper level directory '.' indicates the current directory
cd /var/ftp/pub Switch to the pub directory at one time
cd /root Switch to the root user directory (Note: the root user directory is displayed as "~")

Directory operations are available Use absolute paths (starting from the root directory) or relative paths (starting from the current directory). In order to change directories quickly and accurately, directory operations should be good at using the TAB key to automatically complete directory names
  • cp

cp Copy command
cp 123 /var/ftp/pub Copy the file named 123 to the pub directory
cp 123 /var/ftp/pub/456 Copy the file named 123 to the pub directory and rename it to 456
cp -r /var/ftp/pub /home Copy the pub directory to the home directory
  • mv

##mvMove commandmv 123 /var/ftp/pubMove the file named 123 to pub Under the directory mv 123 /var/ftp/pub/456Move the file named 123 to pub directory and rename it to 456mv /var/ftp/pub /homeMove the pub directory Go to the home directory##mv 123 456Rename file 123 in the current directory to 456
  • rm

##rm Delete Command
rm 123 Delete the file named 123 in the directory (the file exists), you need to press y to confirm
rm -f 123 Delete the file, force deletion, no confirmation required
rm -r abc Delete the directory named abc under the directory (the directory exists), you need to press y to confirm
rm -fr abc Forcibly delete the directory without confirmation
rm -f a* #Forcibly delete all files starting with a in the directory, no confirmation is required
  • touch

##touchCreate filetouch 123Create a file named 123touch a b cCreate multiple files
    stat

Inode: File identifier

Links: Link to Inode

Access: The last time the file contents were viewed

Modify: The time when the file content was last modified

Change: The time when the file permissions or other file attributes were last modified

Use stat to make the above three times consistent again

  • ln

##ln##ln -s yyy syyyln yyy hyyy
Link (shortcut)
Create a link to yyy ( Soft link) syyy, and then use cat syyy to view the content in yyy
Create The link (hard link) of yyy is hyyy, and then use cat hyyy to view the content in yyy

cat/tac/less

##cat/less
View text content command cat /etc/passwd
View the text file passwd Content, you can only view the last page, only suitable for viewing small text files within one screen less /etc/passwd
You can use the up and down cursor keys and page up and down to scroll through the entire contents of the text file passwd. After viewing, press q to exit tac
is similar to the cat command, except that the content is displayed from back to front

  •  head/tail

head -3 yyy 显示yyy文件的前三行内容
tail -3 yyy 显示yyy文件的后三行内容
head -3 yyy | tail -1 显示yyy文件第三行的内容
tail -f yyy 监控yyy的内容(监控Inode,当文件删除后,监控就停止,再次创建同名文件时,不会继续监控)
tail -F yyy 监控yyy文件的内容(监控文件名,当文件删除后,监控会暂停,再次创建同名文件时,监控会继续)

移除yyy后

tail -F yyy停止

因为还有一个hyyy指向和yyy一样的Inode,所以

tail -f yyy还在继续监控

 移除hyyy后

tail -f yyy停止监控

 再次创建yyy后,并向yyy中追加“hello”

tail -F yyy追加hello

tail -f yyy没有反应

 再次向yyy中追加数据

ping www.baidu.com >> yyy//将ping的内容追加到yyy文件中
tail -F yyy继续追加新的信息

  • find

find / -name yyy 全局搜索yyy文件的位置
find /ect -name yyy 在etc目录及子目录查找yyy文件
find /etc -name a*a

在etc目录及子目录查找a开头a结尾的文件

相关推荐:《Linux视频教程

The above is the detailed content of Linux study notes file system (organized and shared). For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete
Linux Operations: Utilizing the Maintenance ModeLinux Operations: Utilizing the Maintenance ModeApr 19, 2025 am 12:08 AM

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

Linux: How to Enter Recovery Mode (and Maintenance)Linux: How to Enter Recovery Mode (and Maintenance)Apr 18, 2025 am 12:05 AM

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

Linux's Essential Components: Explained for BeginnersLinux's Essential Components: Explained for BeginnersApr 17, 2025 am 12:08 AM

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

Linux: A Look at Its Fundamental StructureLinux: A Look at Its Fundamental StructureApr 16, 2025 am 12:01 AM

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

Linux Operations: System Administration and MaintenanceLinux Operations: System Administration and MaintenanceApr 15, 2025 am 12:10 AM

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

Understanding Linux's Maintenance Mode: The EssentialsUnderstanding Linux's Maintenance Mode: The EssentialsApr 14, 2025 am 12:04 AM

Linux maintenance mode is entered by adding init=/bin/bash or single parameters at startup. 1. Enter maintenance mode: Edit the GRUB menu and add startup parameters. 2. Remount the file system to read and write mode: mount-oremount,rw/. 3. Repair the file system: Use the fsck command, such as fsck/dev/sda1. 4. Back up the data and operate with caution to avoid data loss.

How Debian improves Hadoop data processing speedHow Debian improves Hadoop data processing speedApr 13, 2025 am 11:54 AM

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

How to learn Debian syslogHow to learn Debian syslogApr 13, 2025 am 11:51 AM

This guide will guide you to learn how to use Syslog in Debian systems. Syslog is a key service in Linux systems for logging system and application log messages. It helps administrators monitor and analyze system activity to quickly identify and resolve problems. 1. Basic knowledge of Syslog The core functions of Syslog include: centrally collecting and managing log messages; supporting multiple log output formats and target locations (such as files or networks); providing real-time log viewing and filtering functions. 2. Install and configure Syslog (using Rsyslog) The Debian system uses Rsyslog by default. You can install it with the following command: sudoaptupdatesud

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 Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

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.