3 Txoj Hauv Kev Nrhiav Cov Ntaub Ntawv ntawm Linux

Cov txheej txheem:

3 Txoj Hauv Kev Nrhiav Cov Ntaub Ntawv ntawm Linux
3 Txoj Hauv Kev Nrhiav Cov Ntaub Ntawv ntawm Linux

Video: 3 Txoj Hauv Kev Nrhiav Cov Ntaub Ntawv ntawm Linux

Video: 3 Txoj Hauv Kev Nrhiav Cov Ntaub Ntawv ntawm Linux
Video: The gospel of Matthew | Multilingual Subtitles +450 | Search for your language in the subtitles tool 2024, Kaum ib hlis
Anonim

Nrhiav cov ntaub ntawv ntawm Linux system tuaj yeem nyuaj yog tias koj tsis paub yuav ua li cas. Txoj hauv kev zoo tshaj los nrhiav cov ntaub ntawv ntawm Linux yog siv ob peb lub davhlau ya nyob twg cov lus txib. Kev paub qee yam ntawm cov lus txib no tuaj yeem ua rau koj ua tiav kev tswj cov ntaub ntawv, thiab lawv muaj txiaj ntsig ntau dua li kev tshawb nrhiav yooj yim ntawm lwm cov haujlwm.

Kauj ruam

Txoj Kev 1 ntawm 3: Siv "nrhiav"

690519 1
690519 1

Kauj Ruam 1. Tshawb nrhiav cov ntaub ntawv los ntawm lub npe

Hom kev tshawb fawb no yog qhov yooj yim tshaj plaws, thiab koj tuaj yeem ua qhov no nrog nrhiav cov lus txib. Cov lus txib hauv qab no yuav ua qhov kev tshawb fawb raws li lo lus nkag rau hauv phau ntawv teev npe koj nyob nrog rau cov npe hauv nws.

nrhiav -iname "filename"

Yog tias koj siv -iname hloov chaw -name, qhov sib txawv ntawm cov ntawv sab saud thiab qis dua yuav tsis muaj txiaj ntsig. Qhov -name hais kom ua txiav txim siab cov ntawv loj thiab cov tsiaj ntawv tsawg los ua cov cim sib txawv

690519 2
690519 2

Kauj Ruam 2. Teeb qhov kev tshawb nrhiav kom pib hauv cov hauv paus hauv paus npe

Yog tias koj xav ua qhov kev tshawb fawb thoob plaws ntiaj teb, koj tuaj yeem ntxiv / hloov kho rau lo lus tseem ceeb. Tus hloov kho qhia cov lus txib nrhiav kom ntxaws, pib los ntawm cov hauv paus npe.

nrhiav / -iname "filename"

  • Koj tuaj yeem pib tshawb nrhiav hauv cov npe tshwj xeeb los ntawm kev hloov /hloov kho nrog cov npe kab, piv txwv li /home /pat.
  • Koj siv tau. lwm yam tshaj li / yog li kev tshawb fawb tsuas yog ua tiav hauv cov npe uas koj nyob hauv thiab kuj tseem muaj cov npe me me hauv nws.
690519 3
690519 3

Kauj Ruam 3. Siv cov cim tsiaj qus

* txhawm rau tshawb nrhiav txhua yam uas ib nrab phim koj cov ntsiab lus.

Tus cim * tus cim tuaj yeem siv los nrhiav cov ntaub ntawv uas nws lub npe tag nrho uas koj tsis paub, lossis yog tias koj xav nrhiav txhua cov ntaub ntawv nrog kev txuas tshwj xeeb.

nrhiav /tsev /pat -iname "*.conf"

  • Cov lus txib saum toj no yuav xa rov qab txhua cov ntaub ntawv.conf hauv tus neeg siv npe hu ua Pat (ntxiv rau cov ntawv sau npe nyob ntawd).
  • Koj kuj tseem tuaj yeem siv nws txhawm rau nrhiav txhua yam uas nws lub npe ua tau raws cov ntsiab lus ntawd. Piv txwv li, yog tias koj muaj ntau cov ntaub ntawv cuam tshuam nrog wikiHow, koj tuaj yeem pom lawv los ntawm kev ntaus "*wiki*".
690519 4
690519 4

Kauj Ruam 4. Ua kom cov txiaj ntsig tshawb nrhiav yooj yim los tswj

Yog tias cov txiaj ntsig tshawb fawb muaj ntau dhau, nws yuav nyuaj rau koj nrhiav cov ntawv koj xav tau. Siv tus cwj pwm | thiab xa cov txiaj ntsig tshawb fawb rov qab mus rau qhov program "lim" lim. Txoj kev ntawd, koj tuaj yeem hla dhau thiab lim cov txiaj ntsig tshawb fawb yooj yim dua.

nrhiav /tsev /pat -iname "*.conf" | tsawg dua

690519 5
690519 5

Kauj Ruam 5. Nrhiav cov txiaj ntsig tshawb fawb nrog hom tshwj xeeb

Koj tuaj yeem siv cov neeg hloov kho kom rov qab tau qee yam ntawm cov txiaj ntsig. Koj tuaj yeem tshawb nrhiav cov ntaub ntawv tsis tu ncua (f), phau ntawv teev npe (d), cov cim sib txuas (l), cov khoom siv cim (c), thiab thaiv cov cuab yeej (b) siv cov hloov pauv tsim nyog.

nrhiav / -type f -iname "filename"

690519 6
690519 6

Kauj Ruam 6. Lim cov txiaj ntsig tshawb fawb los ntawm qhov loj me

Yog tias koj muaj ntau cov ntaub ntawv nrog cov npe zoo sib xws, tab sis paub qhov loj ntawm cov ntawv koj xav tau, koj tuaj yeem lim qhov kev tshawb fawb los ntawm qhov loj me.

nrhiav / -size +50M -iname "filename"

  • Cov lus txib saum toj no yuav xa rov qab los ntawm 50 megabytes lossis ntau dua. Koj tuaj yeem siv + lossis - txhawm rau tshawb nrhiav cov ntaub ntawv nrog qhov loj dua lossis me dua. Tsis suav nrog + lossis - kos npe ua rau kev tshawb fawb rov qab tsuas yog ua tiav nrog qhov tseeb "raug" me me.
  • Koj tuaj yeem lim qhov kev tshawb fawb los ntawm bytes (c), kilobytes (k), megabytes (M), gigabytes (G), lossis 512 bytes (b) block. Nco ntsoov tias cov cim sib txawv ntawm cov ntawv loj thiab cov tsiaj ntawv me.
690519 7
690519 7

Kauj Ruam 7. Siv cov neeg ua haujlwm boolean los ua ke tshawb fawb lim

Koj tuaj yeem siv cov -and, -or, thiab -not ua haujlwm los ua ke sib txawv tshawb nrhiav.

nrhiav /travelphotos -type f -size +200k -not -iname "*2015*"

Cov lus txib saum toj no yuav nrhiav cov ntaub ntawv hauv "travelphotos" cov npe uas muaj ntau dua 200 kilobytes, tab sis tsis muaj lo lus "2015" hauv lawv lub npe

690519 8
690519 8

Kauj Ruam 8. Txheeb xyuas cov ntaub ntawv los ntawm tus tswv lub npe lossis kev tso cai

Yog tias koj tab tom sim nrhiav cov ntaub ntawv tshwj xeeb uas yog rau tus neeg siv tshwj xeeb, lossis tab tom nrhiav cov ntaub ntawv nrog qee qhov kev tso cai, koj tuaj yeem nqaim tshawb nrhiav.

nrhiav / -user pat -iname "filename" nrhiav / -group users -iname "filename" find / -perm 777 -iname "filename"

Cov piv txwv saum toj no yuav ua kev tshawb nrhiav rau cov neeg siv tshwj xeeb, pab pawg, lossis kev tso cai hauv lo lus tseem ceeb. Koj tseem tuaj yeem tshem tawm lub npe lub npe kom xa rov qab txhua cov ntaub ntawv uas haum rau hom ntawd. Piv txwv li, nrhiav / -phev 777 yuav xa tag nrho cov ntaub ntawv nrog 777 kev tso cai (tsis muaj kev txwv)

690519 9
690519 9

Kauj Ruam 9. Muab cov lus txib los ua qhov kev txiav txim thaum pom cov ntawv

Koj tuaj yeem ua ke nrhiav cov lus txib nrog lwm cov lus txib kom koj tuaj yeem ua cov ntaub ntawv xa rov qab los ntawm lo lus tseem ceeb nrog cov lus txib ntawd. Cais qhov nrhiav cov lus txib thiab cov lus txib thib ob nrog tus chij -exec, tom qab ntawd xaus kab nrog {};

nrhiav. -type f -perm 777 -exec chmod 755 {};

Cov lus txib saum toj no yuav tshawb nrhiav cov npe uas koj nyob hauv (thiab tag nrho cov npe hauv nws) rau cov ntaub ntawv nrog 777 kev tso cai. Tom qab ntawd, chmod hais kom ua yuav hloov qhov kev tso cai rau 755

Txoj Kev 2 ntawm 3: Siv "nrhiav"

690519 10
690519 10

Kauj Ruam 1. Nruab

nrhiav kev ua haujlwm. Qhov chaw hais kom ua feem ntau nrawm dua li nrhiav cov lus txib, vim yog kev siv database ntawm koj cov ntaub ntawv kaw lus. Tsis yog txhua hom Linux tau nruab nrog lub luag haujlwm nrhiav, yog li sau cov lus txib hauv qab no los nruab nws:

  • Ntaus sudo apt-tau hloov tshiab, tom qab ntawv nyem Enter.
  • Koj tuaj yeem nruab nws ntawm Debian thiab ubuntu zoo li no: Hom sudo apt-get install mlocate, tom qab ntawv nyem Enter. Yog tias kev nrhiav haujlwm tau teeb tsa ua ntej, koj yuav pom cov lus hloov chaw yog twb yog qhov tshiab tshaj plaws.
  • Ntawm Arch Linux, siv pacman tus thawj tswj hwm pob: pacman -Syu mlocate
  • Rau Gentoo, siv qhov tshwm sim: tshwm sim txav chaw
690519 11
690519 11

Kauj ruam 2. Hloov tshiab

nrhiav database Koj. Qhov chaw hais kom ua yuav tsis tuaj yeem pom dab tsi txog thaum nws tau tsim thiab hloov kho tshiab. Cov txheej txheem feem ntau ua tiav txhua hnub, tab sis koj tseem tuaj yeem hloov kho nws tus kheej. Koj yuav tsum ua qhov no yog tias koj xav siv txoj haujlwm nrhiav kom sai li sai tau.

Ntaus hauv sudo updatedb, tom qab ntawv nyem Enter

690519 12
690519 12

Kauj Ruam 3. Siv

nrhiav ua qhov kev tshawb nrhiav yooj yim.

Kev nrhiav haujlwm ua haujlwm tau sai, tab sis tsis muaj ntau txoj hauv kev xaiv raws li pom cov lus txib. Koj tuaj yeem tshawb nrhiav cov ntaub ntawv yooj yim ib yam nkaus rau txoj haujlwm nrhiav.

nrhiav -i "*.jpg"

  • Cov lus txib saum toj no yuav tshawb xyuas tag nrho cov kab ke rau cov ntaub ntawv nrog-j.webp" />
  • Zoo li nrhiav pom, tus -i hloov kho kuj ua rau cov ntawv loj thiab cov tsiaj ntawv me hauv cov ntsiab lus pom zoo ib yam.
690519 13
690519 13

Kauj Ruam 4. Txwv txoj kev tshawb fawb

Yog tias koj qhov kev tshawb fawb rov qab los ntau qhov txiaj ntsig uas nws nyuaj rau koj siv lawv, koj tuaj yeem txo cov txiaj ntsig ntawd nrog -n hloov kho, ua raws tus lej ntawm cov txiaj ntsig koj xav rov qab los.

nrhiav -n 20 -i "*.jpg"

  • Tsuas yog 20 qhov txiaj ntsig tshawb fawb yuav tshwm.
  • Koj tseem tuaj yeem siv | xa cov txiaj ntsig tshawb fawb mus rau qhov program lim tsawg dua kom yooj yim dua ntawm cov txiaj ntsig.

Txoj Kev 3 ntawm 3: Tshawb Nrhiav Cov Ntawv hauv Cov Ntaub Ntawv

690519 14
690519 14

Kauj Ruam 1. Siv qhov hais kom ua

pab kom pom cov kab ntawv hauv kab ntawv.

Yog tias koj tab tom nrhiav cov ntaub ntawv uas muaj cov kab lus tshwj xeeb lossis kab cim, koj tuaj yeem siv grep hais kom ua. Cov lus txib grep yooj yim muaj cov qauv hauv qab no:

grep -r -i "tshawb nrhiav"/path/to/directory/

  • Tus -r hloov kho ua qhov kev tshawb fawb "rov ua dua", yog li kev tshawb fawb yuav ua nyob rau hauv cov npe thiab txhua qhov chaw nyob hauv nws txhawm rau nrhiav cov ntaub ntawv uas muaj cov ntawv nrog cov lus tshawb nrhiav.
  • Tus -i hloov pauv qhia tias lo lus tshawb nrhiav tsis txawv ntawm cov ntawv loj thiab cov tsiaj ntawv me. Yog tias koj xav yuam kom tshawb nrhiav kom paub qhov txawv ntawm cov ntawv loj thiab cov tsiaj ntawv me, tsis quav ntsej tus -i hloov kho.
690519 15
690519 15

Kauj Ruam 2. Tshem cov ntawv ntau dhau

Thaum ua qhov kev tshawb fawb grep li saum toj no, koj yuav pom cov npe ntawv nrog cov ntawv sib piv tau hais tseg. Koj tuaj yeem zais cov ntawv sib piv thiab qhia tsuas yog cov npe phau ntawv npe thiab txoj hauv kev los ntawm kev ntxiv:

grep -r -i "tshawb nrhiav lo lus tseem ceeb"/path/to/directory/| cev d: f1

690519 16
690519 16

Kauj Ruam 3. Nkaum qhov lus yuam kev

Grep hais kom ua yuav rov ua yuam kev thaum sim nkag mus rau cov npe uas tsis muaj kev tso cai tsim nyog lossis thaum nkag mus rau cov npe uas tsis muaj dab tsi. Koj tuaj yeem xa cov lus yuam kev rau /dev /null kom lawv tsis tshwm sim.

grep -r -i "tshawb nrhiav lo lus tseem ceeb"/path/to/directory/2>/dev/null

Pom zoo: