ADMINISTRADOR
DE LINUX I
1/71
ndice de contenido
1.-INTRODUCCIN A LA ADMINISTRACIN LINUX............................................4
Actualizacin de software............................................................................ 4
Directorios principales..................................................................................4
Permisos ficheros......................................................................................... 5
Para crear usuario y grupos......................................................................... 5
LOS ENLACES EN LINUX............................................................................... 6
FSTAB .......................................................................................................... 7
ARRANQUE DEL SISTEMA........................................................................... 10
CRONTAB....................................................................................................11
Como compilar un programa en codigo fuente.......................................... 12
COMPILACION DEL KERNEL. PONER MODULOS Y PARCHES...........................15
PASO A PASO PARA LA COMPILACION.........................................................15
Para aplicar un parche a un kernel.............................................................21
MODULOS...................................................................................................22
RECUPERACION DEL SISTEMA EN CASO DE FALLO.........................................23
4.- CONFUGURACON DE LA RED LOCAL......................................................... 24
Ficheros de configuracin de red...............................................................25
CONFIRGURAR UN SERVIDOR DHCP...............................................................27
5.- NFS (Network File System)........................................................................29
PRACTICA NFS............................................................................................ 30
INSTALAR VMWARE SERVER...........................................................................31
VMware Server sobre Debian..................................................................... 33
La consola se cuelga al pulsar el botn browse.........................................33
WEBMIN......................................................................................................34
6.- OpenLDAP ................................................................................................36
Que vamos a hacer?.................................................................................36
INSTALACIN OpenLDAP.............................................................................37
Migracion de los datos locales al Directorio LDAP......................................39
PARTE DEL CLIENTE....................................................................................40
Directorio HOME centralizado.................................................................... 44
PRACTICA OpenLDAP..................................................................................45
SERVIDOR DE IMPRESION CUPS..................................................................... 46
AADIR UNA IMPRESORA........................................................................... 47
Configurar un cliente linux para imprimir por impresoras remotas de CUPS
...................................................................................................................48
COPIAS DE SEGURIDAD..................................................................................49
PARA CONFIGURAR UN SERVIDOR DE RSYC Que es donde tenemos lo
datos.......................................................................................................... 49
PARTIMAGE.................................................................................................51
PARTED. .....................................................................................................52
IMAGEN DEL SO en FORMATO ISO (como ghost)........................................53
SYSTEM RESCUE CD *Descargar................................................................53
SAMBA y WINBIND ........................................................................................ 54
2/71
PRCTICA DE SAMBA..................................................................................61
COMO HACER QUE EL SERVIDOR SAMBA HAGA FUNCIONES DE PDC........64
PRACTICA SAMBA....................................................................................... 66
PRACTICA DE METER UN LINUX EN UN DOMINIO , con WINBIND...............66
PRACTICA FINAL PERMISOS Y USUARIOS, SISTEMAS DE FICHEROS,
MONITORIZACION DEL SISTEMA,................................................................... 68
SAMBA Y RSYNC.............................................................................................68
3/71
ADMINISTRADOR LINUX I
1.-INTRODUCCIN A LA ADMINISTRACIN LINUX
Actualizacin de software.
En /etc/apt/sources.list es donde se especifica el repositorio donde buscar los
paquetes.
Comentar la linea de cdrom si no lo voy a usar.
debian:/home/jose# cat /etc/apt/sources.list
#
# deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 CD Binary-1
20070407-11:55]/ etch contrib main
# deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 CD Binary-1
20070407-11:55]/ etch contrib main
#Lsita de paquetes
deb http://ftp.rediris.es/debian/ etch main
deb-src http://ftp.rediris.es/debian/ etch main
#Actualizaciones de seguridad
deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib
Directorios principales
/bin :binarios para cualquier usuario
/dev : todos los disp. del sistema
/boot : Imagenes del kernel
/sbin: binarios de root
/home: Dir de los usuarios
/lib:Libreria del sistema
/initrd: Es lo que carga el cargador de arranque antes de cargar la imagen del
nuebleo
/etc: Directorio de configuracin de todo el sistema.
/lost+found: Existe por que el fs es ext
/media: donde se monta el CD y los USB
/mnt: donde montamos los discos del sistema por convencio.
4/71
Permisos ficheros.
debian:/home/jose# ls -l
total 4
drwxr-xr-x 2 jose jose 4096 2007-11-05 17:46 Desktop
5/71
jose:x:1000:1000:jose salom,,,:/home/jose:/bin/bash
En /etc/groups
Para poner la contrasea al usuario
# passwd usuario
// sin la s
6/71
Aqu vemos que realmente es como si fuera el mismo fichero ya que tiene el
mismo i-nodo.
FSTAB
Aqu indicamos las particiones que queremos montar en el sistema al arrancar.
debian:/media# cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>
<type> <options>
<dump> <pass>
proc
/proc
proc
defaults
0
0
/dev/hda3
/
ext3
defaults,errors=remount-ro 0
/dev/hda2
none
swap
sw
0
0
/dev/hdc
/media/cdrom0
udf,iso9660 user,noauto
0
0
/dev/fd0
/media/floppy0 auto
rw,user,noauto 0
0
x.x.x.x:/dir_remoto /mnt/donde nfs user # para montar un sistema nfs
options:
user: Para que el usuario pueda montar el dev
noauto: Para que no lo monte al inicio.
Type: Tipo de particion
Si pones auto el sistema intenta reconocer la particion.
Comandos para crear particiones #fdisk o #cfdisk
mkfs.ext3
mkfs.minix
mkfs.reiserfs
mkfs.reiserfs
mkfs.vfat
7/71
Veo que solo puedo dar formato a la particion de esos tipos luego instalo el
paquete reiserfsprogs
debian:/media# apt-get install reiserfsprogs
Leyendo lista de paquetes... Hecho
Creando rbol de dependencias... Hecho
Se instalarn los siguientes paquetes NUEVOS:
reiserfsprogs
0 actualizados, 1 se instalarn, 0 para eliminar y 0 no actualizados.
Necesito descargar 480kB de archivos.
Se utilizarn 1090kB de espacio de disco adicional despus de desempaquetar.
Des:1 http://ftp.rediris.es etch/main reiserfsprogs 1:3.6.19-4 [480kB]
Descargados 480kB en 1s (328kB/s)
Seleccionando el paquete reiserfsprogs previamente no seleccionado.
(Leyendo la base de datos ...
67724 ficheros y directorios instalados actualmente.)
Desempaquetando reiserfsprogs (de .../reiserfsprogs_1%3a3.6.19-4_i386.deb) ...
Configurando reiserfsprogs (3.6.19-4) ...
debian:/media# mkfs. TAB TAB
mkfs.cramfs
mkfs.ext2
mkfs.ext3
mkfs.minix
mkfs.reiserfs
Ahora ya puedo formatear con reiserfs la nuevas particion que haba creado.
debian:/home/jose# mkfs.reiserfs /dev/hda4
mkfs.reiserfs 3.6.19 (2003 www.namesys.com)
A pair of credits:
Alexander Zarochentcev (zam) wrote the high low priority locking code, online
resizer for V3 and V4, online repacker for V4, block allocation code, and major
parts of the flush code, and maintains the transaction manager code. We give
him the stuff that we know will be hard to debug, or needs to be very cleanly
structured.
Vladimir Demidov wrote the parser for sys_reiser4(), the V3 alpha port, part of
the V3 journal relocation code, and helped Hans keep the business side of
things running.
Guessing about desired format.. Kernel 2.6.18-5-686 is running.
Format 3.6 with standard journal
Count of blocks on the device: 1220928
Number of blocks consumed by mkreiserfs formatting process: 8249
Blocksize: 4096
Hash function used to sort names: "r5"
Journal Size 8193 blocks (first block 18)
Journal Max transaction length 1024
inode generation number: 0
UUID: 2b695283-9fe4-4dbe-b72f-7aa3b2649909
ATTENTION: YOU SHOULD REBOOT AFTER FDISK!
ALL DATA WILL BE LOST ON '/dev/hda4'!
Continue (y/n):y
Initializing journal - 0%....20%....40%....60%....80%....100%
Syncing..ok
Tell your friends to use a kernel based on 2.4.18 or later, and especially not
akernel based on 2.4.9, when you use reiserFS. Have fun.
8/71
Con df vemos los datos de los dispositivos montados y sus espacio libre y
usado. La opcion -h es para que lo ponga en Gb y mb
debian:/home/jose# df -h
S.ficheros
Tamao Usado
/dev/hda3
9,2G 2,2G
tmpfs
252M
0
udev
10M
64K
tmpfs
252M
0
/dev/sda1
879M 650M
/dev/hda4
4,7G
33M
Para que se cargue en el inicio pondriamos los datos del mount en el fstab.
proc
/dev/hda3
/dev/hda2
/dev/hdc
/dev/fd0
/dev/hda4
/proc
/
none
/media/cdrom0
/media/floppy0
/mnt/part4
proc
defaults
0
0
ext3
defaults,errors=remount-ro 0
swap
sw
0
0
udf,iso9660 user,noauto
0
0
auto
rw,user,noauto 0
0
auto
rw,user,auto
0
1
Si pones noauto no se carga al principio, pero luego para montarla solo hace
falta pasarle el punto de montaje.
#mount /mnt/part4
9/71
Para que los volumenes montados salgan por defecto hay que ejecutar.
Reiniciar y ejecutar ....
#gconf-editor
Lo siguiente indica que inicia en el nivel dos esto quiere decir que va al
directirio
/etc/rc.2d/ y todo lo que empieza por s hace un start del demonio que le indica
el enlace. En concreto
debian:/etc/rc2.d# ls
README
S20acpid
S20exim4
S21nfs-common S99rmnologin
S10sysklogd S20bittorrent S20hotkey-setup S89anacron
S99stopbootlogd
S11klogd
S20cpufrequtils S20makedev
S89atd
S18portmap S20cupsys
S20openbsd-inetd S89cron
S19hplip
S20dbus
S21gdm
S99rc.local
id:2:initdefault:
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS
# What to do in single-user mode.
~~:S:wait:/sbin/sulogin
#
#
#
#
#
10/71
CRONTAB
Nos sirve para programar tareas. Lo tenemos en /etc
debian:/etc# cat crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 *
* * *
root
cd / && run-parts --report /etc/cron.hourly
25 6
* * *
root
test -x /usr/sbin/anacron || ( cd / && run-parts
--report /etc/cron.daily )
En /etc/crontab se guardan las tareas programadas del sistema.
debian:/etc# cat crontab
11/71
#
#
#
#
#
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
# Tareas todos los dias a las 17:00
17 *
* * *
root
cd / && run-parts --report /etc/cron.hourly
#Tareas diarias
25 6
* * *
root
test -x /usr/sbin/anacron || ( cd / && run-parts
--report /etc/cron.daily )
#Tareas Somanales
47 6
* * 7
root
test -x /usr/sbin/anacron || ( cd / && run-parts
--report /etc/cron.weekly )
#Tareas Mensuales.
52 6
1 * *
root
test -x /usr/sbin/anacron || ( cd / && run-parts
--report /etc/cron.monthly )
Todos los shells scripts que ponemos en esos directorios los lanzar segn el
directorios diarioamente /semanalmente ....
Ademas podemos programar las tareas por cada usuario.
$ crontab -e
$ crontab -l
$ crontab -r
Procedimiento general.
1.- Configurar el programa para nuestra maquina
2.- Lo compilamos
3.- Lo instalamos.
Primero hay que descomprimlo y sacamos del tar.
$ tar xzvf fichero.tar.gz
Donde x:sacar del tar
jose@debian:~/Desktop/Descargas$ tar xzvf tmsnc-0.3.2.tar.gz
1.- Para configurar el programa usar el configue. Para esto suele hacer falta
tener el paquete ncurses-dev
jose@debian:~/Desktop/Descargas/tmsnc-0.3.2$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
.......
checking
checking
checking
checking
ME avisa de que aun me falta una librera en este caso openssl que se llama
13/71
libssl-dev
Ahora paso otra vez el /.configure y acaba bien
....
config.status:
config.status:
config.status:
config.status:
creating autopackage/default.apspec
creating src/config.h
src/config.h is unchanged
executing depfiles commands
Version:
Prefix:
CFLAGS:
0.3.2
/usr/local
-g -O2
Talkfilter support:
i18n support:
no
yes
14/71
3.- Ahora tenemos una carpeta con el todo el cdigo fuente. La tenemos que
15/71
vmlinuz-2.6.18-4-686
vmlinuz-2.6.18-5-686
Estilo Clasico. ---6.- Hacemos make dep para compilar las dependencias.
7a.- make bzImage -> imagen comprimida con bzip
7b.- make Image -> Imagen sin comprimir
7.c- make zImage -> Imagen comprimida con zip.
Esto crea la imagen en /usr/src/linux/arch/i386/boot
Y copiaremos esa imagen en /boot
8.- make modules
9.- make modules install
En usr/src nos dejara los .deb de la imagen del kernel y las cabeceras.
Nota: Los header no hacen falta realmente. solo si hiciera falta por algn
dispositivo.
debian:/usr# cd src/
debian:/usr/src# ls
linux
linux-2.6.23.1
linux-image-2.6.23.1mikernel_2.6.23.1mikernel-10.00.Custom_i386.deb
17/71
9.- Nos pone en el grub la imagen compilada como primera opcin por defecto.
En este caso me agrega la prime opcion y como en opcion default tengo 0
arrancaria por ah.
En menu.lst se configura el grup
debian:/usr/src# cd /boot
debian:/boot# cd grub/
debian:/boot/grub# cat menu.lst
# menu.lst - See: grub(8), info grub, update-grub(8)
#
grub-install(8), grub-floppy(8),
#
grub-md5-crypt, /usr/share/doc/grub
#
and /usr/share/doc/grub-doc/.
## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not change this entry to 'saved' or your
# array will desync and will not let you boot your system.
default
0
## timeout sec
18/71
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout
5
# Pretty colours
color cyan/blue white/blue
## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
#
password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret
#
#
#
#
#
#
#
#
#
#
#
#
examples
title
root
makeactive
chainloader
Windows 95/98/NT/2000
(hd0,0)
title
root
kernel
Linux
(hd0,1)
/vmlinuz root=/dev/hda2 ro
+1
#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST
### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below
## DO NOT UNCOMMENT THEM, Just edit them to your needs
## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
##
kopt_2_6_8=root=/dev/hdc1 ro
##
kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=/dev/hda3 ro
## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,2)
## should update-grub create alternative automagic boot options
## e.g. alternative=true
##
alternative=false
# alternative=true
## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
##
lockalternative=false
# lockalternative=false
19/71
## additional options to use with the default boot option, but not with the##
alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=
## should update-grub lock old automagic boot options
## e.g. lockold=false
##
lockold=true
# lockold=false
## Xen hypervisor options to use with the default Xen boot option
# xenhopt=
## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0
## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
##
altoptions=(single-user) single
# altoptions=(single-user mode) single
## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
##
howmany=7
# howmany=all
## should update-grub create memtest86 boot option
## e.g. memtest86=true
##
memtest86=false
# memtest86=true
## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false
## ## End Default Options ##
title
root
kernel
initrd
savedefault
title
root
kernel
initrd
savedefault
title
root
kernel
initrd
savedefault
title
root
kernel
20/71
initrd
savedefault
/boot/initrd.img-2.6.18-5-686
title
root
kernel
initrd
savedefault
title
root
kernel
initrd
savedefault
21/71
MODULOS
Para ver los modulos que tiene un kernel cargado en un momento dado.
# lsmod | less
Para cargar el modulo nuevo que tenemos disponible.
# modprobe modulo
Para ver los modulos disponibles para ese kernel en su compilacion
# modprobe -l | less
Si algn modulo no esta disponible habria que compilar el kernel otra vez y
marcar el modulo como disponible.
En el archivo /etc/modules estan los modulos que quiero que siempre carge al
inicio de la maquina
debian:/etc# cat modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
loop
22/71
23/71
Y lo desctivamos
24/71
netmask X.X.X.X
ifup ethX
ifdown ethX
Genmask
255.255.255.0
0.0.0.0
Use Iface
0 eth0
0 eth0
25/71
nameserver 192.168.0.10
26/71
Reiniciamos la red
debian:/etc/network# ifdown eth0
ifdown: interface eth0 not configured
debian:/etc/network# ifup eth0
Para asignar ipfijas segn las MAC de las tarjetas de red se hace de la siguiente
27/71
wxp-jsalom {
harware ethernet 00:E5:34:4C:8E:68;
fixed-address 192.168.4.5;
server-names
192.168.4.1;
Para hacer una prueba de recibir la ip desde un servidor DHCP podemos usar la
utilidad dhclient eth0.
debian:/etc# dhclient eth0
Internet Systems Consortium DHCP Client V3.0.4
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Listening on LPF/eth0/00:11:43:b4:1b:ed
Sending on
LPF/eth0/00:11:43:b4:1b:ed
Sending on
Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
DHCPOFFER from 192.168.7.1
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 192.168.7.1
bound to 192.168.7.21 -- renewal in 256 seconds.
Si queremos que el sevidor dhcpd no se reinicie cada vez habra que quitarlo
de los ficheros de arranque de los diferentes niveles.
Esto se puede hacer automticamente con:
debian:/etc/network# update-rc.d -f dhcp remove
Removing any system startup links for /etc/init.d/dhcp ...
/etc/rc0.d/K20dhcp
/etc/rc1.d/K20dhcp
/etc/rc2.d/S20dhcp
/etc/rc3.d/S20dhcp
/etc/rc4.d/S20dhcp
/etc/rc5.d/S20dhcp
/etc/rc6.d/K20dhcp
28/71
El comando de portmap para ver las conexiones RPC que tenemos en el equipo
debe ser.
#rpcinfo -p
programa vers proto
100000
2
tcp
100000
2
udp
100024
1
udp
100024
1
tcp
100003
2
udp
100003
3
udp
100003
4
udp
100021
1
udp
100005
1
udp
100005
1
tcp
100005
2
udp
100005
2
tcp
.....
puerto
111
111
32769
52979
2049
2049
2049
32776
658
661
658
661
portmapper
portmapper
status
status
nfs
nfs
nfs
nlockmgr
mountd
mountd
mountd
mountd
MaquinaClientes (opciones)
Por defecto el NFS intenta asiciar los UID de los cliente con los que existan en
el servidor . Esto puede generar problemas de seguridad.
Las opciones las tenemos el la pgina 86
root_squash: Traslada el UID/GID del root cliente al anonymous del servidor.
all_squash : Cada usuario que mapee la carpeta traslada su UID al UID
anonymous del servidor.
map_daemon: Para que traslade los UID clientes en el Servidor.
29/71
PRACTICA NFS.
debian:/mnt# mkdir remoto
Creo un usuario para acceder a la carpeta
debian:/mnt# useradd -u 3000 -s /bin/bash nfsuser
Le doy permisos al usuaio.
debian:/mnt# chown nfsuser /mnt/remoto
/mnt/remoto
Cada vez que hagamos cambios en el fichero export, o reiniciamos el serv nfs o
ejecutamos exportfs -ra
Esto puede ser util por ejemplo para poner en fstab los montajes de NFS y por
ejemplo mapear los /homes de los usuarios en un servidor.
30/71
done
31/71
done
32/71
Do you want this program to probe for an unused private subnet? (yes/no/help)
[yes]
Probing for an unused private subnet (this can take some time)...
...
Type XXXXX-XXXXX-XXXXX-XXXXX or 'Enter' to cancel:
92WRN-YH60K-282EM-4TJKR
done
done
done
done
done
done
Por qu olvido siempre cmo se llama el paquetito que tengo que instalar
cada vez que se actualiza el kernel para poder compilar los mdulos de
VMware?
apt-get install linux-headers-$(uname -r)
ln -s /usr/src/linux-headers-2.6.18-5-686 /usr/src/linux
33/71
WEBMIN
Hay que ir a www.webmin.com
34/71
35/71
6.- OpenLDAP
Que vamos a hacer?
Lo que vamos a intentar es tener un servidor Ldap donde tendremos la cuentas
de usuario/ grupos y los host. Las maquinas clientes se validarn todos con
esas cuentas de usuario. Podramo hacer tambien que el directorio de usuario
levantara su home como NFS para que lo pueda ver en cualquier lado. Esto es
solo para Linux.
En el Serv LDAP guardara objetos de la red y atributos de estos.
La informacin se estructura en una estructura de tipo arbol. Toda entrada
viene identificada inequivocamente por el DN (Distingiser Name).
Para darle funcionalidad existen esquemas (que definen la extructura ) para
almacenar los datos. Por defecto viene posixAccount. Para samba tendremos
que poner otro esquema.
dn: uid=pepe, ou=People, dc=admon, dc=com
objectClass: person
cn: Jose Garca
sn: Garca
description: alumno
mail: pepe@admon.com
El formato en el que se han mostrado los atributos del objeto se denomina LDIF
(LDAP Data Interchange Format), y resulta til conocerlo porque es el formato
que los servidores LDAP (y OpenLDAP entre ellos) utilizan por defecto para
insertar y extraer informacin del directorio.
36/71
INSTALACIN OpenLDAP.
Para ello instalamos el paquete slapd
apt-get install slapd
37/71
38/71
"cn=admin,dc=jose,dc=es"
39/71
dc=jose, dc=es
192.168.2.24
Para que el cliente pueda autenticar hay que instalar dos bibliotacas.
PAM y NSS. Esto se instala en el cliente de la siguiente forma:
#apt-get install libpam-ldap
Ponemos la ip del servidor ldap://IP
Version 3
Make local root database admin : Decir SI
40/71
41/71
compat ldap
compat ldap
compat ldap
42/71
#
# /etc/pam.d/common-account - authorization settings common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of the authorization modules that define
# the central access policy for use on the system. The default is to
# only deny service to users whose accounts are expired in /etc/shadow.
#
account required
pam_unix.so
account sufficient
pam_ldap.so
debian:/etc/pam.d# cat common-session
#
# /etc/pam.d/common-session - session-related modules common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define tasks to be performed
# at the start and end of sessions of *any* kind (both interactive and
# non-interactive). The default is pam_unix.
#
session required
pam_limits.so
session required
pam_unix.so
session optional
pam_ldap.so
debian:/etc/pam.d# cat common-auth
#
# /etc/pam.d/common-auth - authentication settings common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of the authentication modules that define
# the central authentication scheme for use on the system
# (e.g., /etc/shadow, LDAP, Kerberos, etc.). The default is to use the
# traditional Unix authentication mechanisms.
#
auth
sufficient
pam_unix.so
auth
sufficient
pam_ldap.so try_first_pass
auth
required
pam_env.so
auth
required
pam_securetty.so
auth
required
pam_unix_auth.so
auth
required
pam_warn.so
auth
required
pam_deny.so
43/71
# new password.
#password
required
/etc/exports: the access control list for filesystems which may be exported
to NFS clients. See exports(5).
Example for NFSv2 and NFSv3:
/srv/homes
hostname1(rw,sync) hostname2(ro,sync)
Example for NFSv4:
/srv/nfs4
gss/krb5i(rw,sync,fsid=0,crossmnt)
/srv/nfs4/homes gss/krb5i(rw,sync)
44/71
/home 192.168.2.0/24
(rw)
En el cliente
Poniendo en ftab
192.168.2.1:/home home nfs ...
PRACTICA OpenLDAP
Creamos una maquina virtual debian con Ethernet 1 como britged.
Tomamos ip en la MV con #dhcpclient
Instalamos OpenLdap en el Servidor.
45/71
Sample configuration file for the Common UNIX Printing System (CUPS)
scheduler. See "man cupsd.conf" for a complete description of this
file.
46/71
</Location>
# Restrict access to the admin pages...
# JAS Para decir a quien dejamos administrar
<Location /admin>
Encryption Required
Order allow,deny
Allow localhost
</Location>
....
47/71
48/71
COPIAS DE SEGURIDAD.
Software Libre de copia de seguridad.
amanda o vacula
Aqu utilizaremos uno mas sencillo:rsysn
Ibstalarlo con
apt-get install rsync
man rsysn
Nos sirve para sincronizar directorios y el origen y destino podrn ser local o
remoto.
#rsync *.c
server:/var/datos
Con esto sincronizariamos todos los *.c a /var/datos del servidor. Esto la
primera vez los pasa todo y luego solo envia los cambios.
Este comando se debe poner como una tarea en el cron para que lo haga
Se puede hacer al revs
rsync -avvz server:/var/datos
/root
a Conseva propiedades del archivo
vv Verbose. Da informacin
z Para quecomprima
Por defecto en el destino solo aade (no borra).
Si queremos que borre debemos poner
rsync -avvz --delete server:/var/datos
/root
Hay que tener cuidado con hacer...
rsync /var/datos
IP:/backup
Cogera el directorio destino y lo crear (el dir datos) debajo de backup
rsync /var/datos/
IP:/backup
49/71
gid=root
use chroot=no
syslog facility=daemon
# Definimos la gente que se puede conectar.
host allow=*
max connections=4
uid=root
gid=root
use chroot=no
syslog facility=daemon
# Definimos la gente que se puede conectar.
host allow=*
max connections=4
IMPORTANTE.
Poner el /etc/default/rsinc RSYNC_ENABLE a true
# defaults file for rsync daemon mode
# start rsync in daemon mode from init.d script?
# only allowed values are "true", "false", and "inetd"
# Use "inetd" if you want to start the rsyncd from inetd,
# all this does is prevent the init.d script from printing a message
# about not starting rsyncd (you still need to modify inetd's config yourself).
RSYNC_ENABLE=true
/var/backup/datos
/etc/init.d/rsync restart
Para guardar los datos del proceso y los errores en el mismo fichero podemos
aadir al comando que se ejecuta en el cliente.
#rsync -avvz IP_SERVER::datos
Empaquetar
Desempaquetar
Listar
Verbose
nombre del fichero
comprimir en zip
cimprimir en bzip2
50/71
PARTIMAGE
# apt-get install partimage
Description: backup partitions into a compressed image file
Partition Image is a partition imaging utility. It has support for the
following file systems:
* Ext2/3, the linux standard
* Reiser3, a journalised and powerful file system
* FAT16/32, DOS and Windows file systems
* HPFS, IBM OS/2 file system
* JFS, journalised file system, from IBM, used on AIX
* XFS, another journalised and efficient file system, from sgi, used on Irix
* UFS (beta), Unix file system
* HFS (beta), MacOS File system
* NTFS (experimental), Windows NT, 2000 and XP
Only used blocks are copied and stored into an image file.
The image file can be compressed in the GZIP/BZIP2 formats to save disk space,
and split into multiple files to be copied onto removable media (ZIP for
example), burned on a CD-R, etc.
.
This makes it possible to save a full Linux/Windows system with a single
operation. In case of a problem (virus, crash, error, etc.), you just have
to restore, and after several minutes, your entire system is restored
(boot, files, etc.), and fully working.
.
This is very useful when installing the same software on many machines: just
install one of them, create an image, and restore the image on all other
machines.
#partimage
51/71
PARTED.
Puedes redimensionar particiones
Para hacer cambios sobre una particin debe de estar desmontada.
apt-get parted
# parted /dev/hda
GNU Parted 1.7.1
Using /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
(parted) print
Disk /dev/hda: 40,0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number
1
2
3
4
Start
32,3kB
10,7GB
11,8GB
21,8GB
End
10,7GB
11,8GB
21,8GB
40,0GB
Size
10,7GB
1078MB
10,0GB
18,2GB
Type
primary
primary
primary
primary
File system
ext3
linux-swap
ext3
reiserfs
Flags
boot
52/71
53/71
SAMBA y WINBIND
Se utiliza para compartir recursos mediante el protocolo SMB.
Tambien nos permitir pertenecer a una red windows.
#apt-get install samba smbclient
debian:~/backup# apt-get install samba smbclient
Leyendo lista de paquetes... Hecho
Creando rbol de dependencias... Hecho
Se instalarn los siguientes paquetes extras:
samba-common
Paquetes sugeridos:
smbfs
Paquetes recomendados
smbldap-tools
Se instalarn los siguientes paquetes NUEVOS:
samba samba-common smbclient
...
54/71
Sample configuration file for the Samba suite for Debian GNU/Linux.
This is the main Samba configuration file. You should read the
smb.conf(5) manual page in order to understand the options listed
here. Samba has a huge number of configurable options most of which
are not shown in this example
Any line which starts with a ; (semi-colon) or a # (hash)
is a comment and is ignored. In this example we will use a #
for commentary and a ; for parts of the config file that you
may wish to enable
NOTE: Whenever you modify this file you should run the command
"testparm" to check that you have not made any basic syntactic
errors.
55/71
# This will prevent nmbd to search for NetBIOS names through DNS.
dns proxy = no
# What naming service and in what order should we use to resolve host names
# to IP addresses
;
name resolve order = lmhosts host wins bcast
#### Networking ####
#
#
#
#
;
#
#
#
#
#
;
Only bind to the named interfaces and/or networks; you must use the
'interfaces' option above to use this.
It is recommended that you enable this feature if your Samba machine is
not protected by a firewall or is a firewall itself. However, this
option cannot handle dynamic or non-broadcast interfaces correctly.
bind interfaces only = true
"security = user" is always a good idea. This will require a Unix account
in this server for every user accessing the server. See
/usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
in the samba-doc package for details.
JAS Puede tener varios tipos USER/SHARE /SERVER /DOMAIN
56/71
57/71
;
;
#
#
#
#
#
#
#
;
#
#
#
;
logon drive = H:
logon home = \\%N\%U
The following setting only takes effect if 'domain logons' is set
It specifies the script to run during logon. The script must be stored
in the [netlogon] share
NOTE: Must be store in 'DOS' file format convention
JAS La estructura tipica es /home/samba/profiles
/home/samba/netlogon
JAS Los scripts de arranque
logon script = logon.cmd
This allows Unix users to be created on the domain controller via the SAMR
RPC pipe. The example command creates a user account with a disabled Unix
password; please adapt to your needs
add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u
Most people will find that this option gives better performance.
See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/speed.html
for details
You may want to add the following on a Linux system:
SO_RCVBUF=8192 SO_SNDBUF=8192
socket options = TCP_NODELAY
# The following parameter is useful only if you have the linpopup package
# installed. The samba maintainer and the linpopup maintainer are
58/71
#
#
;
;
;
;
;
;
;
;
;
#
;
;
Some defaults for winbind (make sure you're not using the ranges
for something else.)
idmap uid = 10000-20000
idmap gid = 10000-20000
template shell = /bin/bash
The following was the default behaviour in sarge
but samba upstream reverted the default because it might induce
performance issues in large organizations
See #368251 for some of the consequences of *not* having
this setting and smb.conf(5) for all details
JAS Tambien para tema de Domino
winbind enum groups = yes
winbind enum users = yes
59/71
share modes = no
60/71
#
cdrom share is accesed. For this to work /etc/fstab must contain
#
an entry like this:
#
#
/dev/scd0
/cdrom iso9660 defaults,noauto,ro,user
0 0
#
# The CD-ROM gets unmounted automatically after the connection to the
#
# If you don't want to use auto-mounting/unmounting make sure the CD
#
is mounted on /cdrom
#
;
preexec = /bin/mount /cdrom
;
postexec = /bin/umount /cdrom
PRCTICA DE SAMBA
Copiamos una imagen virtual de windows de prueba del servidor con scp:
# scp 192.168.2.3:/home/luis/Desktop/winxp.tar.gz /root/
The authenticity of host '192.168.2.3 (192.168.2.3)' can't be established.
RSA key fingerprint is d5:df:52:38:55:f6:87:4c:21:74:52:fa:31:b8:61:a4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.2.3' (RSA) to the list of known hosts.
root@192.168.2.3's password:
winxp.tar.gz
100% 668MB
1.7MB/s
06:44
...
61/71
Instalamos swat
# aptitude install swat
Accedemos a traber del puerto 901 del localhost. A traves de esta aplicacin
podemos administrar de forma grafica el SAMBA
62/71
Comment
-------
Workgroup
--------CURSO
Master
------WINXP
63/71
smbfs:
64/71
#smbpasswd -a usudown
PRACTICA SAMBA
Creamos una carpeta en C:\curso del windows y la montaremos desde samba
en el linux como si fuera un NFS.
Hay que tener instalado el paquete smbfs
66/71
files
files
files
files
winbind
winbind
winbind
dns winbind
# /etc/init.d/winbind restart
Verificar la integracin del dominio:
- "net rpc testjoin" muestra si esta correctamente integrada al dominio:
Join to 'PRUEBAS' is OK
- "net ads info" muestra informacin del dominio:
"net rpc info -U Usuario_de_dominio" muestra el dominio al que pertenece, numero
de usuarios, grupos, etc:
Domain Name: PRUEBAS
Domain SID: x-x-x-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx
Sequence number: xx
Num users: xx
Num domain groups: xx
Num local groups: xx
Verificar
- "wbinfo
- "wbinfo
- "getent
- "getent
67/71
-d
-d
-d
-d
-d
68/71
# getfacl comercial/
# file: comercial
# owner: root
# group: comercio
user::-wgroup::rwx
other::--#setfacl -m group:secre:r /var/datos/comercial
getfacl /var/datos/comercial/
getfacl: Removing leading '/' from absolute path names
# file: var/datos/comercial
# owner: root
# group: comercio
user::-wgroup::rwx
group:secre:r-mask::rwx
other::---
path= /var/datos/secretariado
valid users = @secre
read only = No
create mask = 0770
directory mask = 0770
writable = yes
[comercio]
path= /var/datos/comercial
valid users = @comercio
read only = No
create mask = 0770
directory mask = 0770
writable = yes
2.- Hay que poner en el file system que queremos modificar las acl la opcion
acl
# /etc/fstab: static file system information.
#
# <file system> <mount point>
<type> <options>
<dump> <pass>
proc
/proc
proc
defaults
0
0
/dev/hda3
/
ext3
defaults,errors=remount-ro,acl 0
#getfacl fichero
#serfacl fichero
Para dar a un usuario concrero permisos a un fichero sin que pertenezca a un
grupo concreto y sin dar permisos a todos los usuario lo hacemos
#setacl -m user:usuario:rw fichero
70/71
Nota: Para ver en tiempo real en una consola lo que pasa por syslog usar:
debian:/home/jose# tail -f /var/log/syslog
Nota : VirtualBox
Nota :MAYUSCULA + FLECHA IZQ + PAG ARRIBA -- > Voy para arriba en la
consola de texto
Nota: ALT+CONTROL+F1 : Nos lleva a la consola de texto
ALT+F7: Vuelve al entorno Xwindow
TRUCO: Para tener raton el la consola instalar paquete apt-get install gpm
71/71