Skip to content
56K

56K

Slow IT just 4 fun

Menu
Menu

Algunos comandos en Linux que uso habitualmente

Posted on 25/04/202325/04/2023 by fanta

Actualmente suelo usar bastante estos comandos y oneliners en sistemas GNU+Linux. Esto es una nota que voy actualizando poco a poco.

# LIBERAR SWAP Y MEMORIA CACHE

free -h ; sync; echo 1 > /proc/sys/vm/drop_caches ; sysctl -w vm.overcommit_memory=1 ; swapoff -av && swapon -av ; free -h

# EXTENDER 1G SOBRE UN LV EN LVM CUANDO TIENES ESPACIO LIBRE PARA DARLE EN EL VG

FS="/dev/mapper/rootvg-opt" && lvextend -L+1G $FS -r

# TOP 10 PROCESOS CONSUMO RAM Y CPU

#!/bin/bash
export LC_ALL=C bash

tHost="$(hostname)"
tTime="$(date +"%d/%m/%Y a las %H:%M:%S")"
tMemTotal="$(free -m | grep "Mem:" | awk '{print $2}')"
tMemUsed="$(free -m | grep "Mem:" | awk '{print $3}')"
tMemFree="$(free -m | grep "Mem:" | awk '{print $4}')"
tLoadAverage="$(uptime | rev | cut -d ":" -f 1 | rev | cut -d " " -f 2-10)"

echo -e "\n$tHost - $tTime"
echo -e "RAM: $tMemUsed M usados de $tMemTotal M totales ($tMemFree M libres)\nCPU Load Average: $tLoadAverage\n\n[+] Listado de Procesos top10 consumo de RAM:\n"
ps -A --sort=-rss --format pid,user,pmem,rss,comm | head -11
echo -e "\nPor tanto el proceso en el top1 consumo RAM es:\n"
ps -A --sort=-rss --format pid,user,pmem,rss,command | head -2
echo -e "\n[+] Listado de Procesos top10 consumo CPU:\n"
ps -A --sort=-pcpu --format pid,user,pcpu,rss,comm | head -11
echo -e "\nPor tanto el proceso en el top1 consumo CPU es:\n"
ps -A --sort=-pcpu --format pid,user,pcpu,rss,command | head -2
echo -e "\n"

# EXTENDER UN VG CON UN NUEVO PV EN LVM

# pvcreate /dev/sdf
# pvs
# vgextend datosvg /dev/sdf
# pvs
# vgs

 

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
🍅 STREAMING
🍊 LINUX
🥝 GAMES
🥥 THREADS
🧅 SECURITY
🥑 RETRO
🍆 HARDWARE
🍇 MISC
©2023 56K | Built using WordPress and Responsive Blogily theme by Superb