Me pehea te whakatutuki i te SysAdmin Terminal e whakamahi ana i te Tuhi Papa

El Tuhinga o te Shell, E pa ana ki te whakatinana i nga ota matatini e pā ana ki te GNU / Linux Terminal (Papatohu), he mea tino pai ki te mahi aunoa i nga mahi nui me nga mahi nui i roto i a tatou Pūnaha Mahi GNU / Linux, e taea ai e taatau te whakapai i ta maatau Nga Rauemi me te Waa.

Tīpakonga_007

Na reira, ko tana whakamahinga mai i te taatai ​​ka taea e taatau te whakamahi i nga whakahau whakahau uaua ma te ringa, ma te aunoa ranei, ma roto i nga tuhinga, hei mahinga ranei i roto i nga konae utaina aunoa i nga mahi kua whakaritea ranei i roto i te punaha Whakahaere. GNU / Linux. Ana mo a Kaiwhakamahi Waenga, Arā Atu Anō, SysAdmin ranei el rārangi (whakamana) mahi, matohi me / ranei panui kei runga i te Kaihauturu (PC / Tūmau) hei penapena Haora / Mahi Mo te mahi a-ringa ma te tangata ranei, he mea nui, he mea nui mo te mahi pai o mahi hei tohunga ngaiotanga.

A muri ake, ka whakaatuhia me pehea a raraunga (uara / tawhā) i penapenahia i mua i roto i te taurangi na te whakahau Putea Bash he hototahi ranei, ka taea te whakaatu ki te tauranga o to punaha Whakahaere GNU / linux, i runga i te huarahi mahi me te ngawari. Hei taapiri ki te whakatika i te wero a te Terminal.

Hipanga Tuatahi: Whakatikahia te .bashrc a to kaiwhakamahi

Ma te etita o taau i pai ai (vi, nano, me etahi atu) whakatika i te .bashrc konae o to kaiwhakamahi me tu ki roto i te kaainga o taua, ara, hei tauira: "/ Kaainga / taku_ whakamahi".

Whakauruhia nga korero o ia raarangi e whai ake nei me era atu taapiri e whakaarohia ana e koe he pai ki te whakaatu ki te kaiwhakamahi i te wa e whakahaere ana i tetahi taunga kaiwhakamahi:

sleep 3

clear

########################### PARÁMETROS DE MONITOREO ###########################

NOMBRE_SISTEMA=$(cat /etc/os-release | grep NAME | grep -v "VERSION" | sed -n '2p' | cut -f2 -d\")
VERSION_SISTEMA=$(cat /etc/os-release | grep VERSION= | sed -n '1p' | sed 's/VERSION=//' | sed 's/"//g')

FABRICANTE_CPU=$(grep "vendor_id" /proc/cpuinfo | sed q | awk '{print $3}')
MODELO_CPU=$(grep "model name" /proc/cpuinfo | sed q | cut -d ":" -f 2 | awk '{print $0}')
NUM_CPU=$(grep "processor" /proc/cpuinfo | sort -r | sed q | awk '{print $3}' | echo `expr $NUM_CPU + 1`)
NUCLEO_CPU=$(grep "cpu cores" /proc/cpuinfo | sed q | awk '{print $4}')
CACHE_CPU=$(grep "cache size" /proc/cpuinfo | sed q | cut -d ":" -f 2 | awk '{print $0}')

clear

printf %80s |tr " " "="
echo ""
echo "      ADVERTENCIA - USTED HA INICIADO SESIÓN EN EL EQUIPO SERVIDOR DE LA      "
echo "                             EMPRESA INSTITUCIÓN XYZ                                "
echo "       RECUERDE TENER EXTREMO CUIDADO CON CUALQUIER CAMBIO A REALIZAR        "
printf %80s |tr " " "="
echo ""
printf %80s |tr " " "="
echo ""
echo "                         ESTE EQUIPO TIENE INSTALADO                         "
echo "                                                                             "
echo "TIPO DE S.O.: <"`uname -o`">                                                 "
echo "NOMBRE / VERSIÓN DEL S.O.: &lt;"$NOMBRE_SISTEMA"&gt; / &lt;"$VERSION_SISTEMA"&gt;        "
echo "KERNEL / ARQUITECTURA: <"`uname -r`"> / <"`uname -m`">                       "
echo "INFO DEL CPU: ("$FABRICANTE_CPU") / ("$MODELO_CPU") / ("$NUM_CPU") / ("$NUCLEO_CPU") / ("$CACHE_CPU")"
printf %80s |tr " " "="
echo ""
echo ""

PS1="\[\e[33;1m\]┌─( \[\e[34;1m\]\u@\h\[\e[37;1m\] ) * * * * \d - \t * * * * { \[\e[31;1m\]\w\[\e[33;1m\] }\n└──┤ \[\e[32m\]# "

`

Hipanga Tuarua: Whakatikahia te pakiaka .bashrc

Ano hoki me te etita kua oti te whakamahi te whakatika i te .bashrc konae Tuhinga o mua pakiaka superuser me noho ki roto i te huarahi / pakiaka o taua mea.

Whakauruhia nga korero o ia raarangi e whai ake nei me era atu taapiri e whakaarohia ana e koe he pai ki te whakaatu ki te kaiwhakamahi i te wa e whakahaere ana i tetahi taunga kaiwhakamahi:

########################### PARÁMETROS DE MONITOREO ###########################

alias cc='clear'

PROXY=$(route -n | sed -n '3p' | awk '{print $2}')

IP_SERVIDOR_DNS=$(cat /etc/resolv.conf | sed '1 d' | grep nameserver | sed -n '1p' | awk '{print $2}')
DOMINIO=$(cat /etc/resolv.conf | sed '1 d' | grep search | sed -n '1p' | awk '{print $2}')

DATA_USUARIO1=$(du -sh /home/ | sort -r | awk '{print $1}')
DATA_ROOT=$(du -sh /root | awk '{print $1}')
DATA_VAR=$(du -sh /var | awk '{print $1}')

MEM_TOTAL=$(free -h | sed '1 d' | grep Mem: | awk '{print $2}')
MEM_USADA=$(free -h | sed '1 d' | grep Mem: | awk '{print $3}')
MEM_LIBRE=$(free -h | sed '1 d' | grep Mem: | awk '{print $4}')
MEM_COMPARTIDA=$(free -h | sed '1 d' | grep Mem: | awk '{print $5}')
MEM_ALMACENADA=$(free -h | sed '1 d' | grep Mem: | awk '{print $6}')
MEM_CACHEADA=$(free -h | sed '1 d' | grep Mem: | awk '{print $7}')

PART1_TOTAL=$(df -h | sed '1 d' | grep disk | awk '{print $2}')
PART1_USADO=$(df -h | sed '1 d' | grep disk | awk '{print $3}')
PART1_DISPONIBLE=$(df -h | sed '1 d' | grep disk | awk '{print $4}')
PART1_PORCENTAJE=$(df -h | sed '1 d' | grep disk | awk '{print $5}')
PART1_PUNTOMONTAJE=$(df -h | sed '1 d' | grep disk | awk '{print $6}')

CARGA_1MIN=$(top -n 1 -b | grep "load average:" | awk '{print $12}' | sed 's/,//2')

CARGA_5MIN=$(top -n 1 -b | grep "load average:" | awk '{print $13}' | sed 's/,//2')
CARGA_15MIN=$(top -n 1 -b | grep "load average:" | awk '{print $14}' | sed 's/,//2')

USER_ONLINE=$(top -n 1 -b | grep "load average:" | awk '{print $8}')
PROC_ZOMBIE=$(top -n 1 -b | grep "zombie" | awk '{print $10}')

TIEMPO_ENCENDIDO=$(uptime | awk '{print $3,$4}' | cut -f1 -d,)

FABRICANTE_CPU=$(grep "vendor_id" /proc/cpuinfo | sed q | awk '{print $3}')
MODELO_CPU=$(grep "model name" /proc/cpuinfo | sed q | cut -d ":" -f 2 | awk '{print $0}')
NUM_CPU=$(grep "processor" /proc/cpuinfo | sort -r | sed q | awk '{print $3}' | echo `expr $NUM_CPU + 1`)
NUCLEO_CPU=$(grep "cpu cores" /proc/cpuinfo | sed q | awk '{print $4}')
CACHE_CPU=$(grep "cache size" /proc/cpuinfo | sed q | cut -d ":" -f 2 | awk '{print $0}')

IP_ETH0=$(ifconfig eth0 | grep inet | grep -v inet6 | cut -d ":" -f 2 | cut -d " " -f 1)
MAC_ETH0=$(ifconfig eth0 | sed -n '1p' | awk '{print $5}')

###############################################################################

if ping -c 1 8.8.8.8 &amp;&gt; /dev/null; then CONEXION_INTERNET=Habilitado; else CONEXION_INTERNET=Deshabilitado; fi

set -o vi

printf %80s |tr " " "="
echo ""
echo "      ADVERTENCIA - USTED HA INICIADO SESIÓN EN EL EQUIPO SERVIDOR DE LA      "
echo "                             EMPRESA INSTITUCIÓN XYZ                                "
echo "       RECUERDE TENER EXTREMO CUIDADO CON CUALQUIER CAMBIO A REALIZAR        "
printf %80s |tr " " "="
echo ""
printf %80s |tr " " "="
echo ""
echo "                    PARÁMETROS ACTUALES DE FUNCIONAMIENTO                    "
echo "                                                                             "
echo "MEMORIA TOTAL: ("$MEM_TOTAL") - MEMORIA USADA: ("$MEM_USADA") - MEMORIA LIBRE: ("$MEM_LIBRE")"
echo "DISCO PRINCIPAL: ("$PART1_TOTAL") - ESPACIO USADO: ("$PART1_USADO") - ESPACIO LIBRE: ("$PART1_DISPONIBLE") - %: ("$PART1_PORCENTAJE") - PARTICION: ("$PART1_PUNTOMONTAJE")"
echo "CARGA PROMEDIO DEL SISTEMA: 1 MIN ("$CARGA_1MIN") -  5 MIN ("$CARGA_5MIN") - 15 MIN ("$CARGA_15MIN")"
echo "USUARIOS CONECTADOS: ("$USER_ONLINE") -  PROCESOS ZOMBIES: ("$PROC_ZOMBIE")"
echo "TIEMPO ARRANQUE/ENCENDIDO: ("$TIEMPO_ENCENDIDO")                             "
echo "ESPACIO USADO: /home = ("$DATA_USUARIO1") /root = ("$DATA_ROOT") /var = ("$DATA_VAR")"
printf %80s |tr " " "="
echo ""
echo ""
PS1="\[\e[33;1m\]┌─( \[\e[34;1m\]\u@\h\[\e[37;1m\] ) * * * * \d - \t * * * * { \[\e[31;1m\]\w\[\e[33;1m\] }\n└──┤ \[\e[32m\]$ "

 

Taahiraa Tuatoru: Whakatikahia te pakiaka .bashrc

Whakauru atu me te taunga. Me tiimata ano ka wheako i nga panoni. Kia rite te ahua ki tenei e whakaaturia ana i raro ake nei, i nga whakaahua e whai ake nei:

Hipanga 1: Whakaoho TerminalHipanga 2: Whakatika kaiwhakamahi .bashrcHipanga 3: Kua whakauruhia te ihirangi ki te kaiwhakamahi .bashrcHipanga 4: Whakauru pakiakaHipanga 5: Whakauru pakiakaHipanga 6: Whakatikaia te konae .bashrc pakiakaHipanga 7: Whakatikaia te konae .bashrc pakiakaHipanga 8: Whakatikaia te konae .bashrc pakiakaHipanga 9: He tauira whakaatu mo te Kaiwhakamahi KaiwhakamahiHipanga 10: He tauira whakaatu mo te Kaiwhakamahi KaiwhakamahiHipanga 11: He tauira whakaatu mo te Kaiwhakamahi Kaiwhakamahi

Hipanga Tuawh (he kowhiringa): Te Whakakapi i nga Ingoa

Kia maumahara ko te whakamahinga o nga ingoa ingoa i roto i nga .bashrc Ka taea hoki te whakaora i a koe i te wa tuhituhi. Whakakahoretia nga mea ka haere mai noa i roto i te .bashrc, penei i te:

alias ls='ls $LS_OPTIONS'
<strong>alias ll='ls $LS_OPTIONS -l'
<strong>alias l='ls $LS_OPTIONS -lA'

alias rm='rm -i'

Ka taapirihia nga mea e whakaarohia ana e koe he tika, na te mea he whakahau tonu ta raatau, penei i te:

alias cc='clear'

He mea nui kia mohio ake ma te ake-akoako i a ia ano taurangi, ingoakapa, te .bashrc me te reo anga bash mo te taumata angitu o te taunga. He rite ano mo te tiimata i nga waahanga mamao ma te ssh, ka kitea i etahi atu panui ka whai ake.

Ko te tumanako ko enei tamariki nohinohi "Tohu Awhina" whakangawari atu ki a raatau ki te mahi i nga waahanga pai engari tino pai rawa atu, ko te nuinga ka rahuitia ma nga tohunga anake Hangarau, rorohiko, Rorohiko Koreutu me te GNU / Linux.

Whakamaumahara: Mena kaore e taea e tetahi raina whakahau te whakamahi te whakaatu ranei i te uara tika, kia mahara ki te whakamatautau a ringa i ia waahanga o te whakahau whakahau kia ngana ki te whakatika i nga uara, ki te wetewete ranei o etahi taurangi.


Ko nga korero o te tuhinga e piri ana ki o maatau kaupapa o matatika whakatika. Ki te ripoata i tetahi paatene paato Here.

9 korero, waiho maau

Waiho to korero

Ka kore e whakaputaina tō wāhitau īmēra.

*

*

  1. He kawenga mo nga raraunga: Miguel Ángel Gatón
  2. Te kaupapa o te raraunga: Whakahaerehia te SPAM, te whakahaere korero.
  3. Ture: To whakaae
  4. Whakawhitinga korero: Kaore nga korero e tukuna ki nga taha tuatoru engari ma te ture herenga.
  5. Rokiroki raraunga: Paetukutuku e whakahaerehia ana e Occentus Networks (EU)
  6. Tika: I nga wa katoa ka taea e koe te whakaiti, te whakaora me te muku i o korero.

  1.   yippekay ka mea

    Ko nga ingoakapi te mea pai. Kaore au e whakaaro kino mo etahi ka whakauru taunoa i te bashrc: la (ls -a) me te ll (ls -l). I te whakamutunga ka taapirihia e au te tohu -h.

    Othertahi atu ingoakē whai kiko:
    s = 'sudo'
    cd1 = 'cd ..'
    cd2 = 'cd ../ ..'
    rmd = 'rm -r' (Ka whakamahia e au ki te tango i nga whaiaronga me nga konae)
    whakaweto = 'sudo katinga -h inaianei'
    del = 'putunga-maka' (nukuhia nga konae ki te paru, whakahau i te putunga putu-para)

  2.   reo ka mea

    Mai i taku kitenga i tenei ingoakore i tera tau i runga i Reddit ko taku tino pai tena:
    Fuck whakaingoa = 'sudo $ (hitori -p !!)'

  3.   Martin ka mea

    Ko te tuhinga me nga ahuatanga e hoatu ana ki te papatohu he tino pai. Contributionstahi takoha:
    - I Ubuntu ka taea nga ingoa ingoa ke ki roto i tetahi konae motuhake (.bash_aliases) i nga toenga o nga tohatoha kaore au i te mohio engari ma te taapiri i nga raina e whai ake nei ki te .bashrc:
    mena [-f ~ / .bash_aliases]; ka
    . ~ / .bash_aliases
    fi
    Ma tenei ka pai ake te tono o nga ingoa ingoa ingoa me nga mea wareware penei i ahau ka taea e koe te taapiri i tenei ingoakapi e whakaatu ana i te konae e whakararangi ana i nga ingoa ingoa.
    alias lsalias = 'more ~ ​​/ .bash_aliases'
    - He ruarua te whakamahi i te konae tuhinga tuhi (kaore au i te maumahara) i karangahia ko te command_utiles.txt me te rite me nga ingoa ingoa e whai ake nei: alias cutil = 'more ~ ​​/ command_utiles.txt'
    - He maha atu o nga ingoa ingoa ka whakamahia e au:
    alias cdu = 'cd ~'
    alias lof = 'ls -lSr | atu' # Whakaatu ai i nga konae me te taipitopito i whakaritehia e te rahi
    alias lod = 'du -sk * | kōmaka -rn '# Whakaatuhia nga raarangi whai i te rahi
    alias deo = 'du -sh' # Whakatauhia te mokowā e nohoia ana e te dir
    alias psa = 'ps -eafw | atu '# Whakaatuhia nga mahinga katoa me te maha atu
    alias psg = 'ps -eafw | grep '# Whakaatuhia te mahinga kua tohua
    - Hei whakamutunga, he rereke mo nga kaiwhakamahi i mahia e au:
    SYSTEM_NAME = $ (cat / etc / os-release | grep NAME | grep -v "VERSION" | sed -n '1p' | tapahia -f2 -d \ »)
    SYSTEM_VERSION = $ (ngeru / etc / os-tuku | grep VERSION = | sed -n '1p' | sed 's / VERSION = //' | sed 's / »// g')
    MANUFACTURER_CPU = $ (grep "vendor_id" / proc / cpuinfo | sed q | awk '{tā $ 3}')
    CPU_MODEL = $ (grep "ingoa tauira" / proc / cpuinfo | sed q | cut -d ":" -f 2 | awk '{tā $ 0}')
    NUM_CPU = $ (grep "pūtukatuka" / proc / cpuinfo | momo -r | sed q | awk '{tā $ 3}' | oro expr $NUM_CPU + 1)
    NUCLEO_CPU = $ (grep "cpu cores" / proc / cpuinfo | sed q | awk '{tā $ 4}')
    CACHE_CPU = $ (grep "cache size" / proc / cpuinfo | sed q | cut -d ":" -f 2 | awk '{tā $ 0}')
    USER_DATA = $ (du -sh ~ | momo -r | awk '{tā $ 1}')

    mārama
    printf% 130s | tr »» «=»
    maka atu ""
    hamama «DATE:«date +%c --date='+1 year'
    oro «KERNEL:«uname -o»<«uname -r«> <«uname -m«>»
    oro "DISTRIBUTION:" $ SYSTEM_NAME "" $ SYSTEM_VERSION ""
    echo "CPU:" $ MODEL_CPU "," $ NUCLEO_CPU "Nuclei," $ CACHE_CPU "Keteroki"
    oro «WĀI MAHI:« $ DATA_USUARIO
    printf% 130s | tr »» «=»
    maka atu ""
    ##########################
    echo "NGA MAHI MAHI:"
    oro »- Whakauruhia te RPM ki te punaha paapato DEB: alien -c-package.rpm»
    oro »- Hurihia te kaiwhakamahi me te roopu o nga konae whakaheke: chown -hR kaiwhakamahi: roopu [konae, dir]
    echo »- Tuhia te pupuri i nga mana whakaaetanga: te takenga mai o te puna -ax»
    oro »- Whakaatuhia nga putunga kaha: grep -i ppa.launchpad.net /etc/apt/source.list.d/*.list»
    oro »- Taapirihia he putunga: apt-add-repository ppa: repository»
    echo »- KI TE KATOA ATU O NGA KAUTOHU Cutil»
    echo »- KI TE WHAKAMAHI I NGĀ ALIAS»
    printf% 130s | tr »» «=»
    maka atu ""
    maka atu ""
    # PS1 = »[\ e [33; 1m] ┌─ ([\ e [34; 1m] \ u @ \ h [\ e [37; 1m]) * * * * \ d - \ t * * * * {[\ e [31; 1m] \ w [\ e [33; 1m]} \ n└──┤ [\ e [32m] # »
    PS1=»[\e[33;1m]┌─([\e[34;1m]\u@\h[\e[37;1m])>{ [\e[31;1m]\w[\e[33;1m] }\n└──┤ [\e[32m]# «

    1.    abaddon s ka mea

      he aha te mea pai kaore i te tuhi i to ake tuhinga?

  4.   abaddon s ka mea

    ANEI KO NGA MAHI E TANGI ANA AKU !!!!!!!!!

  5.   Ingarangi Jose Albert ka mea

    Ana, he tino koa ahau mo to pai ki a koe me to mahi!

    Apopo kei te tumanako ahau ki te whakaputa i tetahi atu tuhinga! Nga pari.

  6.   kikorangi-kaiwhakamahi ka mea

    Tena koutou me te mihi mutunga kore mo te tohatoha i aua korero.
    Kaore au i te tino mohio mo te whakahaere i te GNU / Linux (He kaiwhakamahi awhina me te hiahia noa ahau kaore he whakangungu matauranga), engari kei te maumahara ahau ki te panui i runga i etahi paetukutuku mo nga raru haumarutanga me te whakanekehanga o te mana motuhake etahi ota me nga putorino i roto i te tuhinga .bashrc, ki taku titiro ka taea e ia te whakahaere i tetahi mahi a te kaimaki, te poka ranei.
    Ma te whakaute me te tino mihi.

  7.   Ingarangi Jose Albert ka mea

    Ma te Huri Panui e pai ake ai te taunga he maamaa, tirohia te tawhiti ka taea e koe ma te mahi i te Huringa Hika Pai.

    LPI-SB8 Whakamatau WhakamaataMata (LINUX POST INSTALL - SCRIPT BICENTENARIO 8.0.0)
    (lpi_sb8_adaptation-audiovisual_2016.sh / 43Kb)

    Tirohia te Matapihi: https://www.youtube.com/watch?v=cWpVQcbgCyY

  8.   Lea ka mea

    Akoranga pai! He pukapuka ka taunakitia e koe i runga i te linux ki te ako pai i te tuhinga anga anga, nga whirihoranga, te ahuru o te kaituku? Mauruuru