Comandos Usuales Simples

Cada día aprendemos comandos que nos permiten realizar determinadas tareas en el trabajo, para no olvidar alguno de estos comandos que sirvieron cree una lista como ayuda memoria.

1# Primera opción
2$ ls -lct /etc | tail -1 | awk '{print $6, $7, $8}'
3# Segunda opción
4$ ls -lct --time-style=+"%d-%m-%Y %H:%M:%S" /etc | tail -1 | awk '{print $6, $7, $8}'
5# En su defecto
6$ ls -lAhF /etc/hostname
bash
1# Identificamos el ID de proceso
2$ fuser -n tcp 7070
3# Buscamos el nombre de proceso en base al ID
4$ ps aux | grep ID_PROCESS
bash
 1$ inxi -Fxz
 2# Comunes: lsblk, lsusb, lsscsi, lspci, lscpu
 3$ hwinfo --short
 4$ free -m
 5$ cat /proc/partitions
 6$ sudo hdparm -i /dev/sda # Puede cambiar sda
 7$ ls /sys/class/net/
 8$ ls /sys/class/net/enp0s25 # Puede cambiar enp0s25
 9$ cat /sys/class/net/enp0s25/carrier
10$ cat /sys/class/net/enp0s25/operstate
11$ lspci -v | grep "VGA" -A 12
12$ df -h
13$ pydf
14$ sudo fdisk -l
15$ mount | column -t
16$ cat /proc/cpuinfo
17$ cat /proc/meminfo
18$ cat /proc/scsi/scsi
19$ cat /proc/version
bash
1# Con netstat
2$ netstat -vatn # netstat -tlpn
3# Con ss
4$ ss -tlpn
bash
1# vim /etc/environment
2LC_ALL="es_BO.UTF-8"
3# Configuración Zona Horaria
4$ timedatectl set-timezone America/La_Paz
bash
 1# Eliminar Kernel Viejos Fedora:
 2$ dnf remove $(dnf repoquery --installonly --latest-limit=-2 -q)
 3
 4# Eliminar Kernel Viejos CentOS:
 5$ package-cleanup --oldkernels --count=2
 6
 7# Comando RPM:
 8$ rpm -qa kernel\* | sort -V
 9
10# Archivo de configuración:
11## Se debe editar el archivo /etc/yum.conf para CentOS y /etc/dnf/dnf.conf 
12## para Fedora y asignar installonly_limit:
13$ installonly_limit=2
14
15# Regenerar Módulos de Kernel
16$ dracut --regenerate-all --force
bash
1# Gnome Shell Personalización a normal:
2$ gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false
3$ gsettings set org.gnome.shell.extensions.dash-to-dock transparency-mode 'FIXED'
4$ gsettings set org.gnome.shell.extensions.dash-to-dock background-opacity 0.0
bash
 1# SSH Tunneling
 2$ ssh -L 2228:hostname.IP_DOMINIO_PUBLICO:22 user@IP_DOMINIO_PRIVADO
 3$ ssh -f user@IP_DOMINIO_PRIVADA -L 2229:hostname.IP_DOMINIO_PRIVADO:22 -N
 4$ ssh -L 2229:hostname.IP_DOMINIO_PUBLICO:22 user@IP_DOMINIO_PRIVADO
 5
 6# Ejemplos
 7$ ssh -i .ssh/PUB_KEY -f user@IP_DOMINIO_PUBLICO -L 2228:IP_DOMINIO_PRIVATE:22 -N
 8$ ssh -i .ssh/PUB_KEY user@localhost -p2228
 9
10# SSH Agent TTY
11$ eval $(ssh-agent -s)
12$ ssh-add ~/.ssh/name_priv_key
13
14# Lista de usuarios con Login SSH aceptados
15$ sudo cat /var/log/auth* | grep Accepted
bash
 1# OpenWRT manejador de paquetes
 2$ opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade 
 3
 4# Actualizar cache de fuentes tipográficas
 5$ fc-cache -f -v
 6
 7# Remount Linux Device
 8$ mount -o remount,rw -t ext4 /dev/sdb /media/device
 9
10# Poner todos los subfolder de un folder a 755:
11$ find . -type d -exec chmod 755 {} \;
12
13# Todos los archivos a 644:
14$ find . -type f -exec chmod 644 {} \;
15
16# Establecer solo los archivos que terminen con .php a 644:
17$ find . -name \*\.php -exec chmod 644 {} \;
bash
 1$ journalctl -t setroubleshoot
 2$ dmesg | grep -i -e tipo = 1300 -e tipo = 1400
 3$ semodule -DB
 4$ emodule -B
 5$ sealert -l "*"
 6
 7# NGINX - Selinux
 8$ ps auZ | grep nginx
 9$ semanage permissive -a httpd_t (Deshabilitando temporalmente SELinux)
10$ sudo chcon -R -t httpd_sys_content_t /var/www/html
11$ sudo chcon -R -t httpd_sys_rw_content_t /var/www/html
12
13# Firewall
14$ sudo firewall-cmd --permanent --zone=public --add-service=http
15$ sudo firewall-cmd --permanent --zone=public --add-service=https
16$ sudo firewall-cmd --reload
bash
1$ whiptail --yesno "Did you already know whiptail?" 40 150
bash
1$ shred -u file.txt
bash
1# vim ~/.moc/config
2TiMidity_Config = /etc/timidity.cfg
3Theme = transparent-background 
4XTermTheme = transparent-background
5# Privilegios
6$ chmod 644 config
bash
1$ cat <<EOF >> shell.sh
2#!/bin/bash
3echo "Template"
4sed -e
5df -h
6EOF
bash
1# Primera opción
2$ sudo touch /etc/cloud/cloud-init.disabled
3$ sudo vim /etc/cloud/cloud-init.disabled
4cloud-init=disabled
5# Segunda opción
6$ sudo systemctl disable cloud-init.service
7$ sudo systemctl stop cloud-init.service
bash

Traducciones: