Linux file management command example analysis [display, view, statistics, etc.]

Linux file management command example analysis [display, view, statistics, etc.]

This article describes the Linux file management commands with examples. Share with you for your reference, the details are as follows:

1. Display file contents

cat : Display the contents of a file
tac : Display contents in reverse order

2. Change file permissions

chmod : Change file permissions
-R recursive changes
chown: Change the file owner
-R recursive changes
chgrp: Change the group to which a file belongs
-R recursive changes

>chmod 666 1.txt
 
> chown user1 1.txt
 
>chgrp user1 1.txt


3. Link files

1) Protect the source program

2) Easy access

ln [options] source file or directory target file or directory
-s soft link
Changing one file will affect another file. Deleting the source file will affect the use of the linked file.

-d hard link

Hard-linked files look the same as normal files. Changing one file will affect the other file. When the source file is deleted, the hard-linked file will not be affected.

4. Find files

find [directory list] [matching parameters] [matching criteria]
-name Search by file name
-group Query by the group to which the file belongs
-user query by user name

> find /home/user1 -name 1.txt


5. Other related commands

df View hard disk space
-l View local hard disk
-h Display in 1024-bit
-H Display in base 1000
-T Display partition type
-t Display the specified partition type
-x does not display the specified partition type

> df -lh
 
> df -lH


du View file size
-b In bytes
-k in kilobytes
-m is in megabytes
-h Display in 1024-bit
-H Display in base 1000
-s show statistics

du -s 123 Statistics folder size

mount command

mount /dev/cdrom /mnt/cdrom


umount uninstall command

umount /mnt/cdrom


eject Eject the CD-ROM drive

I hope this article will be helpful for everyone's Linux system maintenance.

You may also be interested in:
  • Use of Linux passwd command
  • Detailed explanation of the use of Linux time command
  • Use of Linux ln command
  • Detailed explanation of commands to read and write remote files using Vim in Linux system
  • Detailed explanation of the usage of grep command in Linux
  • A complete list of commonly used Linux commands (recommended collection)
  • Solve the problem that the commonly used Linux command "ll" is invalid or the command is not found
  • Baota Linux panel command list
  • Extract specific file paths in folders based on Linux commands
  • Linux nohup command principle and example analysis
  • Use of Linux usermod command

<<:  MySQL scheduled task implementation and usage examples

>>:  JavaScript to implement the function of changing avatar

Recommend

Detailed steps for QT to connect to MYSQL database

The first step is to add the corresponding databa...

Centos8 builds nfs based on kdc encryption

Table of contents Configuration nfs server (nfs.s...

Detailed tutorial on using Docker to build Gitlab based on CentOS8 system

Table of contents 1. Install Docker 2. Install Gi...

How to set the width attribute to the style of the span tag

If you directly set the width attribute to the sty...

WeChat applet implements calculator function

This article shares the specific code for the WeC...

Independent implementation of nginx container configuration file

Create a container [root@server1 ~]# docker run -...

CSS method of clearing float and BFC

BFC BFC: Block Formatting Context BFC layout rule...

5 cool and practical HTML tags and attributes introduction

In fact, this is also a clickbait title, and it c...

Example code for implementing stacked carousel effect with HTML+CSS+JS

Effect: When the slideshow moves in one direction...

Sample code for a large drop-down menu implemented in pure CSS

This is a large drop-down menu implemented purely...

Difference between src and href attributes

There is a difference between src and href, and t...

Summary of the use of element's form elements

There are many form elements. Here is a brief sum...