Ka ho sebelisa mekhoa e meng ea sejoale-joale hammoho le lisebelisoa tsa khale tsa taelo, o ka natefeloa le ho ntlafatsa tlhahiso ea hau.
Mosebetsing oa rona oa letsatsi le letsatsi ho Linux / Unix, re sebelisa lisebelisoa tse ngata tsa taelo ea taelo - mohlala, du ho lekola ts'ebeliso ea disk le lisebelisoa tsa sistimi. Tse ling tsa lisebelisoa tsena li bile teng ka nako e telele. Mohlala, top e hlahile ka 1984, mme tokollo ea pele ea du e qalile ka 1971.
Ho theosa le lilemo, lisebelisoa tsena li 'nile tsa ntlafatsoa le ho kenngoa lits'ebetsong tse fapaneng, empa ka kakaretso ha lia tloha hole le liphetolelo tsa tsona tsa pele, ponahalo le ts'ebeliso ea tsona le tsona ha lia fetoha haholo.
Tsena ke lisebelisoa tse kholo tseo batsamaisi ba bangata ba tsamaiso ba li hlokang. Leha ho le joalo, sechaba se thehile lisebelisoa tse ling tse fanang ka melemo e eketsehileng. Tse ling tsa tsona li na le sebopeho sa sejoale-joale se setle, ha tse ling li ntlafatsa ts'ebeliso ea tsona haholo. Phetolelong ena, re tla bua ka mekhoa e mehlano e fapaneng le lisebelisoa tse tloaelehileng tsa line ea taelo ea Linux.
1. ncdu vs du
Tšebeliso ea Disk ea Nurses (
ncdu e sekaseka disk ebe e bonts'a liphetho tse hlophisitsoeng ka li-directory kapa lifaele tse sebelisoang khafetsa, mohlala:
ncdu 1.14.2 ~ Use the arrow keys to navigate, press ? for help
--- /home/rgerardi ------------------------------------------------------------
96.7 GiB [##########] /libvirt
33.9 GiB [### ] /.crc
7.0 GiB [ ] /Projects
. 4.7 GiB [ ] /Downloads
. 3.9 GiB [ ] /.local
2.5 GiB [ ] /.minishift
2.4 GiB [ ] /.vagrant.d
. 1.9 GiB [ ] /.config
. 1.8 GiB [ ] /.cache
1.7 GiB [ ] /Videos
1.1 GiB [ ] /go
692.6 MiB [ ] /Documents
. 591.5 MiB [ ] /tmp
139.2 MiB [ ] /.var
104.4 MiB [ ] /.oh-my-zsh
82.0 MiB [ ] /scripts
55.8 MiB [ ] /.mozilla
54.6 MiB [ ] /.kube
41.8 MiB [ ] /.vim
31.5 MiB [ ] /.ansible
31.3 MiB [ ] /.gem
26.5 MiB [ ] /.VIM_UNDO_FILES
15.3 MiB [ ] /Personal
2.6 MiB [ ] .ansible_module_generated
1.4 MiB [ ] /backgrounds
944.0 KiB [ ] /Pictures
644.0 KiB [ ] .zsh_history
536.0 KiB [ ] /.ansible_async
Total disk usage: 159.4 GiB Apparent size: 280.8 GiB Items: 561540
U ka tsamaea ka har'a likenyo u sebelisa linotlolo tsa metsu. Haeba o tobetsa Enter, ncdu e tla hlahisa litaba tsa buka e khethiloeng:
--- /home/rgerardi/libvirt ----------------------------------------------------
/..
91.3 GiB [##########] /images
5.3 GiB [ ] /media
U ka sebelisa sesebelisoa sena ho etsa mohlala, ho tseba hore na ke lifaele life tse nkang sebaka sa disk haholo. U ka ea bukeng e fetileng ka ho tobetsa konopo e ka letsohong le letšehali. Ka ncdu o ka hlakola lifaele ka ho tobetsa konopo ea d. E kopa netefatso pele e hlakola. Haeba u batla ho tima tšobotsi ea ho hlakola ho thibela tahlehelo ea phoso ea lifaele tsa bohlokoa, sebelisa khetho ea -r ho nolofalletsa mokhoa oa ho fihlella ho bala feela: ncdu -r.
ncdu e fumaneha bakeng sa li-platform tse ngata tsa Linux le liphallelo. Mohlala, o ka sebelisa dnf ho e kenya ho Fedora ka kotloloho ho tsoa litsing tsa polokelo tsa semmuso:
$ sudo dnf install ncdu
2. htop vs holimo
Ka ho sa feleng htop e shebahala tjena:
Ho fapana le top:
Ntle le moo, htop e bonts'a tlhaiso-leseling e mabapi le sistimi e kaholimo, le phanele ea ho tsamaisa litaelo tse sebelisang linotlolo tsa ts'ebetso tse tlase. U ka e hlophisa ka ho tobetsa F2 ho bula skrine ea tlhophiso. Ho Litlhophiso, o ka fetola mebala, oa kenya kapa oa tlosa litekanyetso, kapa oa fetola likhetho tsa pontšo ea kakaretso.
Leha o ka fihlela ts'ebeliso e ts'oanang ka ho fetola litlhophiso tsa liphetolelo tsa morao-rao tsa top, htop e fana ka tlhophiso e bonolo ea kamehla, e etsang hore e sebetse haholoanyane hape e be bonolo ho e sebelisa.
3. tldr vs motho
Sesebelisoa sa mola oa taelo oa tldr se bonts'a tlhahisoleseling e nolofalitsoeng mabapi le litaelo, haholo mehlala. E ile ea ntlafatsoa ke sechaba
Ke habohlokoa ho hlokomela hore tldr ha se sebaka sa motho. E ntse e le sesebelisoa sa ho hlahisa maqephe a motho se nepahetseng ka ho fetesisa. Leha ho le joalo, maemong a mang motho ha a na thuso. Ha o sa hloke tlhahisoleseling e felletseng mabapi le taelo, o leka feela ho hopola ts'ebeliso ea eona ea mantlha. Mohlala, leqephe la monna bakeng sa taelo ea curl le na le mela e ka bang 3000. Leqephe la tldr la curl le bolelele ba mela e 40. Karolo ea eona e shebahala tjena:
$ tldr curl
# curl
Transfers data from or to a server.
Supports most protocols, including HTTP, FTP, and POP3.
More information: <https://curl.haxx.se>.
- Download the contents of an URL to a file:
curl http://example.com -o filename
- Download a file, saving the output under the filename indicated by the URL:
curl -O http://example.com/filename
- Download a file, following [L]ocation redirects, and automatically [C]ontinuing (resuming) a previous file transfer:
curl -O -L -C - http://example.com/filename
- Send form-encoded data (POST request of type `application/x-www-form-urlencoded`):
curl -d 'name=bob' http://example.com/form
- Send a request with an extra header, using a custom HTTP method:
curl -H 'X-My-Header: 123' -X PUT http://example.com
- Send data in JSON format, specifying the appropriate content-type header:
curl -d '{"name":"bob"}' -H 'Content-Type: application/json' http://example.com/users/1234
... TRUNCATED OUTPUT
TLDR e bolela “nako e telele haholo; ha baa ka ba bala": ke hore, mongolo o mong ha oa ka oa hlokomolohuoa ka lebaka la mantsoe a teng a feteletseng. Lebitso le loketse sesebelisoa sena hobane maqephe a monna, leha a le molemo, ka linako tse ling a ka ba malelele haholo.
Bakeng sa Fedora, tldr e ngotsoe ka Python. U ka e kenya u sebelisa mookameli oa dnf. Ka tloaelo, sesebelisoa se hloka phihlello ea inthanete ho sebetsa. Empa moreki oa Python oa Fedora o lumella maqephe ana hore a jarolloe le ho bolokoa bakeng sa phihlello kantle ho marang-rang.
4.jq khahlano le sed/grep
jq ke processor ea JSON bakeng sa mohala oa taelo. E tšoana le sed kapa grep, empa e etselitsoe ho sebetsa ka data ea JSON. Haeba u moqapi kapa molaoli oa sistimi ea sebelisang JSON mesebetsing ea letsatsi le letsatsi, sena ke sesebelisoa sa hau.
Monyetla o ka sehloohong oa jq holim'a lisebelisoa tse tloaelehileng tsa ho sebetsana le mongolo joalo ka grep le sed ke hore e utloisisa sebopeho sa data sa JSON, se u lumella ho etsa lipotso tse rarahaneng ka polelo e le 'ngoe.
Mohlala, o leka ho fumana mabitso a setshelo faeleng ena ea JSON:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"labels": {
"app": "myapp"
},
"name": "myapp",
"namespace": "project1"
},
"spec": {
"containers": [
{
"command": [
"sleep",
"3000"
],
"image": "busybox",
"imagePullPolicy": "IfNotPresent",
"name": "busybox"
},
{
"name": "nginx",
"image": "nginx",
"resources": {},
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Never"
}
}
Matha grep ho fumana lebitso la mohala:
$ grep name k8s-pod.json
"name": "myapp",
"namespace": "project1"
"name": "busybox"
"name": "nginx",
grep e khutlisitse mela eohle e nang le lebitso la lentsoe. U ka eketsa likhetho tse ling tse 'maloa ho grep ho e thibela,' me u sebelise mokhoa o tloaelehileng oa ho qhekella ho fumana mabitso a setshelo.
Ho fumana sephetho se tšoanang u sebelisa jq, ngola feela:
$ jq '.spec.containers[].name' k8s-pod.json
"busybox"
"nginx"
Taelo ena e tla u fa mabitso a lijana ka bobeli. Haeba u batla feela lebitso la setshelo sa bobeli, eketsa index ea likarolo tse ngata polelong ena:
$ jq '.spec.containers[1].name' k8s-pod.json
"nginx"
Kaha jq e tseba ka sebopeho sa data, e hlahisa liphetho tse tšoanang le haeba sebopeho sa faele se fetoha hanyane. grep le sed li kanna tsa se sebetse hantle ntlheng ena.
jq e na le mesebetsi e mengata, empa sengoloa se seng se hlokahala ho e hlalosa. Ho fumana lintlha tse ling ka kopo ikopanye
5. fd vs fumana
Ka mohlala, ha u batla lifaele bukeng ea polokelo ea Git, fd ha e kenyeletse lifaele tse patiloeng le li-subdirectories, ho kenyeletsa le .git directory, hape e hlokomoloha li-wildcards tse tsoang faeleng ea .gitignore. Ka kakaretso, e potlakisa lipatlisiso ka ho khutlisa liphetho tse nepahetseng ha u leka la pele.
Ka ho sa feleng, fd e etsa patlisiso e sa tsotelleng taba bukeng ea hajoale, e nang le tlhahiso ea mebala. Patlo e tšoanang e sebelisang taelo ea ho fumana e hloka ho kenya li-parameter tse eketsehileng moleng oa taelo. Ka mohlala, ho fumana lifaele tsohle tsa .md (kapa .MD) bukeng ea hajoale, u tla ngola taelo e kang ena:
$ find . -iname "*.md"
Bakeng sa fd e shebahala tjena:
$ fd .md
Empa maemong a mang, fd e boetse e hloka likhetho tse eketsehileng: mohlala, haeba u batla ho kenyelletsa lifaele tse patiloeng le li-directory, u tlameha ho sebelisa khetho ea -H, le hoja hangata sena se sa hlokehe ha u batla.
fd e fumaneha bakeng sa liphallelo tse ngata tsa Linux. Ho Fedora e ka kenngoa ka tsela ena:
$ sudo dnf install fd-find
Ha ua tlameha ho tela letho
Na u sebelisa lisebelisoa tse ncha tsa taelo ea Linux? Kapa na u lula ka ho khetheha holim'a tsa khale? Empa mohlomong u na le combo, na? Ka kopo arolelana phihlelo ea hau ho maikutlo.
E le papatso
Bareki ba bangata ba rona ba se ba ananetse melemo li-server tse matla!
sena
Source: www.habr.com