Guía Yum en Fedora
Archivo de la etiqueta: Linux
Linux Change Hostname
How do I change hostname under Linux operating system?
You need to use the hostname command. It is used to either set or display the current host or domain name of the system. The hostname is used by many of the networking programs (such as sendmail, Apache servers) to identify the machine.
Display Hostname
Type the following command:
hostname
Sample ouputs:
server.nixcraft.net.in
Step # 1: Change Hostname
You need to update two files:
- Linux Distribution specific file. Edit appropriate file as per your distribution as follows.
- /etc/hosts
Redhat / CentOS / Fedora: Change Hostname
Edit /etc/sysconfig/network, enter:
vi /etc/sysconfig/network
Set HOSTNAME=newhost.example.com, enter:
HOSTNAME=server2.nixcraft.com
Save and close the file. Type the following command:
hostname server2.nixcraft.com hostname
Now, proceed to step # 2.
Debian / Ubuntu: Change Hostname
Edit, /etc/hostname file, enter:
vi /etc/hostname
Delete old name and add new name:
server2.nixcraft.com
Save and close the file. Type the following command:
hostname server2.nixcraft.com hostname
Now, proceed to step # 2.
Slackware: Change Hostname
Edit /etc/HOSTNAME, enter:
vi /etc/HOSTNAME
Delete old name and add new one:
server2.nixcraft.com
Save and close the file. Type the following command:
hostname server2.nixcraft.com hostname
Now, proceed to step # 2.
Suse / OpenSuse: Change Hostname
Edit /etc/HOSTNAME, enter:
Delete old name and add new one:
server2.nixcraft.com
Save and close the file. Type the following command:
hostname server2.nixcraft.com hostname
Now, proceed to step # 2.
Step #2: Update /etc/hosts
Now, you need to edit /etc/hosts file, enteR:
vi /etc/hosts
Change all old hostname with newer one.
Permanent hostname change on RedHat based systems
RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot. This is set using the init script /etc/rc.d/rc.sysinit
/etc/sysconfig/network
NETWORKING=yes
HOSTNAME="plain.domainname.com"
GATEWAY="192.168.0.1"
GATEWAYDEV="eth0"
FORWARD_IPV4="yes"
Comando find
Para localizar archivos con un nombre especifico desde un ruta especifica en toda la estructura interna de carpetas se utiliza:
find /home -iname 'archivo.txt'
Este comando se puede utilizar para borrar el archivo 'archivo.txt' de forma recursiva en toda la estructura de directorios que se esta especificando.
find /home -iname 'archivo.txt' | xargs rm -rfv
Comando du
Este comando informa al usuario de la cantidad de almacenamiento utilizado por los archivos especificados, posee varias opciones, su sintaxis es la siguiente:
du [opciones] [archivo...]
Sus opciones más significativas son:
-s
Muestra únicamente los tamaños de los archivos especificados en la línea de comandos.
-h
Muestra los tamaños de archivo en un formato más legible.
-c
Muestra en pantalla el espacio total ocupado por los archivos especificados.
-x
Omite en el conteo aquellos directorios que pertenezcan a otro sistema de archivos.
Ejemplo 8. Uso administrativo del comando du
El administrador de un servidor necesita saber el espacio en disco ocupado por los distintos directorios del sistema, para hacer limpieza. Para esto, se tiene en cuenta que no se deberán contar aquellos directorios que estén en su propio sistema de archivos, entonces se puede ejecutar de esta forma:
# du -sxh /*
6.8M /bin
6.7M /boot
351k /dev
34M /etc
2.8G /home
43M /lib
3.0k /mnt
0 /proc
15M /root
7.3M /sbin
512 /swap
281k /tmp
5.3G /usr
758M /var