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

What are the commonly used disk management and file directory management commands in Linux

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

Share

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

This article mainly introduces "what are the commonly used disk management and file directory management commands in Linux". In daily operation, I believe many people have doubts about what commonly used disk management and file directory management commands in Linux. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what commonly used disk management and file directory management commands are used in Linux". Next, please follow the editor to study!

Disk management

In schedule disk management, we are most commonly used to view the current disk usage, check the size of the current directory, and package compression and decompression.

View disk space

View disk space utilization

The code is as follows:

Df-h

-h: human abbreviation to display the result in a human readable way (with units such as Mmax G, if this parameter is not added, the displayed number is in B)

The code is as follows:

$df-h

/ opt/app/todeav/config#df-h

Filesystem Size Used Avail Use% Mounted on

The code is as follows:

/ dev/mapper/VolGroup00-LogVol00

2.0G 711M 1.2G 38% /

/ dev/mapper/vg1-lv2 20G 3.8G 15G 21% / opt/applog

/ dev/mapper/vg1-lv1 20G 13G 5.6G 70% / opt/app View the space occupied by the current directory

The code is as follows:

Du-sh

-h humanized display

-s recursively the size of the entire directory

The code is as follows:

$du-sh

653m view the sorted size of all subfolders in the current directory

For i in `ls`; do du-sh $I; done | sort

Or:

Du-sh `ls` | sort packaging / compression

Packing

In linux, packaging and compression are implemented in two steps; packaging is to merge multiple files into one file; compression command achieves size

The code is as follows:

Tar-cvf etc.tar / etc

Co.out2

Co.out35: egrep'Aguilar LSHA777vig C 'TSF_STAT_111130.log.035 > co.out35

File and directory permission modification

The code is as follows:

Chown

Change the owner of the file

The code is as follows:

Chmod

Change the file read, write, execute and other attributes

Recursive subdirectory modification:

The code is as follows:

Chown-R tuxapp source/

Increase script executable permissions:

The code is as follows:

Chmod axix myscript

Add an alias to the file

Create symbolic links / hard links:

The code is as follows:

Ln cc ccAgain

Hard connection; delete one and you will still be able to find

The code is as follows:

Ln-s cc ccTo

: symbolic link (soft link); delete the source, another cannot be used; (the latter ccTo is the newly created file)

Piping and redirection

Batch command connection execution:

Concatenation: using semicolon

If the previous one is successful, execute the latter one, otherwise, do not execute: & &

If the previous failure occurs, the latter one executes: |

Eg:

The code is as follows:

Ls / proc & & echo suss! | | echo failed.

Can prompt naming whether the execution of the or failed successfully

The same effect as above is:

The code is as follows:

If ls / proc; then echo suss; else echo fail; fi

Redirect:

The code is as follows:

Ls proc/.c > list > & l

Output the result to list and the error to the end of the same file

The equivalent is:

The code is as follows:

Ls proc/.c & > list

The code is as follows:

Ls list1 list2

Multiple files can be listed at the same time

Clear the file:: > a.txt

Redirect: best text: echo aa > > a.txt

Set environment variabl

After starting the account, the file is automatically executed as .profile, and then you can set your own environment variables through this file.

Generally, the installed software path needs to be added to the path:

The code is as follows:

PATH=$APPDIR:/opt/app/soft/bin:$PATH:/usr/local/bin:$TUXDIR/bin:$ORACLE_HOME/bin;export PATH

Bash Quick input or deletion

Keyboard shortcuts:

Ctl-U removes all characters from the cursor to the beginning of the line and, in some settings, deletes the entire line

Ctl-W deletes the character from the current cursor to the nearest space before it

Ctl-H backspace, delete the characters before the cursor

Ctl-R: match the closest file and then output

Comprehensive application

The code is as follows:

Cat-v record.log | grep AAA | grep-v BBB | wc-l

Find the total number of records in the record.log that contain AAA but not BBB

At this point, the study of "what are the commonly used disk management and file directory management commands in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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