Published by carla on 04 Mar 2008

Solaris - Como checar pacotes pacialmente instalados

Para checar se há pacotes parcialmente instalados, você deve executar o comando pkginfo com a opção “-p”.

O sistema irá mostrar os pacotes parcialmente instalados. Caso a saída do comando não retorne nada é porque a instalação de todos os seus pacotes está ok.

#pkginfo -p

English version:

Solaris - How to check partially installed packages

To check if a Solaris package is partially installed, you should run the command pkginfo, with the option “-p”.

The system will show only the packages that are partially installed. If there is no partially installed package, nothing will be showed.

#pkginfo -p

Published by carla on 22 Feb 2008

Como criar um arquivo de um tamanho específico

Abaixo, seguem os comandos utilizados em AIX e Solaris para criar um arquivo de um tamanho específico. A criação de um arquivo com um determinado tamanho é útil para algumas coisas como:

  • criar-se arquivos para testes, por exemplo, para transferir o arquivo via rede e avaliar a taxa de transferência da rede.
  • criar arquivos para serem usados como swap no Solaris.
  • etc.

AIX:

Comando lmktemp:

# /usr/sbin/lmktemp <nome do arquivo> <tamanho>

Exemplo:

# /usr/sbin/lmktemp teste.txt 100m

Solaris:

Comando mkfile:

# mkfile <tamanho> <nome do arquivo>

Exemplo:

# mkfile 100m teste.txt

Nos dois exemplos acima, um arquivo chamado teste.txt é criado com 100 MB.

Referência:

http://www.coolcommands.com/index.php?option=com_cccat&task=display&id=154

http://docs.sun.com/app/docs/doc/819-2240/6n4htdnct?l=en&a=view&q=mkfile

Published by carla on 24 Dec 2007

Processos do sistema operacional Linux

Abaixo, segue uma relação dos processos encontrados no sistema operacional Linux com suas respectivas descrições.

O processo como o encontramos no sistema operacional está destacado em negrito e abaixo segue sua descrição. Cada processo está separado por uma linha e para cada um, está indicada a referência bibliográfica.

A descrição dos encontra-se em duas línguas, português e inglês.

Follow, we have the list of linux process.

The name of the process is in bold characters and follow we have the description. Each process is separated for one line and the bibliographic reference is indicated as well.

The description for linux process you can find in portuguese and english.

———————————————————————————-
/usr/bin/gdm-binary

GDM – Gerenciamento de Display do GNOME, um programa de login gráfico.

GDM - The GNOME Display Manager, a graphical login program.

Referência:
http://www.gnome.org/projects/gdm/

———————————————————————————-

/sbin/mingetty

O mingetty é o programa que permite login em modo texto no servidor. Ele são reinicializados automaticamente pelo init, caso caiam.

“mingetty is a minimal getty for use on virtual consoles”

“mingetty is designed to be a minimal getty for the virtual terminals on the the workstation’s monitor and keyboard.”

Referência:
http://linux.about.com/library/cmd/blcmdl8_mingetty.htm
http://tldp.org/HOWTO/Remote-Serial-Console-HOWTO/getty-mingetty.html

———————————————————————————-

/usr/bin/gdmgreeter

Ambiente gráfico de login.

“# Greeter for local (non-xdmcp) logins. Change gdmlogin to gdmgreeter to
# get the new graphical greeter.”

Referência:
http://www.linux.org/docs/ldp/howto/XFree-Local-multi-user-HOWTO/examples_dm.html

———————————————————————————-

/usr/sbin/acpid

ACPID é um daemon complemamente flexível, totalmente extensível para entrega de eventos ACPI. Ele “escuta” um arquivo (/proc/acpi/event) e quando um evento ocorre, ele executa programas para tratar o evento. Os programas que ele executa, são configurados através de um conjunto de arquivos de configuração, que podem ser disponibilizados por pacotes ou pelo adminitrador.

ACPID is a completely flexible, totally extensible daemon for delivering ACPI events. It listens on a file (/proc/acpi/event) and when an event occurs, executes programs to handle the event. The programs it executes are configured through a set of configuration files, which can be dropped into place by packages or by the admin.

Referência:
http://acpid.sourceforge.net

ACPI coloca o Sistena Operacional no controle da configuração do sistema e gerenamento de força. Além disso, ele age como uma camada de abstração de hardware entre o sistema operacional e a plataforma BIOS — permitindo ao Sistema Operacional e a plataforma evoluirem independentemente. Veja a seção de documentação para mais informações.

ACPI puts the OS in control of system configuration and power management.
Further, it acts as a hardware abstraction layer between the OS and the platform BIOS — allowing the OS and the platform to evolve independently. See the Documentation section for further information.

Referência:
http://acpi.sourceforge.net/

———————————————————————————-

/usr/sbin/atd

O atd é um servidor que executa comandos especificados em um determinado horário fornecido. Ele é muito similar ao crond, mas está limitado a uma única execução: o comando é executado em horário e datas fornecidas, mas não repetidas vezes como o cron.

Referência:
http://www.linorg.cirp.usp.br/Guias.Conectiva/Guias_V.7.0/Entendendo_O_Conectiva_Linux/sec-atd.html

———————————————————————————-

/usr/sbin/sshd

Daemon para conexao SSH

SSH connection daemon.

Referência:
http://linuxmafia.com/pub/os2/stahl-ssh/snafu-mirror/sshd.html
http://en.wikipedia.org/wiki/SSH

———————————————————————————-

/usr/X11R6/bin/X

Ambiente gráfico.

Graphical environment.

Referência:
http://www.firewalls.com.br/Cursos/netbsd/chap-x.html
http://www.x.org/wiki/FAQMiscellaneous

———————————————————————————-

[aio/0]
[aio/1]
[aio/2]
[aio/3]

Asynchronous Input/Output (aio) é um processo do kernel e ele permite leitura e escrita em arquivos abertos com IO direto em ext2, ext3, jfs, xfs.

Asynchronous Input/Output ( aio ) is a kernel process and It enables read and write on files opened with O_DIRECT on ext2, ext3, jfs, xfs.“

Referência:
http://www.linuxforums.org/forum/slackware-linux-help/98985-aio-0-process.html

———————————————————————————-

[ata/0]
[ata/1]
[ata/2]
[ata/3]
[ata/aux]

Acredito que estas threads do kernel esteja relacionadas ao gerenciamento de dispositivos de disco.

Não encontrei documentação referente a estes processos.

I believe that this threads are related to disk device management. But, I didn’t find any information related to them.

———————————————————————————-

[events/0]
[events/1]
[events/2]
[events/3]

No kernel 2.6, [events/num_cpu] é um mecanismo (ele substituiu o antigo keventd) para lidar com requisições low-level que precisam rodar assincronamente. Todo tipo de notificação roda através dele… Ele é muito ad hoc. Então, se você está vendo este “pegging the meter”, tudo o que ele está realmente dizendo a você é que há um loop em algum lugar.

In a 2.6 kernel, events/cpu_number is a mechanism (it replaces the old keventd) for handling low-level requests that need to run asynchronously. All sorts of notifications run through there … it’s very ad hoc. So if you’re seeing this “pegging the meter,” all it’s really telling you is that there’s a loop somewhere.”

Referência:
http://www.linuxquestions.org/questions/showthread.php?t=441837

As threads events/n (onde n é o número do processador) ajudam a implementar filas de tarefas, que são outra maneira de postergar tarefas no kernel. Se uma parte do kernel quer adiar a execução de uma tarefa, esta pode criar sua própria fila de tarefas ou fazer uso da trhread de tarefas do kernel.

The events/n threads (where n is the processor number) help implement work queues, which are another way of deferring work in the kernel. If a part of the kernel wants to defer execution of work, it can either create its own work queue or make use of the default events/ n worker thread.

Referência:
http://www.linux-mag.com/id/2195/?r=s (é necessário cadastro e login na página)

———————————————————————————-

[kacpid]

É um processo do kernel. Ele lida com a funcionalidade “power-saving” (economia de energia) e algumas outras coisas que são específicas de placas-mãe (motherboards) compatíveis com ACPI. (como monitoramento de temperatura, rpm’s do cooler (ventilador), … ) …

The thing is indeed a kernel-daemon process, it handles power-saving functionality and a few other things that are specific to ACPI compliant motherboards (like monitoring temperatures, rpm’s of fans, … ) …”

Referência:
http://www.linuxquestions.org/questions/showthread.php?t=213429

———————————————————————————-

[kauditd]

kauditd fala com o auditd.

kauditd talks to auditd.

No arquivo audit.c do kernel, encontramos:

/* As soon as there’s any sign of userspace auditd, start kauditd to talk to it */
/* As soon as there’s any sign of userspace auditd,
/* start kauditd to talk to it */

if (!kauditd_task)
kauditd_task = kthread_run(kauditd_thread, NULL, “kauditd”);
f (IS_ERR(kauditd_task)) {

Em português:

/* Assim que houver algum sinal de auditd no espaço do usuário, inicia o kauditd para conversar com ele. */

Referência:

http://www.linuxhq.com/kernel/v2.6/17/kernel/audit.c

auditd - Daemon de auditoria Linux

O auditd é um comonete do espaço do usuário1 para o sistema de auditoria Linux. Ele é resonsável por escrever registros para o disco. A visualização dos logs é feita com utilitários de pesquisa e relatório. A configuração das regras de auditoria é feita com o utilitário auditctl. Durante a inicialização, as regras em /etc/audit.rules são lidas pelo auditctl. O daemon audit por si só tem algumas opções de configuração que o administrador pode querer personalizar.
Elas são encontradas no arquivo auditd.conf.

auditd is the userspace component to the Linux Auditing System. It’s responsible for writing audit records to the disk. Viewing the logs is done with the ausearch or aureport utilities. Configuring the audit rules is done with the auditctl utility. During startup, the rules in /etc/audit.rules are read by auditctl. The audit daemon itself has some configuration options that the admin may wish to customize. They are found in the auditd.conf file

Referência:
http://linux.die.net/man/8/auditd

1 - Um modo de proteção do sistema operacional geralmente segrega a memória virtual em “área do kernel” (“kernel space”) e “area do usuário” (“user space”). A área do kernel é estritamente reservada para executar o kernel, device drivers e extenções do kernel. Em contrapartida, a área do usuário é a área de memória onde toda aplicação em modo usuário trabalha e esta memória pode ser movida para swap (swaped out) quando necessário. O termo userland é freqüentemente usado para se referirão software do sistema operacional que é executado na área do usuário (user space).

Referência:

http://en.wikipedia.org/wiki/User_mode

———————————————————————————-

[kblockd/0]
[kblockd/1]
[kblockd/2]
[kblockd/3]

Gerencia dispositivos de bloco. Parte do trabalho de gerenciar os dispositivos de bloco, é cuidar da alocação de memória no kernel dos dados que serão posteriormente escritos nos dispositivos de bloco.

O kernel guarda em memória antes de escrever para os dispositivos de bloco (como disco), o kblockd gerencia essa alocação em memória feita pelo kernel.

Referência:

http://www.uwsg.indiana.edu/hypermail/linux/kernel/0412.3/0260.html
http://www.geocities.com/ravikiran_uvs/articles/blkdevarch.html
http://www.linuxjournal.com/article/2890
http://www.uwsg.indiana.edu/hypermail/linux/kernel/0412.3/0260.html

———————————————————————————-

[khelper]

Relacionado a processos na fila de execução do kernel.

Referência:
http://www.uwsg.iu.edu/hypermail/linux/kernel/0407.3/0485.html

———————————————————————————-

[khubd]

A thread do kernel khubd, parte do core USB do Linux, monitora os hubs USB da máquina e configura os dispositivos USB quando eles são conectados (hot-plugged) no sistema.

The khubd thread, part of the Linux USB core, monitors the machine’s USB hub and configures USB devices when they are hot-plugged into the system.

Referência:
http://www.linux-mag.com/id/2195/?r=s (é necessário cadastro e login na página)

———————————————————————————-

[kjournald]

kjournald é uma thread de journaling genérica do kernel, que é usada por file systemscomo o ext3.

kjournald is the generic kernel journaling thread, which is used by file systems like ext3.

Referência:
http://www.linux-mag.com/id/2195/?r=s (é necessário cadastro e login na página)

———————————————————————————-

[kmpathd/0]
[kmpathd/1]
[kmpathd/2]
[kmpathd/3]

Possivelmente multipath do storage EMC

Referência:
http://osdir.com/ml/linux.kernel.device-mapper.devel/2005-09/msg00018.html

———————————————————————————-

[kseriod]

É suporte a input via porta serial. Do fonte do Kernel:

CONFIG_INPUT_SERIO
Say Y here and to the Serial port input line discipline option if
you plan to use a joystick that communicates over the serial (COM)
port. For more information on how to use the driver please read
<file[grin]ocumentation/input/joystick.txt>.

/usr/src/kernel-source-2.4.27/Documentation/Configure.help

———————————————————————————-

[ksoftirqd/0]
[ksoftirqd/1]
[ksoftirqd/2]
[ksoftirqd/3]

“NAME
ksoftirqd - Softirq daemon

DESCRIPTION
ksoftirqd is a per-cpu kernel thread that runs when the machine is under heavy soft-interrupt load. Soft interrupts are normally serviced on return from a hard interrupt, but it’s possible for soft interrupts to be triggered more quickly than they can be serviced. If a soft interrupt is triggered for a second time while soft interrupts are being handled, the ksoftirq daemon is triggered to handle the soft interrupts in process context. If ksoftirqd is taking more than a tiny percentage of CPU time, this indicates the machine is under heavy soft interrupt load.

HISTORY
ksoftirqd was introduced during the 2.3 development series as part of the softnet work by Alexey Kuznetsov and David Miller. “

“The [ksoftirqd/0] kernel thread is an aid to implement soft IRQs. Soft IRQs are raised by interrupt handlers to request “bottom half” processing of portions of the interrupt handler whose execution can be deferred. The idea is to minimize the code inside interrupt handlersm which results in reduced interrupt-off times in the system, thus resulting in lower latencies. ksoftirqd ensures that a high load of soft IRQs neither starves the soft IRQs nor overwhelms the system. (On Symmetric Multi-Processing (SMP) machines, where multiple thread instances can run on different processors in parallel, one instance of ksoftirqd is created per processor to improve throughput. On SMP machines, the kernel processes are named ksoftirqd/ n, where n is the processor number.)

Referência:
http://www.penguin-soft.com/penguin/man/9/ksoftirqd.html
http://www.linux-mag.com/id/2195/ (é necessário cadastro e login na página)

———————————————————————————-

[kswapd0]

Thread do kernel que faz o gerenciamento de swap.

O nome swap (troca) para o daemon é um pouco inapropriado, uma vez que o daemon faz mais que simplesmente trocar páginas modifucadas com o arquivo de swap. Sua tarefa é manter o sistema de gerenciamento de memória operando eficientemente. O daemon do kernel de swap (o processo kswapd é iniciado durante a inicialização do sistema e permance esperando pelo swap do kernel para periodicamente expirar) é inicializado toda vez que o timer expira, o daemon swap checa se o número de páginas livres no sistema está ficando muito baixo. Páginas livres no sistema estão muito baixas se:

nr_free_pages + nr_async_pages < free_pages_high

The name swap daemon is a bit of a misnomer as the daemon does more than just swap modified pages out to the swap file. Its task is to keep the memory management system operating efficiently. The Kernel swap daemon (kswapd kernel init process at startup time and sits waiting for the kernel swap timer to periodically expire. ) is started by the Every time the timer expires, the swap daemon looks to see if the number of free pages in the system is getting too low. Free pages in the system are too low if:

nr_free_pages + nr_async_pages < free_pages_high

Referência:
http://www.science.unitn.it/~fiorella/guidelinux/tlk/node39.html

———————————————————————————-

[migration/0]
[migration/1]
[migration/2]
[migration/3]

São threads do kernel responsáveis por mover threads entre as CPU´s. São parte do scheduler do kernel.

It’s a kernel thread responsible for moving threads between CPU’s. It’s
part of the kernel scheduler.

Referência:
http://www.webservertalk.com/archive235-2007-2-1799601.html

———————————————————————————-

[pdflush]

A thread do kernel pdflush limpa páginas sujas do page cache. O page cache registra os acessos ao disco. Para melhorar a performance, a escrita para disco é atrasada até o daemon pdflush escrever dados sujos para disco. Isto é feito se a memória livre disponível está abaixo de um threshold ou se a página remanejou sujeira por um longo tempo. Em kernels 2.4.*, estas duas tarefas são executadas respectivamente por threads distintas do kernel, bdflush e kupdated.

The pdflush kernel thread flushes dirty pages from the page cache. The page cache buffers accesses to the disk. To improve performance, actual writes to the disk are delayed until the pdflush daemon writes out dirtied data to disk. This is done if the available free memory dips below a threshold or if the page has remained dirty for a sufficiently long time. In the 2.4.* kernels, these two tasks were respectively performed by separate kernel threads, bdflush and kupdated.

Referência:

http://www.linux-mag.com/id/2195/ (é necessário cadastro e login na página)

———————————————————————————-

crond

Daemon responsável pela cron (schedule de jobs)

Cron daemon

Referência:
http://linux.die.net/man/8/crond
http://linux.about.com/library/cmd/blcmdl8_crond.htm

———————————————————————————-

cups-config-daemon

Gerenciamento de impressão - Print Server

Referêcia:
http://www.linuxjournal.com/article/8618
http://www.cups.org/
http://www.cups.org/articles.php?L230+I0+T+P1+Qbroadcast

———————————————————————————-

dbus-daemon-1 –system

Processo que gerencia o system bus.

The bus that connects the CPU to main memory on the motherboard. I/O buses, which connect the CPU with the systems other components, branch off of the system bus. The system bus is also called the frontside bus, memory bus, local bus, or host bus.

Referência:
http://www.webopedia.com/TERM/S/system_bus.html

———————————————————————————-

hald

Não, ele não está relacionado ao computador do mal do filme “2001 – Uma Odisséia no Espaço”. Neste contexto, HAL se refere à “Camada de Abstração do Hardware”. O daemon HAL coleta esta informação sobre os dispositivos de hardware do kernel e do hardware e torna esta informação disponível de maneira consistente.
Não desative este daemon. Muitas aplicações dependem dele.

No, this isn’t related to the evil computer in the film “2001, A Space Odyssey.” In this context, HAL refers to the “Hardware Abstraction Layer.” The HAL daemon collects this information about hardware devices from the kernel and the hardware and makes it available in a consistent manner.
Don’t turn off this daemon. Multiple applications rely on it.

Referência:
“Desktop and hardware configuration,” by David Zeuthen http://www.redhatmagazine.com/2007/03/09/understanding-your-red-hat-enterprise-linux-daemons/

———————————————————————————-

init

Processo inicial – principal de todo o sistema

Referência:
http://www.comptechdoc.org/os/linux/startupman/linux_suinit.html
http://www.conectiva.com/doc/livros/online/10.0/servidor/pt_BR/ch03s03.html

———————————————————————————-

irqbalance

Este daemon distribui interrupções de hardware para as CPUs em sistemas SMP (processador simétrico: arquitetura de multi-processador) para melhorar a performance. O daemon faz o balanceamento economizando em consumo de energia com performance.
Você não precisa executar este daemon em sistemas monoprocessados, uma vez que ele apenas tem efeito em sistemas multi-processados. Artigos .”Red Hat Kbase” indicam que o irqbalance é relevante em sistemas x86, x86_64 e AMD.

This daemon distributes hardware interrupts to the CPUs in SMP (symmetric processor: multi-processor architecture) systems to increase performance. The daemon balances savings in power consumption with performance.
You need not run this daemon on single processor systems, as it only has an effect on multiple-processor systems. Red Hat Kbase articles indicate that irqbalance is relevant on x86, x86_64, and AMD systems
.”

Referência:
http://www.irqbalance.org
http://www.redhatmagazine.com/2007/03/09/understanding-your-red-hat-enterprise-linux-daemons/

———————————————————————————-

klogd

O daemon klog, klogd, é um processo de aplicação que amarra o sistema de mensagem do kernel ao syslogd.

The klog dæmon, klogd, is an application process that ties the kernel messaging system to syslogd.”

Referência:
http://www.linuxjournal.com/article/4036

———————————————————————————-

portmap
rpc.idmapd
rpc.statd

Daemons relacionados ao NFS (Network File System)

NFS daemons related.

Referência:

http://nfs.sourceforge.net/nfs-howto/
http://en.wikipedia.org/wiki/Distributed_file_system

———————————————————————————-

syslogd

Gerenciamento de logs do sistema.

System log managment.

Referência:

http://linux.about.com/od/commands/l/blcmdl8_syslogd.htm

———————————————————————————-

udevd

udev é o /dev “virtual” que substituiu o padrão.

Udev permite usuários Linux ter um diretório dinâmico /dev e ele provê a habilidade de ter nomes de devices persistentes.

udev allows Linux users to have a dynamic /dev directory and it provides the ability to have persistent device names.

Referência:
http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html

———————————————————————————-

xfs

Este damon é o servidor de fonte xfs. Este daemon carrega as fontes na memória para habilitar aplicações gráficas a executarem mais rapidamente do que se elas tivessem que carregar as fontes do disco. Vale a pena manter este daemon em execução para melhora de performance das aplicações.

This damon is the xfs font server. This daemon loads fonts into memory to enable X applications to run faster than if they had to load the fonts from disk. This daemon is worth running to improve application performance.”

Referência:

http://linuxreviews.org/howtos/xfree/xfs

http://www.redhatmagazine.com/2007/03/09/understanding-your-red-hat-enterprise-linux-daemons/

———————————————————————————-

xinetd

O xinetd é um substituto para do daemon inetd, daemon de serviços de internet.

Em redes de computadores, xinetd (daemon de internet extendido), é um daemon open-source que roda em diversos sistemas Unix e gerencia conectividade baseada na Internet. Ele oferece uma versão mais segura do inetd, o internet daemon”

“xinetd is a replacement for inetd, the internet services daemon.”

In computer networking, xinetd, the eXtended InterNET Daemon, is an open-source daemon which runs on many Unix systems and manages Internet-based connectivity. It offers a more secure extension to or version of inetd, the Internet daemon.”

Referência:

http://www.xinetd.org/faq.html
http://en.wikipedia.org/wiki/Xinetd
http://linux.about.com/library/cmd/blcmdl8_xinetd.htm

———————————————————————————-

Algumas definicoes:

Definição de thread do kernel:

Um exemplo de uma thread do kernel é o processo init ou processo 0. Este é um processo do sistema que é executado apenas em modo kernel. Alguns outros exemplos seriam o buffer flusher, o swapper, serviços de conexão de rede (keventd, kapm, kswapd, kflushd (bdflush), kupdated, ksoftirqd). Estes executam simples funções C como juntar-se a um processo regular que será usado em modo User e Kernel, e o kernel tem que chamar qualquer função C usada (Veja system calls e traps)”

Definition of Kernel Thread
(ref. /proc/sys/kernel/threads-max)

An example of a kernel thread is init or process 0. It is a system process that only ever runs in Kernel mode. Some other examples would be the buffer flusher, the swapper, network connection services (keventd, kapm, kswapd, kflushd (bdflush), kupdated, ksoftirqd). These execute single C functions as apposed to a regular process that will use User and Kernel mode and the kernel has to call any C functions used. (See system calls and traps).

Referência:

http://freeloaderlinux.sourceforge.net/internals-all.html

Published by carla on 21 Nov 2007

Linux - Como reduzir arquivo de imagem na linha de comando

Para enviar fotos ou imagens por email, para um fotolog ou páginas web, pode ser interessante reduzir o tamanho dessas imagens.

Para reduzir o tamanho de arquivos de imagem, pode-se usar o comando convert do Linux.

Segue abaixo um exemplo desta redução, onde o arquivo DSC07370.JPG será reduzido para o tamanho 800×600 e passará a se chamar DSC07370_P.JPG. O tamanho dos arquivos está destacado em vermelho.

$ convert -size 800×600 DSC07370.JPG DSC07370_P.JPG

$ ls -l
total 18478
-rwxr–r– 1 foo foo 3037188 2007-10-08 23:47 DSC07370.JPG
-rwxr–r– 1 foo foo 3037188 2007-10-14 23:46 DSC07370.JPG.BKP
-rw-r–r– 1 foo foo 854502 2007-10-14 23:46 DSC07370_P.JPG
-rwxr–r– 1 foo foo 3121465 2007-10-08 23:48 DSC07371.JPG
-rwxr–r– 1 foo foo 3041769 2007-10-08 23:48 DSC07372.JPG
-rwxr–r– 1 foo foo 3029528 2007-10-08 23:48 DSC07373.JPG
-rwxr–r– 1 foo foo 2737071 2007-10-08 23:49 DSC07374.JPG
$

Referência:

http://linux.about.com/od/commands/l/blcmdl1_convert.htm

http://www.linux.com/articles/113978

http://www.ibm.com/developerworks/linux/library/l-graf/

Published by carla on 30 Aug 2007

Linux - Como identificar o processo que está utilizando uma porta

Em linux, com a opção p do comando netstat podemos identificar qual o processo está utilizando uma determinada porta:

[root@foo~]# netstat -nap |grep 9101
tcp 0 0 0.0.0.0:9101 0.0.0.0:* LISTEN 4266/nsrexecd

No exemplo acima, vemos que o processo de PID 4266 chamado nsrexecd está utilizando a porta 9101.

Com o comando ps, vemos mais detalhes do processo:

[root@foo ~]# ps -ef |grep 4266
root 4266 1 0 Aug29 ? 00:00:00 /usr/sbin/nsrexecd
root 9503 9427 0 10:25 pts/2 00:00:00 grep 4266

O processo nsrexecd pertence ao software de backup Networker (mais conhecido como Legato).

Verificando o status do Networker:

[root@foo init.d]# /etc/init.d/networker status
+–o nsrexecd (4266)

Se paralizarmos o Networker, a porta será liberada:

[root@foo init.d]# /etc/init.d/networker stop

[root@foo init.d]# /etc/init.d/networker status
nsr_shutdown: There are currently no running NetWorker processes.

[root@foo init.d]# netstat -nap |grep 9101
[root@foo init.d]#

Published by carla on 24 Aug 2007

AIX - Espelhamento do rootvg

O AIX permite que se faça o espelhamento de um VG (volume group) pelo sistema operacional. O VG que contém o sistema operacional é chamado de rootvg. O espelhamento do rootvg é importante para garantir a disponibilidade do sistema operacional oferecendo segurança dos dados.

Situações onde pode-se quere fazer o espelhamento do rootvg são, por exemplo, novas instalações ou após a troca de um disco com problema.

Seguem abaixo os passos para fazer o espelhamento do rootvg em sistemas AIX.

1 - Verificar os discos

# lspv
hdisk0 0000699fde553fc9 rootvg active
hdisk1 0000699f2f5a53d1 None

2- Incluir o novo disco no rootvg

# extendvg rootvg hdisk1

3 - Espelhar o rootvg

# mirrorvg rootvg
0516-1124 mirrorvg: Quorum requirement turned off, reboot system for this to take effect for rootvg.
0516-1126 mirrorvg: rootvg successfully mirrored, user should perform
bosboot of system to initialize boot records. Then, user must modify bootlist to include: hdisk1 hdisk0.

4 - Sincronizzar as cópias

# syncvg -v rootvg

OBS: Este passo é importantíssimo para garantir a integridade dos dados. Caso não seja executado, o sistema pode ser comprometido.

5 - Escrever a área de boot nos dois discos pertencentes ao rootvg:

# bosboot -ad /dev/hdisk1
bosboot: Boot image is 19173 512 byte blocks.

# bosboot -ad /dev/hdisk0
bosboot: Boot image is 19173 512 byte blocks.

6 - Acertar a bootlist(1)

6.1- verificar a bootlist:

# bootlist -m normal -o
hdisk0

6.2 - Configurar a bootlist:

# bootlist -m normal hdisk0 hdisk1

6.3 - Verificar a nova bootlist:

# bootlist -m normal -o
hdisk0
hdisk1

(1) bootlist: lista de boot do sistema operacional. Nela configuramos os devices onde o sistema buscará pelo boot durante a inicialização. Devices como CD (cd0) e fita (rmt0) são comunmente adicionados também.

Referência:

Para saber mais sobre LVM em AIX:

AIX Logical Volume Manager from A to Z: Introduction and Concepts: http://www.redbooks.ibm.com/abstracts/sg245432.html?Open

Published by carla on 03 Aug 2007

Como pular a primeira linha de uma lista

Há mais de uma maneira de pular a primeira linha de uma lista, seja essa lista um arquivo ou a saida de um comando.

Uma maneira bem simples é usar o comando tail com a opção +2:

tail +2 [nomedoarquivo]

O +2 no comando tail não está dizendo exatamente para pular a primeira linha, mas sim para exibir a lista a partir da segunda linha o que vai significar na prática a mesma coisa. No entanto, você pode usar o tail com +3, +4, etc, iniciando a listagem a partir de qualquer linha que se deseje.

Da man page do comando tail:

“If the first character of N (the number of bytes or lines) is a `+’, print beginning with the Nth item from the start of each file, otherwise, print the last N items in the file.

Referências:

Man page do comando tail: http://unixhelp.ed.ac.uk/CGI/man-cgi?tail

Forum - tópico (Best way to skip first line?):

http://www.daniweb.com/forums/thread80245.html (precisa de registro no site)

Published by carla on 13 Jul 2007

IBM - Dicas console e Menu Service Processor

Duas dicas:

1 - Como acessar o menu para configuração da console serial:

CTRL (esquerda) + “-”

2 - Como acessar o Service Processor Menu

com a maquina no prompt “ok”
conecta console
tecla <enter>

Published by carla on 12 Jul 2007

Erro com scp - [ksh: scp: not found. lost connection]

Como resolver o erro ksh: scp: not found. lost connection na execução do comando scp?

O “not found” parece óbvio e logo penso: “Ahn, é o PATH”.

Tento então executar o comando scp com o PATH completo e o problema continua:

foobar:root> /usr/local/bin/scp teste.txt root@192.168.0.1:/root
ksh: scp: not found.
lost connection
foobar:root>

Para tentar identificar o problema, uso a opção “-v” que irá detalhar o log de execução:

foobar>/usr/local/bin/scp -v “$ARQLOG” root@192.168.0.1:/tmp
Executing: program /usr/local/bin/ssh host X.X.X.X, user root, command scp -v -t /tmp
OpenSSH_3.9p1, OpenSSL 0.9.7e 25 Oct 2004
debug1: Reading configuration data /usr/local/etc/ssh_config
debug1: Connecting to X.X.X.X [X.X.X.X] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/1
debug1: identity file /.ssh/identity type -1
debug1: identity file /.ssh/id_rsa type 1
debug1: identity file /.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_4.5
debug1: match: OpenSSH_4.5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.9p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host ‘129.214.18.171′ is known and matches the RSA host key.
debug1: Found key in /.ssh/known_hosts:8
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/identity
debug1: Offering public key: /.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 149
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending command: scp -v -t /tmp
ksh: scp: not found.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.1 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 127
lost connection

O mesmo erro. Pesquisando na web, encontro a resposta na FAQ. :)

Lendo a FAQ:http://www.openssh.org/faq.html#3.7

scp(1) must be in the default PATH on both the client and the server.”

“This includes resetting PATH in /etc/profile, PATH in /etc/environment on AIX, or (for 3.7p1 and above) setting PATH or SUPATH in /etc/default/login on Solaris or Reliant Unix.”

O que acontece é que no servidor do SSH (SSH server), não apenas no client onde estava tentando executar o scp, o scp precisa ter seu PATH configurado no default do ambiente do sistema operacional. O arquivo de configuração onde o PATH deve ser incluído varia de unix para unix.

Para solucionar, editar os arquivos de configuração do servidor SSH e incluir o PATH do comando scp. Para AIX, editar /etc/environment, para Solaris o /etc/default/login.

PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/local/bin

Published by carla on 29 Jun 2007

Email no Unix (mail/mailx) - Como enviar arquivo anexo

Como fazer para enviar um arquivo anexo através do comando mail ou mailx no Unix?

Por exemplo, pode ser necessário enviar um arquivo anexo em emails enviados através de scripts que realizam funções administrativas. Além do anexo, podemos enviar junto o conteúdo no corpo do email (body).

Seguem os passos para enviar um email contendo um arquivo compactado (.zip) e conteúdo no corpo do email:

1 - Compactar arquivos, gerando arquivo zip:

/usr/bin/zip arquivo.zip $diretorio/*ERR*

2 - Gerar o anexo. Para isso usamos o comando uuencode:

/usr/bin/uuencode arquivo.zip arquivo.zip > attachment.txt

OBS: Sim, o nome do arquivo zip é repetido 2 vezes no comando. Não é erro de digitação. :)

3 - Combinar o anexo com o texto que irá no corpo do email:

cat texto_email.txt attachment.txt > combinado.txt

O arquivo texto_email.txt contém o que irá escrito no corpo do email.

4 -Enviar o email com conteúdo no corpo do email e arquivo zip anexo:

/usr/bin/mailx -s “Email com anexo e conteúdo” email@dominio < combinado.txt

A opção “-s” é para colocar o Assunto/Subject do email.

« Prev - Next »