bash https://keopx.net/ es Exploring .img Files on Linux and create your custom one https://keopx.net/blog/exploring-img-files-linux-and-create-your-custom-one <span>Exploring .img Files on Linux and create your custom one</span> <div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"><ul><li>Discover the hidden secrets of a monolithic <code>.img</code> file</li> <li>Mount the partitions in an <code>.img</code> file using <code>losetup</code>, <code>kpartx</code> and <code>mount</code></li> <li>Create your own <code>.img</code> files and use them as virtual disks</li> <li>Write out your virtual disk image to a thumb drive (or any drive for that matter) for use later</li> </ul><h2>Install packages</h2> <p><code>$ sudo aptitude install kpartx xz-utils</code></p> <h2>Decompress image</h2> <p>Once its downloaded you will want to uncompress it with <code>xz --decompress</code>:</p> <p><code>$ xz --decompress Retrobro128KillerHomeConsole.img.img.xz</code></p> <h2>Mount image</h2> <p>We’re going to attach the image file to what is known as a <a href="https://web.archive.org/web/20210118104618/https://en.wikipedia.org/wiki/Loop_device">loopback device</a>.</p> <p><code>$ sudo losetup /dev/loop0 Retrobro128KillerHomeConsole.img</code></p> <p>Note: We used <code>/dev/loop0</code> in this example. If <code>/dev/loop0</code> wasn’t available to us (that is, it was already in use), we could have chosen <code>/dev/loop1</code>, etc.</p> <p><code>$ sudo losetup -a /dev/loop0: [65026]:28970069 (/home/keopx/Retrobro128KillerHomeConsole.img)</code></p> <p>Now <code>/dev/loop0</code> is attached. How about look at the partition table with <code>fdisk</code>?</p> <p><code>$ sudo fdisk -l /dev/loop0 Disco /dev/loop0: 119,8 GiB, 128579534848 bytes, 251131904 sectores Unidades: sectores de 1 * 512 = 512 bytes Tamaño de sector (lógico/físico): 512 bytes / 512 bytes Tamaño de E/S (mínimo/óptimo): 512 bytes / 512 bytes Tipo de etiqueta de disco: dos Identificador del disco: 0xf2d3cb4f Disposit. Inicio Comienzo Final Sectores Tamaño Id Tipo /dev/loop0p1 * 8192 124927 116736 57M e W95 FAT16 (LBA) /dev/loop0p2 124928 251131903 251006976 119,7G 83 Linux </code></p> <p>To see what <code>kpartx</code> <em>would</em> map, run it with the <code>-l</code> option:</p> <p><code>$ sudo kpartx -l /dev/loop0 loop0p1 : 0 116736 /dev/loop0 8192 loop0p2 : 0 251006976 /dev/loop0 124928</code></p> <p>Let’s go ahead and run it and add the maps:</p> <p><code>$ sudo kpartx -a /dev/loop0 </code></p> <p>Now you can see new devices on <strong>dolphin</strong>.</p> <p>Running a shell:</p> <p>Now that the partitions are mapped, let’s examine the filesystems on each partition with <code>file</code> and the <code>--special-files</code> and <code>--dereference</code> options.</p> <p><code>$ sudo file -sL /dev/mapper/loop0p1 /dev/mapper/loop0p1: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "mkfs.fat", sectors/cluster 4, reserved sectors 4, root entries 512, Media descriptor 0xf8, sectors/FAT 116, sectors/track 32, heads 64, sectors 116736 (volumes &gt; 32 MB), serial number 0xb13de1e5, label: "boot ", FAT (16 bit)</code></p> <p><code>$ sudo file -sL /dev/mapper/loop0p2 /dev/mapper/loop0p2: Linux rev 1.0 ext4 filesystem data, UUID=c50e928e-5669-44d0-8e3c-a59d21ad3da2, volume name "retropie" (extents) (64bit) (large files) </code></p> <p>Now that we have our partitions mapped, we can mount them. Create two directories to serve as mountpoints:</p> <p><code>$ mkdir boot # We will mount the FAT partition here $ mkdir retropie # We will mount the ext4 partition here</code></p> <p>Once they are created, <code>mount</code> the filesystems (only system in my case).</p> <p><code>$ sudo mount /dev/mapper/loop0p2 retropie</code></p> <h2>Umount image</h2> <p>Once you are done and want to “let go” of the <code>.img</code> file, reverse the process with:</p> <p><code>$ sudo umount retropie $ sudo kpartx -d /dev/loop0 $ sudo losetup -d /dev/loop0</code></p> <p>Reference:</p> <ul><li><a href="https://web.archive.org/web/20210118104618/https://dev.iachieved.it/iachievedit/exploring-img-files-on-linux/">https://dev.iachieved.it/iachievedit/exploring-img-files-on-linux/</a></li> </ul></div> <span><span>keopx</span></span> <span><time datetime="2019-12-26T11:50:37+01:00" title="Jueves, Diciembre 26, 2019 - 11:50">Jue, 26/12/2019 - 11:50</time> </span> <div class="field field--name-field-tax-cat field--type-entity-reference field--label-above"> <div class="field__label">Categoria</div> <div class="field__items"> <div class="field__item"><a href="/categoria/debian-10" hreflang="es">Debian 10</a></div> <div class="field__item"><a href="/categoria/raspberry-pi" hreflang="es">Raspberry pi</a></div> </div> </div> <div class="field field--name-field-tax-tag field--type-entity-reference field--label-above"> <div class="field__label">Tag</div> <div class="field__items"> <div class="field__item"><a href="/tag/bash" hreflang="es">bash</a></div> <div class="field__item"><a href="/tag/terminal" hreflang="es">Terminal</a></div> <div class="field__item"><a href="/tag/consola" hreflang="es">consola</a></div> </div> </div> <section data-drupal-selector="comments" class="comments"> <h2 class="comments__title">Comentarios</h2> <div class="add-comment"> <div class="add-comment__form"> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=308&amp;2=field_comments&amp;3=comment" token="O6DJWUhWDSOQytsmVQ9idBx3ufl7Pw7sSFZCnZvlKQU"></drupal-render-placeholder> </div> </div> </section> Thu, 26 Dec 2019 10:50:37 +0000 keopx 308 at https://keopx.net Cargar cambios en bash_profile sin necesidad de salir y entrar en el sistema https://keopx.net/blog/cargar-cambios-en-bashprofile-sin-necesidad-de-salir-y-entrar-en-el-sistema <span>Cargar cambios en bash_profile sin necesidad de salir y entrar en el sistema</span> <div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"><div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item quickedit-field" data-quickedit-field-id="node/204/body/es/full"> <p>Los comandos que contiene son leídos y ejecutados en <em>.bash_profile</em> cada vez que el usuario entra en el sistema.</p> <p>Cualquier cambio hecho en este fichero no tendrá efecto hasta que salgamos y entremos en el sistema de nuevo.</p> <p>Una alternativa para no tener que salir del sistema es ejecutar el siguiente comando:</p> <pre> <code class="language-bash">source .bash_profile</code></pre><p> </p> </div> </div> <span><span>keopx</span></span> <span><time datetime="2010-12-20T10:40:41+01:00" title="Lunes, Diciembre 20, 2010 - 10:40">Lun, 20/12/2010 - 10:40</time> </span> <div class="field field--name-field-tax-cat field--type-entity-reference field--label-above"> <div class="field__label">Categoria</div> <div class="field__items"> <div class="field__item"><a href="/categoria/gnu-linux" hreflang="es">GNU Linux</a></div> </div> </div> <div class="field field--name-field-tax-tag field--type-entity-reference field--label-above"> <div class="field__label">Tag</div> <div class="field__items"> <div class="field__item"><a href="/tag/bash" hreflang="es">bash</a></div> <div class="field__item"><a href="/tag/consola" hreflang="es">consola</a></div> <div class="field__item"><a href="/tag/terminal" hreflang="es">Terminal</a></div> </div> </div> <section data-drupal-selector="comments" class="comments"> <h2 class="comments__title">Comentarios</h2> <div class="add-comment"> <div class="add-comment__form"> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=204&amp;2=field_comments&amp;3=comment" token="HCafKj4s_9bFhPahhmYoXlEO6bAKb0aQ63ZpgnKbkAw"></drupal-render-placeholder> </div> </div> </section> Mon, 20 Dec 2010 09:40:41 +0000 keopx 204 at https://keopx.net https://keopx.net/blog/cargar-cambios-en-bashprofile-sin-necesidad-de-salir-y-entrar-en-el-sistema#comments Redimensionar imagenes de forma automatica a un tamaño definido https://keopx.net/blog/redimensionar-imagenes-de-forma-automatica-un-tamano-definido <span>Redimensionar imagenes de forma automatica a un tamaño definido</span> <div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Script para redimensionar imágenes de forma automática.</p> <pre lang="bash" line="1" xml:lang="bash"> #! /bin/sh # ------------------------------------------------------------------------- # GNU GENERAL PUBLIC LICENSE # Version 3, 29 June 2007 # # Copyright (C) 2007 Free Software Foundation, Inc. # Everyone is permitted to copy and distribute verbatim copies # of this license document, but changing it is not allowed. # ------------------------------------------------------------------------- # Datos fijos TAMAINAMAX=1024 TAMAINAX=1024x TAMAINAY=x1024 NOW=$(date +"%Y-%m-%d") # Formato yyyy-mm-dd CARPETA="/var/www/imagenes" # Carpeta de imagenes BAK="/backups_aiaraldea/${NOW}" # Primero las copias de seguridad cp -r $CARPETA $BAK # Cambiamos al tamaño máximo definido, en este caso 1024px cd $KARPETA # JPG for img in `ls *.jpg` do # Obtener anchura y altura: TAMAINA_ZABALERA=`identify -format "%w" $img` TAMAINA_ALTUERA=`identify -format "%h" $img` # Compara que es mayor si altula o la achura if [ $TAMAINA_ALTUERA -gt $TAMAINA_ZABALERA ]; then # Altura if [ $TAMAINA_ALTUERA -gt $TAMAINAMAX ]; then convert -resize $TAMAINAY $img $img fi else # Anchura if [ $TAMAINA_ZABALERA -gt $TAMAINAMAX ]; then convert -resize $TAMAINAX $img $img fi fi done </pre></div> <span><span>keopx</span></span> <span><time datetime="2010-06-30T16:21:59+02:00" title="Miércoles, Junio 30, 2010 - 16:21">Mié, 30/06/2010 - 16:21</time> </span> <div class="field field--name-field-tax-cat field--type-entity-reference field--label-above"> <div class="field__label">Categoria</div> <div class="field__items"> <div class="field__item"><a href="/categoria/gnu-linux" hreflang="es">GNU Linux</a></div> <div class="field__item"><a href="/categoria/sistemas" hreflang="es">Sistemas</a></div> </div> </div> <div class="field field--name-field-tax-tag field--type-entity-reference field--label-above"> <div class="field__label">Tag</div> <div class="field__items"> <div class="field__item"><a href="/tag/bash" hreflang="es">bash</a></div> <div class="field__item"><a href="/tag/sistemas" hreflang="es">Sistemas</a></div> <div class="field__item"><a href="/tag/consola" hreflang="es">consola</a></div> </div> </div> <section data-drupal-selector="comments" class="comments"> <h2 class="comments__title">Comentarios</h2> <div class="add-comment"> <div class="add-comment__form"> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=188&amp;2=field_comments&amp;3=comment" token="A3JPE0EH0GiTJXPOWFgs9KRAO13wAwErZ2-yUYPjXkA"></drupal-render-placeholder> </div> </div> </section> Wed, 30 Jun 2010 14:21:59 +0000 keopx 188 at https://keopx.net https://keopx.net/blog/redimensionar-imagenes-de-forma-automatica-un-tamano-definido#comments Controlar el disco duro con smartmontools en Debiab/Ubuntu https://keopx.net/blog/controlar-el-disco-duro-con-smartmontools-en-debiabubuntu <span>Controlar el disco duro con smartmontools en Debiab/Ubuntu</span> <div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"><div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item quickedit-field" data-quickedit-field-id="node/185/body/es/full"> <p>Si se detecta un posible fallo en el disco duro (HD) que nos pudiera dar más fallos tenemos la posibilidad de saber del estado del HD para cambiarlo antes de que se nos termine de "morir".</p> <p>Para ello es necesario instalar smartmontools:</p> <pre> <code class="language-bash">sudo aptitude install smartmontools</code></pre><p>Activamos la monitorización de discos:</p> <pre> <code class="language-bash">sudo smartctl -s on /dev/sda</code></pre><p><em>Deberás cambiar </em><strong>sda</strong><em> por el nombre de tu dispositivo.</em></p> <p>Controlar el estado de salud actual:</p> <pre> <code class="language-bash">smartctl -H /dev/sda</code></pre><p>Para obtener toda la información del disco:</p> <pre> <code class="language-bash">smartctl -a /dev/sda</code></pre><p>Estado del disco:</p> <pre> <code class="language-bash">smartctl -l selftest /dev/sda</code></pre><p>Referencia:</p> <ul><li><a href="http://www.esdebian.org/articulos/24191/smartmontools-controlemos-nuestro-hd">http://www.esdebian.org/articulos/24191/smartmontools-controlemos-nuestro-hd</a></li> </ul></div> </div> <span><span>keopx</span></span> <span><time datetime="2010-06-27T15:55:32+02:00" title="Domingo, Junio 27, 2010 - 15:55">Dom, 27/06/2010 - 15:55</time> </span> <div class="field field--name-field-tax-cat field--type-entity-reference field--label-above"> <div class="field__label">Categoria</div> <div class="field__items"> <div class="field__item"><a href="/categoria/gnu-linux" hreflang="es">GNU Linux</a></div> <div class="field__item"><a href="/categoria/sistemas" hreflang="es">Sistemas</a></div> </div> </div> <div class="field field--name-field-tax-tag field--type-entity-reference field--label-above"> <div class="field__label">Tag</div> <div class="field__items"> <div class="field__item"><a href="/tag/bash" hreflang="es">bash</a></div> <div class="field__item"><a href="/tag/consola" hreflang="es">consola</a></div> </div> </div> <section data-drupal-selector="comments" class="comments"> <h2 class="comments__title">Comentarios</h2> <div class="add-comment"> <div class="add-comment__form"> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=185&amp;2=field_comments&amp;3=comment" token="8BL2DWF7t4CnH9BS_z3Bv8Ig1hdiV9EpM6CaSH4bz4Y"></drupal-render-placeholder> </div> </div> </section> Sun, 27 Jun 2010 13:55:32 +0000 keopx 185 at https://keopx.net https://keopx.net/blog/controlar-el-disco-duro-con-smartmontools-en-debiabubuntu#comments Autocompletar con Bash en Ubuntu/Debian https://keopx.net/blog/autocompletar-con-bash-en-ubuntudebian <span>Autocompletar con Bash en Ubuntu/Debian</span> <div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Para activar el autocompletado en Ubuntu o Debian es necesario el realizar los siguientes pasos. Instalar el paquete para autocompletado:</p> <pre> <code class="language-bash">$ sudo aptitude install bash-completion</code></pre><p>Editamos el fichero para bash:</p> <pre> <code class="language-bash">$ sudo nano /etc/profile</code></pre><p>Después es necesario descomentar la siguiente linea:</p> <pre> <code class="language-bash">if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi </code></pre><p>Guardaremos con Control+O después enter y cerraremos con Control+X seguido pulsamos enter.</p> </div> <span><span>keopx</span></span> <span><time datetime="2010-04-11T10:00:38+02:00" title="Domingo, Abril 11, 2010 - 10:00">Dom, 11/04/2010 - 10:00</time> </span> <div class="field field--name-field-tax-cat field--type-entity-reference field--label-above"> <div class="field__label">Categoria</div> <div class="field__items"> <div class="field__item"><a href="/categoria/gnu-linux" hreflang="es">GNU Linux</a></div> </div> </div> <div class="field field--name-field-tax-tag field--type-entity-reference field--label-above"> <div class="field__label">Tag</div> <div class="field__items"> <div class="field__item"><a href="/tag/consola" hreflang="es">consola</a></div> <div class="field__item"><a href="/tag/terminal" hreflang="es">Terminal</a></div> <div class="field__item"><a href="/tag/bash" hreflang="es">bash</a></div> </div> </div> <section data-drupal-selector="comments" class="comments"> <h2 class="comments__title">Comentarios</h2> <div class="add-comment"> <div class="add-comment__form"> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=171&amp;2=field_comments&amp;3=comment" token="DfBfnIR70D0TJDktofI9ZjQd2S13JcLx-bAUdbayt_g"></drupal-render-placeholder> </div> </div> </section> Sun, 11 Apr 2010 08:00:38 +0000 keopx 171 at https://keopx.net https://keopx.net/blog/autocompletar-con-bash-en-ubuntudebian#comments Añadir usuario a sudoers en Debian/Ubuntu https://keopx.net/blog/anadir-usuario-sudoers-en-debianubuntu <span>Añadir usuario a sudoers en Debian/Ubuntu</span> <div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"><div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item quickedit-field" data-quickedit-field-id="node/170/body/es/full"> <p>Si queremos que un usuario tenga permisos para ejecutar tareas de root es necesario el añadir el usuario a la lista de sudoers. En el caso de Debian es necesario el instalar el paquete sudo.</p> <p>Debian:</p> <pre> <code class="language-bash">$ su $ aptitude install sudo</code></pre><p>En Ubuntu ya estaría instalado.</p> <p>Una vez instalado el paquete podemos proceder de las 2 formas siguientes:</p> <pre> <code class="language-bash">$ visudo</code></pre><p>o</p> <pre> <code class="language-bash">$ nano /etc/sudoers</code></pre><p>Nos saldrá la pagina correspondiente y añadimos el usuario dejándolo así:</p> <pre> <code class="language-bash"># /etc/sudoers ... root ALL=(ALL) ALL new_user ALL=(ALL) ALL ...</code></pre><p> </p> </div> </div> <span><span>keopx</span></span> <span><time datetime="2010-03-27T18:09:48+01:00" title="Sábado, Marzo 27, 2010 - 18:09">Sáb, 27/03/2010 - 18:09</time> </span> <div class="field field--name-field-tax-cat field--type-entity-reference field--label-above"> <div class="field__label">Categoria</div> <div class="field__items"> <div class="field__item"><a href="/categoria/sistemas" hreflang="es">Sistemas</a></div> <div class="field__item"><a href="/categoria/gnu-linux" hreflang="es">GNU Linux</a></div> </div> </div> <div class="field field--name-field-tax-tag field--type-entity-reference field--label-above"> <div class="field__label">Tag</div> <div class="field__items"> <div class="field__item"><a href="/tag/bash" hreflang="es">bash</a></div> <div class="field__item"><a href="/tag/sistemas" hreflang="es">Sistemas</a></div> <div class="field__item"><a href="/tag/consola" hreflang="es">consola</a></div> <div class="field__item"><a href="/tag/terminal" hreflang="es">Terminal</a></div> </div> </div> <section data-drupal-selector="comments" class="comments"> <h2 class="comments__title">Comentarios</h2> <div class="add-comment"> <div class="add-comment__form"> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=170&amp;2=field_comments&amp;3=comment" token="BNPE9fIBnc7h5NKFek_a8c0KlMb2sQ6Xmz7qCGRm3i4"></drupal-render-placeholder> </div> </div> </section> Sat, 27 Mar 2010 17:09:48 +0000 keopx 170 at https://keopx.net https://keopx.net/blog/anadir-usuario-sudoers-en-debianubuntu#comments