Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 12

Taller 7: Comandos en consola en Zimbra

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

7.1.- Zimbra CLI Commands


=======================================================================
=========================================
CLI Description
-------------------- ------------------------------------------------------------
ldap Start, stop, or find the status of zimbra LDAP

ldapsearch Perform a search on an LDAP server

logmysqladmin Send myslqadmin commands to the logger mysql

mailboxd Start, stop, find the status of the mailboxd server

mysql Enters interactive command-line MySQL session with the mailbox mysql

mysql.server Start, stop the SQL instance for the mailboxpackage

mysqladmin Send admin commands to MySQL

postconf Postfix command to view or modify the postfixconfiguration

postfix Start, stop, reload, flush, check, upgrade-configuration of postfix

qshape Examine postfix queue in relation to time andsender/recipient domain

zmaccts Lists the accounts and gives the status ofaccounts on the domain

zmamavisdctl Start, stop, restart, or find the status of theAmavis-D New

zmantispamctl Start, stop, reload, status for anti-spam service

zmantivirusctl Start, stop, reload, status for the anti-virus service

zmapachectl Start, stop, reload, or check status of Apacheservice (for spell check)

zmarchive Config Command to view, modify, or configure archiving

zmarchivectl Start, stop, reload, status for archiving

zmarchivesearch Search archives on the account

zmauditswatchctl Start, stop, restart, reload, status of theauditswatch

zmbackup Performs full backups and incremental backupsfor a designated mail host.

zmbackupabort Stops a backup that is in process.

zmbackupquery Find a specific full backup set


zmblobchk Check consistency of the Zimbra blob store

zmcalchk Check consistency of appointments andattendees in the Zimbracalendar

zmcertmgr Manage self-signed and commercial certificates

zmclamdctl Start, stop, or find the status of Clam AV

zmcleaniplanetics Clean iPlanet ICS calendar files

zmcontrol (Start/Stop Service) Start, stop, status of the Zimbra servers. Also can use
to find the Zimbra version installed.

zmconvertctl Start, stop, the conversion server or find thestatus of the converted
attachments conversion/indexing

zmdumpenv General information about the serverenvironment is displayed

zmgsautil Create, delete the GAL sync account and initiate manual syncs.

zmhostname Find the hostname of the Zimbra server

zmhsm Start, stop and status of a HSM session.

zmitemdatafile Extracts and packs tgz files that ZCS uses forREST import/export

zmjava Execute Java with Zimbra-specific environmentsettings

zmldappasswd Changes the LDAP password

zmlicense View and install your Zimbra license

zmlmtpinject Testing tool

zmlocalconfig Used to set or get the local configuration of a Zimbra server

zmloggerctl Start, stop, reload, or find the status of the Zimbra logger service

zmloggerhostmap Used to manually map a DNS hostname to azmhostname.

zmlogswatchctl Start, stop, status of the swatch that is monitoring logging

zmmailbox Performs mailbox management tasks

zmmailboxdctl Start, stop, reload, or find the status of themailbox components


(mailboxd, MySQL, convert)

zmmailboxmove (Move Mailbox) Used to move selected mailboxes from one Zimbra
server to another.
zmmboxsearch (Cross Mailbox Search) Search across mailboxes to find messages
andattachments

zmmetadump Support tool that dumps an items metadata in ahuman-readable form

zmmtaconfigctl Start, stop, or find the status of the MTAconfiguration daemon

zmmtactl Start, stop, or find the status of the MTA

zmmypasswd Trace messages

zmmypasswd Change MySQL passwords

zmmysqlstatus Status of mailbox SQL instance

zmperditionctl Start, stop, or find the status of the perdition IMAP proxy

zmplayredo Performs data restore using backed upsnapshots taken periodically. Users
who use snapshots to backup and
restore their information from a standby site use this command.

zmprov (Provisioning) Performs all provisioning tasks in Zimbra LDAP, including


creating accounts, domains,
distribution lists and aliases

zmproxyconfgen Generates configuration for the nginx proxy

zmproxyctl Start, stop, restart, and find the status of the IMAP proxy service

zmproxypurge Purges POP/IMAP routing information from oneor more memcached


servers

zmpython Ability to write Python scripts that access Zimbra Java libraries. It sets the
ZCS class path and starts the Jython interpreter.

zmredodump Support tool for dumping contents of a redologfile for debugging


purposes

zmrestore Performs full restores and incremental restoresfor a designated mail host

zmrestoreldap Restore accounts from the LDAP backup

zmrestoreoffline (Offline Restore) Performs full restore when the Zimbra server (i.e., the
mailboxd process) is down

zmsaslauthdctl Start, stop, or find the status of saslauthd(authentication)

zmschedulebackup Schedule backups and add the command to your cron table

zmshutil Used for other zm scripts, do not use

zmskindeploy Deploy skins for accounts from the command line


zmsoap Print mail, account, and admin information in the SOAP format

zmspellctl Start, stop, or find the status of the spell checkserver

zmsshkeygen Generate Zimbras SSH encryption keys

zmstat-chart Generate charts from zmstat data collected in adirectory

zmstat-chart-config Generate an .xml file with data included from the account setup

zmstat-chart-config Outputs an XML configuration that describes the current state of the
data gathered from zmstat-chart to generate charts on the

administration console

zmstatctl Start, stop, check status, or rotate logs of zmstat data collectors

zmstorectl Start, stop, or find the status of Zimbra storeservices

zmswatchctl Start, stop, or find the status of the Swatchprocess, which is used in
monitoring

zmsyslogsetup Used to setup system log config file

zmthrdump Initiate a thread dump and save the data to a filewith a timestamp

zmtlsctl Set the Web server mode to the communication protocol options: HTTP,
HTTPS or mixed

zmtrainsa Used to train the anti-spam filter to recognizewhat is spam or ham

zmtzupdate Provides mechanism to process timezonechanges from the command line

zmupdateauthkeys Used to fetch the ssh encryption keys created by zmsshkeygen

zmvolume Manage storage volumes on your Zimbra Mailbox server

zmzimletctl Deploy and configure Zimlets

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

Comandos de Servicio
=======================================================================
===================================
$> su - zimbra

verificar el estado de todos los servicios en zimbra


$> zmcontrol status

detener todos los servicios


$> zmcontrol stop

iniciar todos los servicios


$> zmcontrol start

reiniciar todos los servicios


$> zmcontrol restart

Ver la versin de zimbra y el parche actual


$> zmcontrol -v

7.2.- Comandos individuales de servicio (start, stop, restart, status)


##########################################################################
Ej: detenemos todos los servicios e iniciaremos uno a uno

$> zmcontrol stop

$> zmcontrol status

Iniciar LDAP server


$> ldap start

$> zmcontrol status

Iniciar MySQL Server


$> mysql.server start

Iniciar zmconfigd
$> zmconfigdctl start

Iniciar MTA (postfix, saslauthd)


$> zmmtactl start

Iniciar Amavis, Antivirus y AntiSpam (amavis, spamassassin, clamav)


$> zmamavisdctl start

$> zmcontrol status

Iniciar Mailbox (webmail, panel de administracion, servidores imap y pop3, servidores de filtros)
$> zmmailboxdctl start

Iniciar spell (servidor de ortografa)


$> zmapachectl start

Iniciar monitoreo
$> zmswatchctl start

Iniciar estadsticas
$> zmstatctl start

Iniciar Logger (logs del sistema)


$> zmlogswatchctl start

Reiniciar servicio antivirus


$> zmantivirusctl restart

Reiniciar servicio antispam


$> zmantispamctl restart

Iniciar servicio de memcache


$> zmmemcachedctl start

Iniciar servicio dkim


$> zmopendkimctl start

Iniciar proxy
#> zmproxyctl start

Ver el estado de los servicios


$> zmcontrol status

7.3.- Comandos de la consola de administracin


######################################################################3
zmcontrol
zmprov
zmlocalconfig

7.3.1.- zmcontrol
#######################################################################
Detener zimbra
$> zmcontrol stop

Iniciar zimbra
$> zmcontrol start

Reiniciar zimbra
$> zmcontrol restart

Ver el estado de los servicios


$> zmcontrol status

Ver la versin de zimbra y su parche instalado


$> zmcontrol -v

7.3.2.- zmprov: comando de administracin de zimbra


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

Loguearse primero como usuario zimbra


$> su - zimbra

Lista la ayuda general de zmprov


$> zmprov help
Listar la ayuda para gestionar las cuentas
$> zmprov help account

Consola Interactiva
$> zmprov
prov>

Ver ayuda de cuentas


prov> help account

Salir de la consola interactiva


prov> quit

7.3.2.1.- Cuentas
############################################

Obtener listado de todas las cuentas del servidor (todos los dominios)
$> zmprov -l gaa

Obtener todas las cuentas de administracin


$> zmprov -l gaaa

Obtener informacin de una sola cuenta


$> zmprov -l ga tuxito@dominio.com

Cuentas de un dominio especfico


$> zmprov -l gaa dominio.com

Detalle de cuentas de un dominio especifico


$> zmprov -l gaa -v dominio.com

Detalle de cuentas de un dominio especifico con Cuenta, Nombre y Quota


$> zmprov -l gaa -v dominio0.com | grep -e zimbraMailDeliveryAddress -e displayName -e
zimbraMailQuota |sed -e "s/zimbraMailDeliveryAddress/Cuenta/" -e "s/displayName/Nombre/" -e
"s/zimbraMailQuota/Quota/"

Crear una cuenta, con cos default


$> zmprov ca pepito@dominio.com Pepito1. displayName "Pepito Perez"

Crear un usuario con un cos especfico ej: gerente


$> cos=`zmprov gc gerente | grep zimbraId:|cut -d ' ' -f2`
$> zmprov ca juanito@dominio.com Juanito1. displayName "Juanito Martinez" zimbraCOSId $cos

Crear una cuenta con detalle


$> zmprov ca windozero@dominio.com Windozero1. cn 'Windozero Luser' displayName
'Windozero Luser' zimbraCOSId $cos

Esto crear una cuenta de administrador adicional con la contrasea de 'test123':


$> zmprov ca testadmin@domain.com test123 zimbraIsAdminAccount TRUE

Esto transformar una cuenta de usuario normal en una cuenta de administrador (en este ejemplo,
futur-admin se convertir en un admin):
$> zmprov ma futur-admin@domain.com zimbraIsAdminAccount TRUE

7.3.2.2.- Modificar opciones de una cuenta


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

Cambiar de password de una cuenta


$> zmprov sp usuario1@dominio.com passnuevo

Modificar un atributo de una cuenta


$> zmprov ma usuario1@dominio.com displayName "Luser Noob 1"

Nota: se puede modificar cualquier atributo del usuario


para la lista de atributos ejecutar
$> zmprov -l ga usuario1@dominio.com

7.3.2.3.- Busqueda de cuentas


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

* Bsqueda por atributos


Se puede buscar las cuentas por un atributo en comn
zmprov sa parametro=cadena

Buscar todas las cuentas activas


$> zmprov sa zimbraAccountStatus=active

Buscar todas las cuentas bloqueadas


$> zmprov sa zimbraAccountStatus=locked

Buscar en cuales listas se encuentra una cuenta


$> zmprov gam cuenta@dominio.com

Buscar todos las cuentas que estn de vacaciones


$> zmprov -l gaa -v ofipymes.com |grep -e zimbraMailDeliveryAddress -e displayName -e
zimbraPrefOutOfOfficeUntilDate |grep zimbraPrefOutOfOfficeUntilDate -B 2

7.3.2.4.- Borrar una cuenta


##########################################################
$> zmprov da usuario3@dominio.com

7.3.2.5.- Creacin de Cuentas en forma masiva


################################################################################
######################
Nos logueamos como root
$> su -

Creamos nuestro directorio de scrips


$> mkdir /opt/zimbra/scripts
Entramos al directorio
$> cd /opt/zimbra/scripts

Primero creamos un archivo con la lista de cuentas y sus respectivos cos


$> vim usuarios.txt
--------------------------------------------
usuario1@dominio.com,Usuario1.,Usuario Prueba 1,default
usuario2@dominio.com,Usuario2.,Usuario Prueba 2,default
usuario3@dominio.com,Usuario3.,Usuario Prueba 3,gerente
--------------------------------------------

Creamos ahora un script que genere un archivo para la creacin de usuario


$> vim crea_usuarios.php
---------------------------------------------------------------
#!/usr/bin/php

<?php

// Obteniendo los COS del sistema y sus Ids


exec("/opt/zimbra/bin/zmprov gac",$arrcos);
$cos = array();
foreach($arrcos as $cos_name){
$cos_name = chop ($cos_name);
$cosid=`/opt/zimbra/bin/zmprov gc $cos_name | grep ^zimbraId:`;
$cosid = trim(str_replace("zimbraId: ","",$cosid));
$cos[$cos_name]=$cosid;
}

//print_r($cos);
// Leyendo los archivos de Usuarios
$userfile=file("usuarios.txt");
// Recorriendo array de usuarios y creando las cuentas
foreach($userfile as $userline){
$userline=trim(chop($userline));
if(!empty($userline)){
$user = explode(",",$userline);
echo("ca $user[0] $user[1] displayName '$user[2]' zimbraCOSId ".$cos[$user[3]]."\n");
}
}
?>

---------------------------------------------------------------

Ejecutamos el script, para eso necesitamos php


$> yum -y install php56w-cli
$> chmod 755 crea_usuarios.php
$> ./crea_usuarios.php> cuentas.zm

Creamos los usuarios con zmprov


$> /opt/zimbra/bin/zmprov < cuentas.zm
7.3.2.6.- Listas de correo
###############################################################
Buscar todas las listas, y por dominio

$> zmprov gadl

$> zmprov gadl dominio.com

Crear una lista


$> zmprov cdl lista@dominio.com

Ver una lista especfica


$> zmprov gdl lista@dominio.com

Encontrar todas las listas de un dominio y sus miembros


$> for i in $( zmprov gadl dominio0.com | grep -v abuse | grep -v postmaster | sort ) ; do echo
`zmprov gdl $i | grep -e 'mail: ' -e 'zimbraMailForwardingAddress: ' | sed 's/mail/Lista/' | sed
's/zimbraMailForwardingAddress: //'` ; done ;

agregar un miembro a la lista


$> zmprov adlm lista@dominio.com cuenta@dominio.com

Remover un miembro de la lista


$> zmprov rdlm lista@dominio.com cuenta@dominio.com

Borrar una lista


$ zmprov ddl lista@dominio.com

7.3.3.- Obtener y modificar valores de configuracion


#########################################################################
Ver los valores de configuracin del servidor
$> zmlocalconfig

Ver los valores de configuracin mostrando los password


$> zmlocalconfig -s

Mostrar el password de mysql


$> zmlocalconfig -s | grep mysql_root_password

Mostrar el password de ldap


$> zmlocalconfig -s | grep zimbra_ldap_password

Obtener todos los parmetros de configuracin generales


$> zmprov gacf | less

Modificar un valor global de configuracin


$> zmprov mcf zimbraMtaMaxMessageSize 20240000

Obtener los parmetros de configuracin de un servidor


$> zmprov gs `zmhostname` | less
Modificar el valor de configuracin de un servidor
$> zmprov ms `zmhostname` zimbraImapNumThreads 1000

Siempre que se modifica un valor de zimbra hacer un restart del servidor o del servicio
afectado

7.4.- Buzones (zmmailbox)


##################################################################
Entrar a la consola interactiva
$> zmmailbox
mbox>

Ver ayuda general del comando


$> zmmailbox help

Ver ayuda de las cuentas


$> zmmailbox help account

Ver ayuda de los mensajes


$> zmmailbox help message

7.4.1.- Tamao de un buzn


######################################################################
Ver tamao ocupado del buzn
$> zmmailbox -z -m cuenta@dominio.com gms

Ver el tamao de las quotas asignadas y ocupadas de todos los buzones


$> zmprov gqu `zmhostname`|awk {'print " "$3" "$2" "$1'}

Revisar mensajes por carpetas en el buzn


$> zmmailbox -z -m cuenta@dominio.com gaf

Borrar una carpeta completa de un buzn


$> zmmailbox -z -m cuenta@dominio.com emptyFolder Junk

Importar mensajes de una carpeta Maildir existente en el INBOX


$> echo addMessage /INBOX /path/to/Maildir/cur | /opt/zimbra/bin/zmmailbox -z -m
cuenta@dominio.com

Buscar un mensaje
$> zmmailbox -z -m cuenta@dominio.com search -t message "prueba"

Buscar un mensaje en todas las cuentas


$> zmprov -l gaa |awk '{print "zmmailbox -z -m "$1" search \"linux\" "}' |sh -v
linux es la palabra de bsqueda

Buscar correos anteriores a una fecha: (formato mes/dia/ao)


$> zmmailbox -z -m cuenta@dominio.com search -t message "in:INBOX (before: 07/28/13)"
Obtener contenido de un correo
$> zmmailbox -z -m cuenta@dominio.com gm 21940
21940 es el ID del mensaje

Ver contactos:
$> zmmailbox -z -m cuenta@dominio.com gact | less

Vaciar casilla usuario:


$> zmmailbox -z -m accoun@domain.com ef "/Inbox"

Ver correos de una carpeta


$> zmmailbox -z -m cuenta@dominio.com search -l 100 "in:Inbox"

Ver metadata de un correo:


$> zmmetadump -m cuenta@dominio.com -i 26747

Borrar un mensaje
$> zmmailbox -z -m cuenta@dominio.com dm 4543
4543 es el id del mensaje

Borrar un mensaje en todas las cuentas (tarea)

You might also like