List of commands for Android Terminal Emulator GNU LINUX DEBIAN

Table of Contents
  1. Essential commands to use it
  2. System information
  3. Shutdown (System Reboot or Logout)
  4. Files and Directories
  5. Find files
  6. Mounting a file system
  7. Disk Space
  8. Users and Groups
  9. Permisos en Ficheros (Usa ”+” para colocar permisos y ”-” para eliminar)
  10. Atributos especiales en ficheros (Usa ”+” para colocar permisos y ”-” para eliminar)
  11. Compressed files and archives
  12. RPM packages (Red Hat, Fedora and similar)
  13. YUM package updater (Red Hat, Fedora and similar)
  14. Deb packages (Debian, Ubuntu and derivatives)
  15. APT package updater (Debian, Ubuntu and derivatives)
  16. View the contents of a file
  17. Text manipulation
  18. Set character and file conversion
  19. File system analysis
  20. Formatting a file system
  21. Working with SWAP
  22. Salvas (Backup)
  23. CD-ROM
  24. Networking (LAN and Wi-Fi)
  25. Microsoft Windows Networks (SAMBA)
  26. IP Boards (FIREWALLS)
  27. Monitoring and debugging
  28. Other useful commands

kali linux

Cómo utilizar el terminal de Linux en Android

Essential commands to use it

Let's see some commands that we can use.

your – Obtener derechos root
cd – Cambiar directorios
Uname -a – Obtener información sobre la arquitectura.
exit – Salir del shell.
ls – Lista el contenido del directorio.
chmod – Cambia permisos.
tar – Crea archivos comprimidos.

Muchos de los famosos comandos de Linux que usas diariamente en terminal funcionan muy bien en Android también, debido al Núcleo de Linux.

super user command in android

run terminal ls command in android

run linux commands in android terminal

running termux in android

Lo primero que veremos será el comando que hayamos configurado para que se ejecute nada más abrir la consola de comandos o el comando que viene por defecto con la aplicación. En la siguiente línea tenemos el Linu's promptx, el símbolo del dólar ‘$‘.

First of all, what we need to do is to access the root or Linux superuser by the Console, with the comando de Linux “su”. Pero antes tenemos que acceder al teclado, para ello pulsamos la tecla Menú de nuestro Android y pulsáis en “Toggle soft Keyboard”. Ya aparece nuestro teclado y podemos teclear el comando y retorno de carro.
$ su

El prompt de la consola de comandos de Linux cambiará al símbolo de almohadilla ‘#‘. Ya estamos como superusuario (root). A partir de ahora great care, que las balas cargadas ya son de verdad. Creamos en nuestra tarjeta de memoria la carpeta “efs”, con el comando “mkdir”:
#mkdir /sdcard/efs

Y con el siguiente comando copiamos la carpeta “efs” de nuestro Android, con todas las subcarpetas, a la carpeta “efs” de la tarjeta de memoria. Para ello utilizamos el comando “cp” con la opción “-r”.
#cp -r /efs/* /sdcard/efs

Ready, we can now enter the /sdcard/efs folder:
#cd /sdcard/efs
and see the content we have copied:
ls -l

Esto es un pequeño ejemplo de todo lo que se puede hacer con la Linux Command Console on Android. Coméntanos tus consejos o trucos que sueles utilizar.

System information

  1. arch: mostrar la arquitectura de la máquina (1).
  2. uname -m: mostrar la arquitectura de la máquina (2).
  3. uname -r: mostrar la versión del kernel usado.
  4. dmidecode -q: display the (hardware) components of the system.
  5. hdparm -i /dev/hda: mostrar las características de un disco duro.
  6. hdparm -tT /dev/sda: perform a read test on a hard disk.
  7. cat /proc/cpuinfo: mostrar información de la CPU.
  8. cat /proc/interrupts: show the interruptions.
  9. cat /proc/meminfoCheck the memory usage.
  10. cat /proc/swapsshow swap files.
  11. cat /proc/version: mostrar la versión del kernel.
  12. cat /proc/net/dev: mostrar adaptadores de red y estadísticas.
  13. cat /proc/mounts: show the mounted file system.
  14. lspci -tvPCI devices: display the PCI devices.
  15. lsusb -tvUSB devices: display the USB devices.
  16. date: display the system date.
  17. lime 2011display the 2011 almanac.
  18. cal 07 2011Show the almanac for the month of July 2011.
  19. date 041217002011.00: set (declare, adjust) date and time.
  20. clock -wSave date changes in the BIOS.

Shutdown (System Reboot or Logout)

  1. shutdown -h now: shut down the system (1).
  2. init 0: shut down the system (2).
  3. telinit 0: turn off the system (3).
  4. halt: turn off the system (4).
  5. shutdown -h hours:minutes &planned system shutdown.
  6. shutdown -cCancel a planned system shutdown.
  7. shutdown -r now: restart (1).
  8. reboot: restart (2).
  9. logout: cerrar sesión.

Files and Directories

  1. cd /home: entrar en el directorio “home”.
  2. cd ...: go back one level.
  3. cd ../...: go back 2 levels.
  4. cd: ir al directorio raíz.
  5. cd ~user1go to the user1 directory.
  6. cd –: go (return) to the previous directory.
  7. pwd: show the path to the working directory.
  8. ls: view the files in a directory.
  9. ls -F: view the files in a directory.
  10. ls -l: show the details of files and folders in a directory.
  11. ls -a: show hidden files.
  12. ls *[0-9]*: mostrar los ficheros y carpetas que contienen números.
  13. tree: mostrar los ficheros y carpetas en forma de árbol comenzando por la raíz.(1)
  14. lstree: mostrar los ficheros y carpetas en forma de árbol comenzando por la raíz.(2)
  15. mkdir dir1: crear una carpeta o directorio con nombre ‘dir1’.
  16. mkdir dir1 dir2: crear dos carpetas o directorios simultáneamente (Crear dos directorios a la vez).
  17. mkdir -p /tmp/dir1/dir2: crear un árbol de directorios.
  18. rm -f file1: borrar el fichero llamado ‘file1’.
  19. rmdir dir1: borrar la carpeta llamada ‘dir1’.
  20. rm -rf dir1: eliminar una carpeta llamada ‘dir1’ con su contenido de forma recursiva. (Si lo borro recursivo estoy diciendo que es con su contenido).
  21. rm -rf dir1 dir2delete two folders (directories) with their contents recursively.
  22. mv dir1 new_dirrename or move a file or folder (directory).
  23. cp file1: copy a file.
  24. cp file1 file2: copiar dos ficheros al unísono.
  25. cp dir /* .copy all files of a directory into the current working directory.
  26. cp -a /tmp/dir1 .Copy a directory into the current working directory.
  27. cp -a dir1: copy a directory.
  28. cp -a dir1 dir2: copiar dos directorio al unísono.
  29. ln -s file1 lnk1: crear un enlace simbólico al fichero o directorio.
  30. ln file1 lnk1: crear un enlace físico al fichero o directorio.
  31. touch -t 0712250000 file1: modificar el tiempo real (tiempo de creación) de un fichero o directorio.
  32. file file1mime type output (screen dump) of a text file.
  33. iconv -llists of known ciphers.
  34. iconv -f fromEncoding -t toEncoding inputFile > outputFile: crea una nueva forma del fichero de entrada asumiendo que está codificado en fromEncoding y convirtiéndolo a ToEncoding.
  35. find . -maxdepth 1 -name *.jpg -print -exec convert ”{}” -resize 80×60 “thumbs/{}” \;: group resized files in the current directory and send them to directories in thumbnail views (requires conversion from ImagemagicK).

Find files

  1. find / -name file1: buscar fichero y directorio a partir de la raíz del sistema.
  2. find / -user user1: buscar ficheros y directorios pertenecientes al usuario ‘user1’.
  3. find /home/user1 -name \*.bin: buscar ficheros con extensión ‘. bin’ dentro del directorio ‘/ home/user1’.
  4. find /usr/bin -type f -atime +100: buscar ficheros binarios no usados en los últimos 100 días.
  5. find /usr/bin -type f -mtime -10: buscar ficheros creados o cambiados dentro de los últimos 10 días.
  6. find / -name \*.rpm -exec chmod 755 ‘{}’ \;: buscar ficheros con extensión ‘.rpm’ y modificar permisos.
  7. find / -xdev -name \*.rpm: Buscar ficheros con extensión ‘.rpm’ ignorando los dispositivos removibles como cdrom, pen-drive, etc.…
  8. locate \*.ps: encuentra ficheros con extensión ‘.ps’ ejecutados primeramente con el command ‘updatedb’.
  9. whereis halt: mostrar la ubicación de un fichero binario, de ayuda o fuente. En este caso pregunta dónde está el comando ‘halt’.
  10. which halt: show the complete path (the complete path) to a binary / executable.

Mounting a file system

  1. mount /dev/hda2 /mnt/hda2: montar un disco llamado hda2. Verifique primero la existencia del directorio ‘/ mnt/hda2’; si no está, debe crearlo.
  2. umount /dev/hda2: desmontar un disco llamado hda2. Salir primero desde el punto ‘/ mnt/hda2.
  3. fuser -km /mnt/hda2: forzar el desmontaje cuando el dispositivo está ocupado.
  4. umount -n /mnt/hda2: correr el desmontaje sin leer el fichero /etc/mtab. Útil cuando el fichero es de solo lectura o el disco duro está lleno.
  5. mount /dev/fd0 /mnt/floppy: mount a floppy disk.
  6. mount /dev/cdrom /mnt/cdrom: mount a cdrom / dvdrom.
  7. mount /dev/hdc /mnt/cdrecorder: mount a rewritable cd or a dvdrom.
  8. mount /dev/hdb /mnt/cdrecorder: mount a rewritable cd / dvdrom (a dvd).
  9. mount -o loop file.iso /mnt/cdrom: mount a file or an iso image.
  10. mount -t vfat /dev/hda5 /mnt/hda5Mount a FAT32 file system.
  11. mount /dev/sda1 /mnt/usbdisk: mount a usb pen-drive or a memory stick (without specifying the type of file system).

Disk Space

  1. df -hShow a list of mounted partitions.
  2. ls -lSr |more: mostrar el tamaño de los ficheros y directorios ordenados por tamaño.
  3. du -sh dir1: Estimar el espacio usado por el directorio ‘dir1’.
  4. du -sk * | sort -rn: mostrar el tamaño de los ficheros y directorios ordenados por tamaño.
  5. rpm -q -a –qf ‘%10{SIZE}t%{NAME}n’ | sort -k1,1n: mostrar el espacio usado por los paquetes rpm instalados organizados por tamaño (Fedora, Redhat y otros).
  6. dpkg-query -W -f=’${Installed-Size;10}t${Package}n’ | sort -k1,1n: mostrar el espacio usado por los paquetes instalados, organizados por tamaño (Ubuntu, Debian y otros).

Users and Groups

  1. groupadd group_name: create a new group.
  2. groupdel group_name: delete a group.
  3. groupmod -n new_group_name old_group_name: rename a group.
  4. useradd -c “Name Surname ” -g admin -d /home/user1 -s /bin/bash user1: Crear un nuevo usuario perteneciente al grupo “admin”.
  5. useradd user1: create a new user.
  6. userdel -r user1: borrar un usuario (‘-r’ elimina el directorio Home).
  7. usermod -c “User FTP” -g system -d /ftp/user1 -s /bin/nologin user1change the user's attributes.
  8. passwd: cambiar contraseña.
  9. passwd user1: cambiar la contraseña de un usuario (solamente por root).
  10. chage -E 2011-12-31 user1: colocar un plazo para la contraseña del usuario. En este caso dice que la clave expira el 31 de diciembre de 2011.
  11. pwck: chequear la sintaxis correcta el formato de fichero de ‘/etc/passwd’ y la existencia de usuarios.
  12. grpck: chequear la sintaxis correcta y el formato del fichero ‘/etc/group’ y la existencia de grupos.
  13. newgrp group_nameRegister a new group to change the default group for newly created files.

Permisos en Ficheros (Usa ”+” para colocar permisos y ”-” para eliminar)

  1. ls -lh: Show permissions.
  2. ls /tmp | pr -T5 -W$COLUMNS: divide the terminal into 5 columns.
  3. chmod ugo+rwx directory1: colocar permisos de lectura ®, escritura (w) y ejecución(x) al propietario (u), al grupo (g) y a otros (o) sobre el directorio ‘directory1’.
  4. chmod go-rwx directory1: quitar permiso de lectura ®, escritura (w) y (x) ejecución al grupo (g) y otros (o) sobre el directorio ‘directory1’.
  5. chown user1 file1: cambiar el dueño de un fichero.
  6. chown -R user1 directory1Change the owner of a directory and all the files and directories contained in it.
  7. chgrp group1 file1: change file group.
  8. chown user1:group1 file1: change user and group owner of a file.
  9. find / -perm -u+sSUID: display all files in the system with SUID configured.
  10. chmod u+s /bin/file1: colocar el bit SUID en un fichero binario. El usuario que corriendo ese fichero adquiere los mismos privilegios como dueño.
  11. chmod u-s /bin/file1Disable the SUID bit in a binary file.
  12. chmod g+s /home/public: colocar un bit SGID en un directorio –similar al SUID pero por directorio.
  13. chmod g-s /home/publicDisable an SGID bit in a directory.
  14. chmod o+t /home/public: colocar un bit STIKY en un directorio. Permite el borrado de ficheros solamente a los dueños legítimos.
  15. chmod o-t /home/publicDisable a STIKY bit in a directory.

Atributos especiales en ficheros (Usa ”+” para colocar permisos y ”-” para eliminar)

  1. chattr +a file1: allows you to write by opening a file in append mode only.
  2. chattr +c file1allows a file to be compressed / decompressed automatically.
  3. chattr +d file1: ensures that the program ignores deleting files during the backup.
  4. chattr +i file1makes the file unchangeable, so it cannot be deleted, altered, renamed, or linked.
  5. chattr +s file1allows a file to be securely deleted.
  6. chattr +S file1ensures that a file is modified, changes are written in synchronous mode as with sync.
  7. chattr +u file1: te permite recuperar el contenido de un fichero aún si este está cancelado.
  8. lsattrshow special attributes.

Compressed files and archives

  1. bunzip2 file1.bz2: descomprime in fichero llamado ‘file1.bz2’.
  2. bzip2 file1: comprime un fichero llamado ‘file1’.
  3. gunzip file1.gz: descomprime un fichero llamado ‘file1.gz’.
  4. gzip file1: comprime un fichero llamado ‘file1’.
  5. gzip -9 file1: comprime con compresión máxima.
  6. rar to file1.rar test_file: crear un fichero rar llamado ‘file1.rar’.
  7. rar a file1.rar file1 file1 file2 dir1: comprimir ‘file1’, ‘file2’ y ‘dir1’ simultáneamente.
  8. rar x file1.rar: unzip rar file.
  9. unrar x file1.rar: unzip rar file.
  10. tar -cvf archive.tar file1: create an unzipped tarball.
  11. tar -cvf archive.tar file1 file2 file2 dir1: crear un archivo conteniendo ‘file1’, ‘file2′ y’dir1’.
  12. tar -tf archive.tar: display the contents of a file.
  13. tar -xvf archive.tar: extract a tarball.
  14. tar -xvf archive.tar -C /tmp: extract a tarball in / tmp.
  15. tar -cvfj archive.tar.bz2 dir1: create a compressed tarball inside bzip2.
  16. tar -xvfj archive.tar.bz2: unzip a bzip2 compressed tar file
  17. tar -cvfz archive.tar.gz dir1: create a gzip compressed tarball.
  18. tar -xvfz archive.tar.gz: unzip a gzip compressed tar file.
  19. zip file1.zip file1Create a compressed zip file.
  20. zip -r file1.zip file1 file1 file2 dir1: comprimir, en zip, varios archivos y directorios de forma simultánea.
  21. unzip file1.zip: unzip a zip file.

RPM packages (Red Hat, Fedora and similar)

  1. rpm -ivh package.rpm: install an rpm package.
  2. rpm -ivh –nodeeps package.rpm: install an rpm package ignoring dependency requests.
  3. rpm -U package.rpm: actualizar un paquete rpm sin cambiar la configuración de los ficheros.
  4. rpm -F package.rpm: actualizar un paquete rpm solamente si este está instalado.
  5. rpm -e package_name.rpm: remove an rpm package.
  6. rpm -qashow all rpm packages installed on the system.
  7. rpm -qa | grep httpd: mostrar todos los paquetes rpm con el nombre “httpd”.
  8. rpm -qi package_name: obtener información en un paquete específico instalado.
  9. rpm -qg “System Environment/Daemons”show the rpm packages of a software group.
  10. rpm -ql package_nameshow list of files given by an installed rpm package.
  11. rpm -qc package_name: mostrar lista de configuración de ficheros dados por un paquete rpm instalado.
  12. rpm -q package_name –whatrequiresshow list of dependencies requested for an rpm package.
  13. rpm -q package_name –whatprovidesshow the capacity given by an rpm package.
  14. rpm -q package_name –scripts: mostrar los scripts comenzados durante la instalación /eliminación.
  15. rpm -q package_name –changelogshow the revision history of an rpm package.
  16. rpm -qf /etc/httpd/conf/httpd.conf: verificar cuál paquete rpm pertenece a un fichero dado.
  17. rpm -qp package.rpm -l: mostrar lista de ficheros dados por un paquete rpm que aún no ha sido instalado.
  18. rpm –import /media/cdrom/RPM-GPG-KEY: importar la firma digital de la llave pública.
  19. rpm –checksig package.rpmrpm package integrity check: check the integrity of an rpm package.
  20. rpm -qa gpg-pubkeyCheck the integrity of all installed rpm packages.
  21. rpm -V package_name: chequear el tamaño del fichero, licencias, tipos, dueño, grupo, chequeo de resumen de MD5 y última modificación.
  22. rpm -VaCheck all rpm packages installed on the system. Use with care.
  23. rpm -Vp package.rpm: verificar un paquete rpm no instalado todavía.
  24. rpm2cpio package.rpm | cpio –extract –make-directories *bin*: extract executable file from rpm package.
  25. rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm: install a package built from an rpm source.
  26. rpmbuild –rebuild package_name.src.rpmbuild an rpm package from an rpm source.

YUM package updater (Red Hat, Fedora and similar)

  1. yum install package_nameDownload and install an rpm package.
  2. yum localinstall package_name.rpm: este instalará un RPM y tratará de resolver todas las dependencies para ti, usando tus repositorios.
  3. yum update package_name.rpmUpdate all rpm packages installed on the system.
  4. yum update package_name: modernize / update an rpm package.
  5. yum remove package_name: remove an rpm package.
  6. yum listList all the packages installed on the system.
  7. yum search package_name: Find a package in rpm repository.
  8. yum clean packages: limpiar un caché rpm borrando los paquetes descargados.
  9. yum clean headers: delete all header files that the system uses to resolve the dependency.
  10. yum clean all: eliminar desde los paquetes caché y ficheros de encabezado.

Deb packages (Debian, Ubuntu and derivatives)

  1. dpkg -i package.deb: install / update a deb package.
  2. dpkg -r package_name: remove a deb package from the system.
  3. dpkg -l: display all deb packages installed on the system.
  4. dpkg -l | grep httpd: mostrar todos los paquetes deb con el nombre “httpd”
  5. dpkg -s package_name: obtener información en un paquete específico instalado en el sistema.
  6. dpkg -L package_name: show list of files given by a package installed on the system.
  7. dpkg –contents package.deb: mostrar lista de ficheros dados por un paquete no instalado todavía.
  8. dpkg -S /bin/ping: verificar cuál paquete pertenece a un fichero dado.

APT package updater (Debian, Ubuntu and derivatives)

  1. apt-get install package_name: install / update a deb package.
  2. apt-cdrom install package_name: install / update a deb package from a cdrom.
  3. apt-get update: update the list of packages.
  4. apt-get upgrade: update all installed packages.
  5. apt-get remove package_name: remove a deb package from the system.
  6. apt-get check: verificar la correcta resolución de las dependencias.
  7. apt-get clean: clear cache from downloaded packages.
  8. apt-cache search searched-package: retorna lista de paquetes que corresponde a la serie «paquetes buscados».

View the contents of a file

  1. cat file1: view the contents of a file starting from the first row.
  2. tac file1: ver los contenidos de un fichero comenzando desde la última línea.
  3. more file1: view the content along a file.
  4. less file1: parecido al commando ‘more’ pero permite salvar el movimiento en el fichero así como el movimiento hacia atrás.
  5. head -2 file1: ver las dos primeras líneas de un fichero.
  6. tail -2 file1: ver las dos últimas líneas de un fichero.
  7. tail -f /var/log/messages: ver en tiempo real qué ha sido añadido al fichero.

Text manipulation

  1. cat file1 file2 ... | command file1_in.txt_or_file1_out.txt: sintaxis general para la manipulación de texto utilizando PIPE, STDIN y STDOUT.
  2. cat file1 | command( sed, grep, awk, grep, etc…) > result.txtgeneral syntax for manipulating text in a file and writing the result to a new file.
  3. cat file1 | command( sed, grep, awk, grep, etc…) » result.txt: sintaxis general para manipular un texto de un fichero y añadir resultado en un fichero existente.
  4. grep Aug /var/log/messages: buscar palabras “Aug” en el fichero ‘/var/log/messages’.
  5. grep ^Aug /var/log/messages: buscar palabras que comienzan con “Aug” en fichero ‘/var/log/messages’
  6. grep [0-9] /var/log/messages: seleccionar todas las líneas del fichero ‘/var/log/messages’ que contienen números.
  7. grep Aug -R /var/log/*: buscar la cadena “Aug” en el directorio ‘/var/log’ y debajo.
  8. sed ‘s/stringa1/stringa2/g’ example.txt: reubicar “string1” con “string2” en ejemplo.txt
  9. sed ‘/^$/d’ example.txt: eliminar todas las líneas en blanco desde el ejemplo.txt
  10. sed ‘/ *#/d; /^$/d’ example.txt: eliminar comentarios y líneas en blanco de ejemplo.txt
  11. echo ‘esempio’ | tr ‘[:lower:]’ ‘[:upper:]’: convertir minúsculas en mayúsculas.
  12. sed -e ‘1d’ result.txt: elimina la primera línea del fichero ejemplo.txt
  13. sed -n ‘/stringa1/p’: visualizar solamente las líneas que contienen la palabra “string1”.

Set character and file conversion

  1. dos2unix filedos.txt fileunix.txt: convert a text file format from MSDOS to UNIX.
  2. unix2dos fileunix.txt fileunix.txt filedos.txtconvert a text file format from UNIX to MSDOS.
  3. recode ...HTML page.html: convert a text file to html.
  4. recode -l | more: show all available format conversions.

File system analysis

  1. badblocks -v /dev/hda1Check for bad blocks on the hda1 disk.
  2. fsck /dev/hda1: repair / check the integrity of the Linux system file on the hda1 disk.
  3. fsck.ext2 /dev/hda1: repair / check integrity of ext 2 system file on disk hda1.
  4. e2fsck /dev/hda1: repair / check integrity of ext 2 system file on disk hda1.
  5. e2fsck -j /dev/hda1: repair / check integrity of ext 3 system file on disk hda1.
  6. fsck.ext3 /dev/hda1: repair / check integrity of ext 3 system file on disk hda1.
  7. fsck.vfat /dev/hda1: repair / check the integrity of the system fat file on the hda1 disk.
  8. fsck.msdos /dev/hda1: repair / check the integrity of a system file two on disk hda1.
  9. dosfsck /dev/hda1: repair / check the integrity of a system file two on disk hda1.

Formatting a file system

  1. mkfs /dev/hda1: crear un fichero de sistema tipo Linux en la partición hda1.
  2. mke2fs /dev/hda1create a Linux ext 2 type system file in hda1.
  3. mke2fs -j /dev/hda1: crear un fichero de sistema tipo Linux ext3 (periódico) en la partición hda1.
  4. mkfs -t vfat 32 -F /dev/hda1: create a FAT32 system file on hda1.
  5. fdformat -n /dev/fd0Formatting a flooply disk.
  6. mkswap /dev/hda3: create a swap system file.

Working with SWAP

  1. mkswap /dev/hda3create swap system file.
  2. swapon /dev/hda3: activando una nueva partición swap.
  3. swapon /dev/hda2 /dev/hdb3: activate two swap partitions.

Salvas (Backup)

  1. dump -0aj -f /tmp/home0.bak /home: hacer una salva completa del directorio ‘/home’.
  2. dump -1aj -f /tmp/home0.bak /home: hacer una salva incremental del directorio ‘/home’.
  3. restore -if /tmp/home0.bak: restoring a save interactively.
  4. rsync -rogpav –delete /home /tmp: sincronización entre directorios.
  5. rsync -rogpav -e ssh –delete /home ip_address:/tmp: rsync a través del túnel SSH.
  6. rsync -az -e ssh –delete ip_addr:/home/public /home/local: sincronizar un directorio local con un directorio remoto a través de ssh y de compresión.
  7. rsync -az -e ssh –delete /home/local ip_addr:/home/public: sincronizar un directorio remoto con un directorio local a través de ssh y de compresión.
  8. dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr ‘dd of=hda.gz’: hacer una salva de un disco duro en un host remoto a través de ssh.
  9. dd if=/dev/sda of=/tmp/file1: salvar el contenido de un disco duro a un fichero. (En este caso el disco duro es “sda” y el fichero “file1”).
  10. tar -Puf backup.tar /home/user: hacer una salva incremental del directorio ‘/home/user’.
  11. ( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr ‘cd /home/share/ && tar x -p’: copiar el contenido de un directorio en un directorio remoto a través de ssh.
  12. ( tar c /home ) | ssh -C user@ip_addr ‘cd /home/backup-home && tar x -p’: copiar un directorio local en un directorio remoto a través de ssh.
  13. tar cf – . | (cd /tmp/backup ; tar xf – )local copy preserving the licenses and links from one directory to another.
  14. find /home/user1 -name ‘*.txt’ | xargs cp -av –target-directory=/home/backup/ –parents: encontrar y copiar todos los ficheros con extensión ‘.txt’ de un directorio a otro.
  15. find /var/log -name ‘*.log’ | tar cv –files-from=- | bzip2 > log.tar.bz2: encontrar todos los ficheros con extensión ‘.log’ y hacer un archivo bzip.
  16. dd if=/dev/hda of=/dev/fd0 bs=512 count=1Make a copy of the MRB (Master Boot Record) to a floppy disk.
  17. dd if=/dev/fd0 of=/dev/hda bs=512 count=1Restore the MBR (Master Boot Record) copy saved on a floppy disk.

CD-ROM

  1. cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force: cleaning or erasing a rewritable CD.
  2. mkisofs /dev/cdrom > cd.isoCreate a cdrom iso image on disk.
  3. mkisofs /dev/cdrom | gzip > cd_iso.gzCreate an iso compressed cdrom iso image on disk.
  4. mkisofs -J -allow-leading-dots -R -V “Label CD” -iso-level 4 -o ./cd.iso data_cd: create an iso image from a directory.
  5. cdrecord -v dev=/dev/cdrom cd.isoburn an iso image.
  6. gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom –Burn a compressed iso image.
  7. mount -o loop cd.iso /mnt/isoMount an iso image.
  8. cd-paranoia -B: convert songs from cd to wav files.
  9. cd-paranoia – ”-3”: convert the first 3 songs of a cd to wav files.
  10. cdrecord –scanbus: scan bus to identify the scsi channel.
  11. dd if=/dev/hdc | md5sum: run an md5sum on a device, such as a CD.

I work with the NETWORK ( LAN and Wi-Fi)

  1. ifconfig eth0: mostrar la configuración de una tarjeta de red Ethernet.
  2. ifup eth0: activar una interface ‘eth0’.
  3. ifdown eth0: deshabilitar una interface ‘eth0’.
  4. ifconfig eth0 192.168.1.1.1 netmask 255.255.255.0: configurar una dirección IP.
  5. ifconfig eth0 promisc: configurar ‘eth0’en modo común para obtener los paquetes (sniffing).
  6. dhclient eth0: activar la interface ‘eth0’ en modo dhcp.
  7. route -n: show tour table.
  8. route add -net 0/0 gw IP_Gateway: set default input.
  9. route add -net 192.168.0.0.0 netmask 255.255.0.0 gw 192.168.1.1: configurar ruta estática para buscar la red ‘192.168.0.0/16’.
  10. route from 0/0 gw IP_gateway: eliminar la ruta estática.
  11. echo “1” > /proc/sys/net/ipv4/ip_forward: activate the ip route.
  12. hostname: display the host name of the system.
  13. host www.example.com: buscar el nombre del host para resolver el nombre a una dirección ip(1).
  14. nslookup www.example.com: buscar el nombre del host para resolver el nombre a una direccióm ip y viceversa(2).
  15. ip link showshow the link status of all interfaces.
  16. mii-tool eth0: mostar el estado de enlace de ‘eth0’.
  17. ethtool eth0: mostrar las estadísticas de tarjeta de red ‘eth0’.
  18. netstat -tup: display all active network connections and their PIDs.
  19. netstat -tuplShow all network listener services in the system and their PIDs.
  20. tcpdump tcp port 80: mostrar todo el tráfico HTTP.
  21. iwlist scan: mostrar las redes inalámbricas.
  22. iwconfig eth1: mostrar la configuración de una tarjeta de red inalámbrica.
  23. whois www.example.comWhois database search.

Microsoft Windows Networks (SAMBA)

  1. nbtscan ip_addr: resolución de nombre de red bios.
  2. nmblookup -A ip_addr: resolución de nombre de red bios.
  3. smbclient -L ip_addr/hostnameShow remote actions of a host in windows.

IP Boards (FIREWALLS)

  1. iptables -t filter -L: show all the strings in the filter table.
  2. iptables -t nat -L: show all the strings of the nat table.
  3. iptables -t filter -FClear all the rules of the filter table.
  4. iptables -t nat -F: clear all the rules of the nat table.
  5. iptables -t filter -XDelete any string created by the user.
  6. iptables -t filter -A INPUT -p tcp –dport telnet -j ACCEPT: allow telnet connections to log in.
  7. iptables -t filter -A OUTPUT -p tcp –dport http -j DROP: blocking connections HTTP to exit.
  8. iptables -t filter -A FORWARD -p tcp –dport pop3 -j ACCEPT: enable connections POP to a front chain.
  9. iptables -t filter -A INPUT -j LOG –log-prefix “DROP INPUT”: registering an input string.
  10. iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE: configurar un PAT (Puerto de traducción de dirección) en eth0, ocultando los paquetes de salida forzada.
  11. iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp -m tcp –dport 22 -j DNAT –to-destination 10.0.0.2:22Redirect packets routed from one host to another.

Monitoring and debugging

  1. top: mostrar las tareas de linux usando la mayoría cpu.
  2. ps -eafwLinux tasks: displays Linux tasks.
  3. ps -e -o pid,args –forest: muestra las tareas Linux en un modo jerárquico.
  4. pstree: mostrar un árbol sistema de procesos.
  5. kill -9 Process_ID: to force the closing of a process and terminate it.
  6. kill -1 Process_ID: forzar un proceso para recargar la configuración.
  7. lsof -p $$: display a list of open files by process.
  8. lsof /home/user1shows a list of open files in a given system path.
  9. strace -c ls >/dev/null: display the system calls made and received by a process.
  10. strace -f -e open ls >/dev/null: display the calls to the library.
  11. watch -n1 ‘cat /proc/interrupts’: display interruptions in real time.
  12. last rebootShow restart history.
  13. lsmod: show the loaded kernel.
  14. free -mRAM: shows the RAM status in megabytes.
  15. smartctl -A /dev/hda: monitorear la fiabilidad de un disco duro a través de SMART.
  16. smartctl -i /dev/hda: chequear si SMART está activado en un disco duro.
  17. tail /var/log/dmesgshow events inherent to the kernel loading process.
  18. tail /var/log/messages: display the system events.

Other useful commands

  1. apropos …keyword: mostrar una lista de comandos que pertenecen a las palabras claves de un programa; son útiles cuando tú sabes qué hace tu programa, pero de sconoces el nombre del comando.
  2. man ping: mostrar las páginas del manual on-line; por ejemplo, en un comando ping, usar la opción ‘-k’ para encontrar cualquier comando relacionado.
  3. whatis …keyword: muestra la descripción de lo que hace el programa.
  4. mkbootdisk –device /dev/fd0 `uname -r`: create a bootable floppy.
  5. gpg -c file1Encrypt a file with GNU security guard.
  6. gpg file1.gpgdecode a file with GNU Security Guard.
  7. wget -r www.example.com: download a complete website.
  8. wget -c www.example.com/file.iso: descargar un fichero con la posibilidad de parar la descargar y reanudar más tarde.
  9. echo ‘wget -c www.example.com/files.iso‘ | at 09:00: Comenzar una descarga a cualquier hora. En este caso empezaría a las 9 horas.
  10. ldd /usr/bin/sshshow the shared libraries required by the ssh program.
  11. alias hh=’history’: colocar un alias para un commando –hh= Historial.
  12. chshChange the Shell command.
  13. chsh –list-shellsis a command suitable to know if you have to make remote in another terminal.
  14. who -a: mostrar quien está registrado, e imprimir hora del último sistema de importación, procesos muertos, procesos de registro de sistema, procesos activos producidos por init, funcionamiento actual y últimos cambios del reloj del sistema.

Write us a comment:

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Go up

Cookies on this website are used to personalize content and ads, provide social media features and analyze traffic. More information

en_USEnglish