Changes

Jump to navigation Jump to search
250 bytes removed ,  17:51, 10 September 2018
Line 1: Line 1: −
'''Linux commands'''
+
== Linux general commands ==
 
   
{| class="wikitable sortable"
 
{| class="wikitable sortable"
 
|-
 
|-
! Commands !! Description
+
! Command !! Description
 
|-
 
|-
| tty || Shows the terminal where you are connected
+
| [[Linux_command:_alias|alias]] || Creates a commnad
 +
|-
 +
| [[Linux_command:_alien|alien]] || Migrate packages from .rpm to .deb and vice versa
 +
|-
 +
| apropos <subject> || Sows commnads related to a subject
 
|-
 
|-
| free || Shows free memory
+
| [[Linux_comand:_apt-get|apt-get]] || Package installation and system update
 
|-
 
|-
| date || Shows date
+
| [[Linux_command:_awk|awk]] || CLI text processor
 
|-
 
|-
 
| cal || Shows calendar
 
| cal || Shows calendar
 +
|-
 +
| cat <filename> || Shows file content
 
|-
 
|-
 
| clear || Clear screen
 
| clear || Clear screen
 
|-
 
|-
| who || Connected persons
+
| [[Linux_command:_date|date]] || Shows date
 +
|-
 +
| [[Linux_command:_dd|dd]] || Create / Dump images
 
|-
 
|-
| whoami || Who am i
+
| df || Shows the disk ussage. Example: df -h -x devtmpfs -x tmpfs
 
|-
 
|-
| [[Linux_command:_uname|uname]] || Shows system info
+
| dpkg || .deb package installation: sudo dpkg -i packagename.deb
 
|-
 
|-
 
| [[Linux_command:_du|du]] || Disk ussage  
 
| [[Linux_command:_du|du]] || Disk ussage  
 
|-
 
|-
| df || Shows the disk ussage. Example: df -
+
| export VARIABLE=VALUE || To create system variables
 +
|-
 +
| [[Linux_command:_fsck|fsck]] || Check file system
 +
|-
 +
| [[Linux_command:_fdisk|fdisk]] || Disk partition utility
 +
|-
 +
| [[Linux_command:_find|find]] || Find files
 
|-
 
|-
| man <command> || Sowhs a command manual page 
+
| free || Shows free memory
 
|-
 
|-
| apropos <subject> || Sows commnads related to a subject
+
| [[Linux:_gpg|gpg]] || GnuPG
 +
|-
 +
| [[Linux_comand:_grep|grep]] || finds text matching regex or text
 +
|-
 +
| head || Shows file start (-n, -f,...)
 +
|-
 +
| history || Shows the commnad history (contained in ~.bash_history)
 
|-
 
|-
 
| info <command> || Sows command info
 
| info <command> || Sows command info
 
|-
 
|-
| history || Shows the commnad history (contained in ~.bash_history)
+
| [[Linux_command:_ln|ln]] || Create simbolic links
 +
|-
 +
| lsb_release -a || Show os name and version
 +
|-
 +
| lsblk ||
 +
|-
 +
| lspci -v || View PCI device information
 +
|-
 +
| lscpu || List cpu cores
 +
|-
 +
| lsof || <nowiki>sudo lsof -i -n | egrep '\<ssh\>'</nowiki>
 +
|-
 +
| man <command> || Sowhs a command manual page
 +
|-
 +
| mc || Midnight commander. File system navigation
 +
|-
 +
| mkdosfs -F32 /dev/mmcblk0 || Format SD card with FAT32
 +
|-
 +
| more <filename> || Shows file content, screen by screen
 +
|-
 +
| mount || File sistem mounting
 
|-
 
|-
 
| pwd || Shows working directory
 
| pwd || Shows working directory
 +
|-
 +
| rsync -a ruta1 ruta2 [--exclude=/{dir1, dir2..]/] || Copies files from ruta1 to ruta2 excluding dir1, dir2,...
 +
|-
 +
| [[Linux command: rename|rename]] || Rename files allowing regex
 +
|-
 +
| scp || Copy files to a remote machine over ssh protocol
 +
|-
 +
| [[Linux:_SSH|ssh]] || ssh (Secure Shell)
 +
|-
 +
| [[Linux_command:_sed|sed]] || String replacement
 +
|-
 +
| sort || Sorts the content of a file line by line
 +
|-
 +
| su || Log as root at the terminal (sudo su)
 +
|-
 +
| sudo <command>|| Execute command as root
 +
|-
 +
| [[Linux_command:_tar|tar]] || Compress/decompress tar files
 +
|-
 +
| [[Linux command: tail|tail]] || Shows file end (-n, -f, ...)
 
|-
 
|-
 
| touch <file_name> || Creates an empty file
 
| touch <file_name> || Creates an empty file
 
|-
 
|-
| [[Linux_command:_alias|alias]] || Creates a commnad
+
| tty || Shows the terminal where you are connected
 +
|-
 +
| [[Linux_command:_uname|uname]] || Shows system info
 +
|-
 +
| [[Linux_comand:_visudo|visudo]] || visudo is used to securely edit /etc/sudoers
 +
|-
 +
| wc -l || Counts lines
 
|-
 
|-
| cat <filename> || Shows file content
+
| [[Linux_command:_wget|wget]] || Download files/web pages
 
|-
 
|-
| more <filename> || Shows file content, screen by screen
+
| [[Linux:_vim|vim]] || Text file editor
 
|-
 
|-
| head || Shows file start (-n, -f,...)
+
| who || Connected persons
 
|-
 
|-
| tail || Shows file end (-n, -f, ...)
+
| whoami || Who am i
 
|-
 
|-
| sort || Sorts the content of a file line by line
+
| [[Linux_command:_xargs|xargs]] || Send output of command to stdin
 
|-
 
|-
 
| <nowiki><cmd1> | <cmd2></nowiki> || Pipe: takes the output of command1 as input of command2. example: <nowiki>cat /etc/passwd | sort | more</nowiki>
 
| <nowiki><cmd1> | <cmd2></nowiki> || Pipe: takes the output of command1 as input of command2. example: <nowiki>cat /etc/passwd | sort | more</nowiki>
 +
|}
 +
 +
== Users and File permissions ==
 +
{| class="wikitable sortable"
 +
|-
 +
! Command !! Description
 +
|-
 +
| [[Linux_command:_adduser|adduser]] || Add users
 +
| w || Show connected users
 
|-
 
|-
| ||
+
| chown <NewOwner>:<NewGroup> <File>|| Change file owner
 
|-
 
|-
| ||
+
| chgrp <NewGroup> <File> || Change group of file
 
|-
 
|-
| ||
+
| [[Linux_command:_chmod|chmod]] || Change file permissions
 
|}
 
|}
    +
== Processes ==
   −
rsync -a ruta1 ruta2 [--exclude=/{dir1, dir2..]/] copia los archivos de la ruta1 en la 2 excluyendo los especificados
+
{| class="wikitable sortable"
 +
|-
 +
! Command !! Description
 +
|-
 +
| CTRL + C || Stop process
 +
|-
 +
| CTRL + Z || Pause process
 +
|-
 +
| %PID || Recover paused process
 +
|-
 +
| <command>& || Execute command in second plane
 +
|-
 +
| bg <command> || Execute command in second plane
 +
|-
 +
| [[Linux_command:_ps|ps]] || List processes
 +
|-
 +
| pstree || Show process tree
 +
|-
 +
| top || Processes viewer
 +
|-
 +
| htop || Process viewer more advanced than top
 +
|-
 +
| kill %PID || Terminate process
 +
|-
 +
| [[Linux_command:_nice|nice, renice]] || Process priorities: nice -n <command>
 +
|-
 +
| nohup <command> || Execute process avoiding its stop if the terminal is stopt
 +
|-
 +
| pgrep <pattern>|| Retruns process that matches pattern
 +
|-
 +
| locate <program> || Returns program path
 +
|-
 +
|}
   −
grep (texto) (archivo) Busca un texto en un archivo y lo muestra
+
== Firewall ==
wc -l Cuenta las lineas
+
{| class="wikitable sortable"
 +
|-
 +
! Command !! Description
 +
|-
 +
| [[Linux_command:_iptables|iptables]] || Firewall rules
 +
|-
 +
| service iptables [start, stop] || Activate/deactivate firewall
 +
|-
 +
| route -n || Shows routing table
 +
|}
   −
find . -name "*.txt" Distingue entre mayusculas y minusculas
+
== Networking ==
find . -iname "*.txt" No distingue entre mayusculas y minusculas
+
{| class="wikitable sortable"
 +
|-
 +
! Command !! Description
 +
|-
 +
| [[Linux command: netstat|netstat]] ||
 +
|-
 +
| nmap || Network mapping
 +
|-
 +
| nm-tool || Network monitor tool
 +
|-
 +
| nm-connection-editor || Network monitor editor
 +
|-
 +
| ifconfig || Show network configuration
 +
|-
 +
| iwconfig || Show WiFi connections
 +
|-
 +
| service networkmanager restart || Restart network daemon
 +
|}
 +
Network Manager configuration files:<br />
 +
*/etc/NetworkManager/system-connections/name-of-connection
 +
Network configuration file:
 +
*/etc/network/interfaces
   −
Firewall
+
== Linux key files/directories ==
iptables -l lista reglas del firewall
+
See: [[Linux:_Key_files/folders|Linux key files/directories]]
service iptables [start, stop] Activa y desactiva el firewall
  −
route -n Muestra la tabla de enrutamiento
  −
Instalar KDE
  −
apt-get install kali-defaults kali-root-login desktop-base kde-full
  −
  −
Actualizar Kali
  −
apt-get update && apt-get upgrade && apt-get dist-upgrade
     −
INSTALACION PROGRAMAS
     −
        sudo apt-cache search qbasic
+
== Programs ==
 
+
{| class="wikitable sortable"
 
+
|-
Instalar *.deb
+
! Command !! Description
sudo dpkg -i packagename.deb
+
|-
Instalar *.rpm
+
| [[Linux_command:_git|git]] || Software repository
dev to rpm
+
|-
alien --to-rpm package.deb
+
| coursera-dl ||
rpm to dev
+
|-
alien --to-deb package.rpm
+
| [[Jp2a|jp2a]] || Jpg to ASCII
 
+
|-
su Logear root en terminal
+
| [[Linux:_John|john]] || John the ripper
 
+
|-
apt-get (update/install remove apt-cache searc)
+
| [[Linux:_macchanger|macchanger]] || Change MAC address
/etc/sources.list lista de repositorios de paquetes
+
|-
 
+
| openvpn || Connect to VPN
aptitude --purge paquete desinstala un paquete
+
|-
mc midnight commander
+
| [[Linux_command:_terminator|terminator]] || Advanced terminal
 
+
|-
Montar/desmontar discos
+
| [[Virtualenv|virtualenv]] || Create virtual enviroments
df -h Muestra lo que hay montado
+
|-
fdisk -l Muestra las particiones
+
| [[Virtualenvwrapper|virtualenvwrapper]] || Simplify virtualenv ussage
mount -t vfat[ntfs-3g] /dev/hda /media/sdb  ntfs-3g es un paquete que hay que instalar.
+
|-
para cd iso990
+
| [[Linux:_youtube-dl|youtube-dl]] || YouTube video downloader
 
+
|}
COMPILAR KERNEL
+
vnc:escritorio remoto
1.- Descargar fuentes
+
== Save command without running to recover later ==
apt-get install (version nucleo se averigua con uname -r)
+
ctrl+u --> saves
se guarda en /usr/src/versionkernel
+
ctrl+y --> recover
descomprimir el archivo con tar xvf archivo
  −
entrar en la carpeta descomprimida
  −
2.- Configurar
  −
3.- Compilar
  −
instalar build-essential y libncurses5-dev (con apt-get install)
  −
make clean limpia anteriores compilaciones
  −
make menuconfig
  −
make deb-pkg
  −
se generan: linux-image.dev linux-libc.dev linux-headers.deb instalar con
  −
dpkg -i
  −
 
  −
 
  −
 
  −
WGET
  −
wget -xr website.com will download recursively all the files on that site
  −
          -r
  −
      --recursive
  −
          Turn on recursive retrieving.    The default maximum depth is 5.
  −
      -l depth
  −
      --level=depth
  −
          Specify recursion maximum depth level depth
  −
 
  −
        wget -m http://nombredelsitioweb.com
  −
        wget -H -r --level=1 -k -p http://nombredelsitioweb.com"
  −
 
  −
TERMINATOR
  −
        inciar: terminator
  −
 
  −
        dividir horizontal: CTRL+SHIFT+O
  −
        dividir vertical CTRL+SHIFT+E
  −
        Redimensionar CTRL+SHIFT+FLECHAS
  −
        carmibar de terminal: ALT+FLECHA
  −
        Copiar: CTRL+SHIFT+C
  −
        Pegar: CTRL+SHIFT+V
  −
        Cerrar ventana: CTRL+SHIFT+W
  −
        Mostrartodos/Mostrar 1: CTRL+SHIFT+X
  −
        Cerrar todo: CTRL+SHIFT+Q
  −
        Ampliar/reducir texto: CTRL+ '+/-'
  −
        Agrupar todos los terminales en una ventana: SUPER+t
  −
        Desagrupar todos los terminales de una ventana: SUPER+SHIFT+T
  −
 
  −
        Archivo de configuración: /.config/terminator/config    +++man terminator_config
  −
 
  −
PROCESOS
  −
Listar procesos: jobs
  −
        Para ejecutar en segundo plano poner $
  −
        Interrumpir proceso CTRL + C
  −
        Pausar proceso CTRL + Z
  −
    Recuperar proceso pausado: %PID
  −
        Reanudar proceso detenido en segundo plano: bg %PID
  −
        Información de procesos: ps, pstree, top, htop (ps -ef)
  −
        Parar proceso: kill %PID
  −
        Establecer prioridades: nice -n -5 COMANDO, renice 7 PID
  −
        Ejecutar procesos evitando que se paren si se cierra la terminal: nohup COMANDO
  −
        top, atop, htop: utilidades procesos completilla
  −
        pgrep: devuelve el pid del proceso que coincide con la busqueda
  −
        locate programa: encuentra la ubicación de un programa
  −
 
  −
        scp archivoorigen usuarioremoto@máquinaremota:destino
  −
        vnc:escritorio remoto
  −
 
  −
USUARIOS
  −
        w: Muestra los usuarios conectados
  −
        du: disk usage
  −
        chown nuevopropietario:nuevogrupo nombrearchivo
  −
        chgrp nuevogrupo nombrearchivo
  −
 
  −
VIM
  −
        i
  −
        w
  −
        wq
  −
        q!
  −
        yy copia linea
  −
        dd corta linea
  −
        p pegar
  −
 
  −
JOHN
  −
                se crea el directorio /root/.john
  −
        john --wordlist:[archivodiccionario] [archivo paswords]
  −
        john --show[=LEFT]            show cracked passwords [if =LEFT, then uncracked]
  −
 
  −
ARCHIVOS IMPORTANTES
  −
        /etc/sudoers
  −
        carpetas de archivos ejecutables (para cada usuario en archivo home .bashrc, abrir con vim.bashrc)
  −
                        (Ver /usr/share/doc/examples/startup-files del paquete bash-doc)
  −
                /opt/sge/bin
  −
                /usr/local/bin
  −
        /etc/init.d/ "directorio para los escripts de los daemons aplicaciones arrancan al inicio.
  −
 
  −
RED
  −
/etc/network/interfaces Configuración de red
  −
/etc/NetworkManager/system-connections/name-of-connection
  −
NETWORK
  −
nm-tool
  −
nm-connection-editor
  −
/etc/NetworkManager/system-connections/name-of-connection
  −
iwconfig: Muestra las conexiones inalambrica
  −
service networkmanager restart: Reinicia network manager
  −
service networking restart: Reinicia el demonio de red
  −
HARDWARE
  −
lspci -v: Muestra información dispositivos PCI
 

Navigation menu