Linux - Guia do Administrador do Sistema
Instalação
de software
Nessa seção colocaremos os pacotes RPM do Red Hat Linux que deverão ser instalados em cada capitulo. Outras distribuições não estarão disponíveis por enquanto. As vezes instalar um pacote rpm não e possível devido ao fato que o pacote não instala por que falta um outro (problema de dependência). Uma das formas de se resolver esse problema e configurar um repositório APT local com os pacotes rpm dos CDs do Red Hat e utilizar o comando apt-get para instalar os pacotes rpm.
O procedimento para isso esta no site moin.conectiva.com.br/AptRpm/Repositories.
O apt para o Red Hat Linux pode ser obtido em www.freshrpms.net.
O apt possui dois front-ends um texto (aptitude) e outro gráfico (synaptic). O synaptic pode ser obtido em
www.freshrpms.net.
INIT
A inicializacao do Debian segue o Sys V init mas e um pouco diferente do Red Hat. O Debian não possui o arquivo /etc/rc.local e o comando service, também não possui os comandos chkconfig e ntsysv que auxiliam muito o gerenciamento dos links dos serviços. O equivalente do comando chkconfig e update-rc.d, Exemplos:
# update-rc.d -f xdm
Remove os links de inicializaçao do XDM (X11)
# update-rc.d xdm start 40 2 3 4 5 . stop 40 0 1 6 .
Cria os links para inicializar o xdm nos runlevels 2 3 4 5 - ordem de inicializacao 40 e os links para não inicializa-lo ou para-lo nos runlevels 0 1 6 - ordem 40.
Criando o comando service no Debian
Edite o arquivo /sbin/services da seguinte forma:
#!/bin/sh
VERSION="`basename $0` ver. 0.91"
USAGE="Usage: `basename $0` < option > | --status-all | \
[ service_name [ command | --full-restart ] ]"
SERVICE=
SERVICEDIR="/etc/init.d"
if [ $# -eq 0 ]; then
echo "${USAGE}" >&2
exit 1
fi
while [ $# -gt 0 ]
do
case "${1}" in
--help | -h | --h* )
echo "${USAGE}" >&2
exit 0
;;
--version | -V )
echo "${VERSION}" >&2
exit 0
;;
*)
if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
cd "${SERVICEDIR}"
for SERVICE in *; do
case "${SERVICE}" in
functions | halt | killall | single| linuxconf| kudzu | \
*rpmorig | *rpmnew | *rpmsave | *~ | *.orig)
;;
*)
if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
"${SERVICEDIR}/${SERVICE}" status
fi
;;
esac
done
exit 0
elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
SERVICE="${1}"
cd "${SERVICEDIR}"
if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
"${SERVICEDIR}/${SERVICE}" stop
"${SERVICEDIR}/${SERVICE}" start
exit $?
fi
elif [ -z "${SERVICE}" ]; then
SERVICE="${1}"
else
OPTIONS="${OPTIONS} ${1}"
fi
shift
;;
esac
done
if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
"${SERVICEDIR}/${SERVICE}" ${OPTIONS}
else
echo "${SERVICE}: unrecognized service" >&2
exit 1
fi
Torne esse arquivo executável com o comando:
# chmod 755 /sbin/service
Criando o arquivo /etc/rc.local no Debian
Edite o arquivo /etc/init.d/local da seguinte forma:
#!/bin/sh
#
# Set the path
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
case "$1" in
start)
if [ -f /etc/rc.local ]; then
exec /etc/rc.local
fi
;;
stop)
# No action to be taken here
;;
status)
# No action to be taken here
;;
restart|reload)
$0 stop
$0 start
;;
*)
echo -n "Usage: $0 {start|stop|status|restart}"
echo
exit 1
esac
Torne esse arquivo executável com o comando:
# chmod 755 /etc/init.d/local
Execute o comando para criar os links simbólicos
# update-rc.d local start 99 2 3 4 5 . 99 0 1 6 .
Edite o arquivo /etc/rc.local de acordo com as necessidades
Torne esse arquivo executável com o comando:
# chmod 755 /etc/rc.local
PLACAS DE REDE
DEBIAN
O arquivo de configuração das placas de rede no Debian e /etc/network/interfaces
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# The loopback interface
auto lo
iface lo inet loopback
# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
address 152.92.122.2
netmask 255.255.255.192
network 152.92.122.0
broadcast 152.92.122.63
gateway 152.92.122.1
auto eth1
iface eth1 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
auto eth2
iface eth2 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
O kernel, como no compilado do Debian possui suporte built-in para varias placas de rede. Para carregar módulos de placas de rede não presentes no kernel edite o arquivo /etc/modules.
SLACKWARE
O arquivo de configuração das placas de rede no Slackware e /etc/rc.d/rc.inet1
#! /bin/sh
# /etc/rc.d/rc.inet1
# This script starts up the base networking system.
#
# Version:
# @(#)/etc/rc.d/rc.inet1 8.1 Tue May 28 15:27:39 PDT 2002 (pjv)
# Edit these values to set up your first Ethernet card (eth0):
IPADDR="152.92.122.61" # REPLACE with YOUR IP address!
NETMASK="255.255.255.192" # REPLACE with YOUR netmask!
# Or, uncomment the following lines to set up eth0 using DHCP:
#USE_DHCP=yes
# If your provider requires a DHCP hostname, uncomment and edit below:
#DHCP_HOSTNAME="CCHOSTNUM-A"
# Edit these values to set up your second Ethernet card (eth1),
# if you have one. Otherwise leave it configured to 127.0.0.1,
# or comment it out, and it will be ignored at boot.
IPADDR2="127.0.0.1" # REPLACE with YOUR IP address!
NETMASK2="255.255.255.0" # REPLACE with YOUR netmask!
# Or, uncomment the following lines to set up eth1 using DHCP:
#USE_DHCP2=yes
# If your provider requires a DHCP hostname, uncomment and edit below:
#DHCP_HOSTNAME2="CCHOSTNUM-A"
# Edit the next line to point to your gateway:
GATEWAY="152.92.122.1" # REPLACE with YOUR gateway!
# You shouldn't need to edit anything below here.
# Set up the loopback interface:
/sbin/ifconfig lo 127.0.0.1
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
# Set up the eth0 interface:
if [ "$USE_DHCP" = "yes" ]; then # use DHCP to set everything up:
echo "Attempting to configure eth0 by contacting a DHCP server..."
# Add the -h option to the DHCP hostname:
if [ ! "$DHCP_HOSTNAME" = "" ]; then
DHCP_HOSTNAME="-h $DHCP_HOSTNAME"
fi
/sbin/dhcpcd -t 10 ${DHCP_HOSTNAME} -d eth0
elif [ ! "$IPADDR" = "127.0.0.1" -a ! "$IPADDR" = "" ]; then # set up IP statically:
# Determine broadcast and network addresses from the IP address and netmask:
BROADCAST=`/bin/ipmask $NETMASK $IPADDR | cut -f 1 -d ' '`
NETWORK=`/bin/ipmask $NETMASK $IPADDR | cut -f 2 -d ' '`
# Set up the ethernet card:
echo "Configuring eth0:"
echo "ifconfig eth0 ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK}"
/sbin/ifconfig eth0 ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK}
# If that didn't succeed, give the system administrator some hints:
if [ ! $? = 0 ]; then
echo "Your eth0 card was not initialized properly. Here are some reasons why this"
echo "may have happened, and the solutions:"
echo "1. Your kernel does not contain support for your card. Including all the"
echo " network drivers in a Linux kernel can make it too large to even boot, and"
echo " sometimes including extra drivers can cause system hangs. To support your"
echo " ethernet, either edit /etc/rc.d/rc.modules to load the support at boot time,"
echo " or compile and install a kernel that contains support."
echo "2. You don't have an ethernet card, in which case you should run netconfig"
echo " and configure your machine for loopback. (Unless you don't mind seeing this"
echo " error...)"
fi
fi # set up eth0
# Set up the eth1 interface:
if [ "$USE_DHCP2" = "yes" ]; then # use DHCP to set everything up:
echo "Attempting to configure eth1 by contacting a DHCP server..."
# Add the -h option to the DHCP hostname:
if [ ! "$DHCP_HOSTNAME2" = "" ]; then
DHCP_HOSTNAME2="-h $DHCP_HOSTNAME2"
fi
/sbin/dhcpcd -t 10 ${DHCP_HOSTNAME2} -d eth1
elif [ ! "$IPADDR2" = "127.0.0.1" -a ! "$IPADDR2" = "" ]; then # set up IP statically:
# Determine broadcast and network addresses from the IP address and netmask:
BROADCAST2=`/bin/ipmask $NETMASK2 $IPADDR2 | cut -f 1 -d ' '`
NETWORK2=`/bin/ipmask $NETMASK2 $IPADDR2 | cut -f 2 -d ' '`
# Set up the ethernet card:
echo "Configuring eth1:"
echo "ifconfig eth1 ${IPADDR2} broadcast ${BROADCAST2} netmask ${NETMASK2}"
/sbin/ifconfig eth1 ${IPADDR2} broadcast ${BROADCAST2} netmask ${NETMASK2}
# If that didn't succeed, give the system administrator some hints:
if [ ! $? = 0 ]; then
echo "Your eth1 card was not initialized properly. Here are some reasons why this"
echo "may have happened, and the solutions:"
echo "1. Your kernel does not contain support for your card. Including all the"
echo " network drivers in a Linux kernel can make it too large to even boot, and"
echo " sometimes including extra drivers can cause system hangs. To support your"
echo " ethernet, either edit /etc/rc.d/rc.modules to load the support at boot time,"
echo " or compile and install a kernel that contains support."
echo "2. You don't have an ethernet card, in which case you should fix"
echo " /etc/rc.d/rc.inet1 to stop trying to configure eth1. (Unless you don't mind"
echo " seeing this error...)"
fi
fi # set up eth1
# Set up the gateway:
if [ ! "$GATEWAY" = "127.0.0.1" -a ! "$GATEWAY" = "" ]; then
/sbin/route add default gw ${GATEWAY} metric 1
fi
# End of /etc/rc.d/rc.inet1
Para carregar os módulos das placas de rede edite o arquivo /etc/rc.d/rc.modules.
