🧪 Micro-Lab: Navegacion y manipulacion
🎯 1. Objetivo y Escenario
Crear una infraestructura de simulación de logs.
-
Navegación: Ve a tu directorio
homey crea una carpeta llamadaBridget_Test. -
Expansión de Llaves (Brace Expansion): Dentro de
Bridget_Test, crea de un solo golpe la siguiente estructura:logs/nginx,logs/auth,scripts/backup,data/db. -
Manipulación de Timestamps: En
logs/nginx, crea 3 archivos:access.log,error.logydebug.log. -
Simulación de Antigüedad: Cambia la fecha de
access.logal 10 de enero de 2024. -
Verificación: Lista el contenido de
logs/nginxmostrando el tamaño en formato humano, los inodos y ordenados por fecha de modificación.
💻 2. Ejecución (Comandos/Código)
cd ~
mkdir -pv Bridget_Test
cd Bridget_Test
mkdir -pv logs/{nginx,auth}/ scripts/backup data/db
cd logs/nginx/
touch access.log error.log debug.log
touch -md "2024-01-10" access.log
ls -lahti
📸 3. Evidencia (Output)
jhoel@bridget:~$ pwd
/home/jhoel
jhoel@bridget:~$ cd /home/
jhoel@bridget:/home$ ls -l
total 4
drwx------ 19 jhoel jhoel 4096 feb 28 16:37 jhoel
jhoel@bridget:/home$ mkdir -pv Bridget_Test
mkdir: cannot create directory ‘Bridget_Test’: Permiso denegado
jhoel@bridget:/home$ de jhoel/
-bash: de: orden no encontrada
jhoel@bridget:/home$ cd jhoel/
jhoel@bridget:~$ mkdir -pv Bridget_Test
mkdir: se ha creado el directorio 'Bridget_Test'
jhoel@bridget:~$ cd Bridget_Test/
jhoel@bridget:~/Bridget_Test$ mkdir -pv logs/{nginx,auth}/ scripts/backup data/db
mkdir: se ha creado el directorio 'logs'
mkdir: se ha creado el directorio 'logs/nginx/'
mkdir: se ha creado el directorio 'logs/auth/'
mkdir: se ha creado el directorio 'scripts'
mkdir: se ha creado el directorio 'scripts/backup'
mkdir: se ha creado el directorio 'data'
mkdir: se ha creado el directorio 'data/db'
jhoel@bridget:~/Bridget_Test$ ls -Ral
.:
total 20
drwxrwxr-x 5 jhoel jhoel 4096 feb 28 16:40 .
drwx------ 20 jhoel jhoel 4096 feb 28 16:38 ..
drwxrwxr-x 3 jhoel jhoel 4096 feb 28 16:40 data
drwxrwxr-x 4 jhoel jhoel 4096 feb 28 16:40 logs
drwxrwxr-x 3 jhoel jhoel 4096 feb 28 16:40 scripts
./data:
total 12
drwxrwxr-x 3 jhoel jhoel 4096 feb 28 16:40 .
drwxrwxr-x 5 jhoel jhoel 4096 feb 28 16:40 ..
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:40 db
./data/db:
total 8
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:40 .
drwxrwxr-x 3 jhoel jhoel 4096 feb 28 16:40 ..
./logs:
total 16
drwxrwxr-x 4 jhoel jhoel 4096 feb 28 16:40 .
drwxrwxr-x 5 jhoel jhoel 4096 feb 28 16:40 ..
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:40 auth
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:40 nginx
./logs/auth:
total 8
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:40 .
drwxrwxr-x 4 jhoel jhoel 4096 feb 28 16:40 ..
./logs/nginx:
total 8
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:40 .
drwxrwxr-x 4 jhoel jhoel 4096 feb 28 16:40 ..
./scripts:
total 12
drwxrwxr-x 3 jhoel jhoel 4096 feb 28 16:40 .
drwxrwxr-x 5 jhoel jhoel 4096 feb 28 16:40 ..
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:40 backup
./scripts/backup:
total 8
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:40 .
drwxrwxr-x 3 jhoel jhoel 4096 feb 28 16:40 ..
jhoel@bridget:~/Bridget_Test$ cd logs/nginx/
jhoel@bridget:~/Bridget_Test/logs/nginx$ ls
jhoel@bridget:~/Bridget_Test/logs/nginx$ touch access.log error.log debug.log
jhoel@bridget:~/Bridget_Test/logs/nginx$ ls
access.log debug.log error.log
jhoel@bridget:~/Bridget_Test/logs/nginx$ ls -la
total 8
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:44 .
drwxrwxr-x 4 jhoel jhoel 4096 feb 28 16:40 ..
-rw-rw-r-- 1 jhoel jhoel 0 feb 28 16:44 access.log
-rw-rw-r-- 1 jhoel jhoel 0 feb 28 16:44 debug.log
-rw-rw-r-- 1 jhoel jhoel 0 feb 28 16:44 error.log
jhoel@bridget:~/Bridget_Test/logs/nginx$ touch -md "2024-01-10"
touch: falta un fichero como operando
Pruebe 'touch --help' para más información.
jhoel@bridget:~/Bridget_Test/logs/nginx$ touch -md "2024-01-10 00:00"
touch: falta un fichero como operando
Pruebe 'touch --help' para más información.
jhoel@bridget:~/Bridget_Test/logs/nginx$ touch -md "2024-01-10" access.log
jhoel@bridget:~/Bridget_Test/logs/nginx$ ls -la
total 8
drwxrwxr-x 2 jhoel jhoel 4096 feb 28 16:44 .
drwxrwxr-x 4 jhoel jhoel 4096 feb 28 16:40 ..
-rw-rw-r-- 1 jhoel jhoel 0 ene 10 2024 access.log
-rw-rw-r-- 1 jhoel jhoel 0 feb 28 16:44 debug.log
-rw-rw-r-- 1 jhoel jhoel 0 feb 28 16:44 error.log
jhoel@bridget:~/Bridget_Test/logs/nginx$ ls -lahti
total 8,0K
395851 drwxrwxr-x 2 jhoel jhoel 4,0K feb 28 16:44 .
395865 -rw-rw-r-- 1 jhoel jhoel 0 feb 28 16:44 debug.log
395862 -rw-rw-r-- 1 jhoel jhoel 0 feb 28 16:44 error.log
395850 drwxrwxr-x 4 jhoel jhoel 4,0K feb 28 16:40 ..
395861 -rw-rw-r-- 1 jhoel jhoel 0 ene 10 2024 access.log
jhoel@bridget:~/Bridget_Test/logs/nginx$
🧠 4. Lección Aprendida
Memorizar es bueno, pero es mejor aprender por la practica, ya que ahi vez en donde estan tus errores.
⚠️ 5. Errores y Obstáculos (Troubleshooting)
- Error: - Solución:
- falta un fichero como operando - agregar el fichero en el comando o si no el comando no sabe a quien deseas darle el time stamp.
- agregar la hora en
"2024-01-10 00:00"- resulta que no es necesario - ejecutar mkdir en /home/ - un error estupido, ya que para hacerlo necesito los permisos