Skip to content

Instantly share code, notes, and snippets.

@barthelemypousset
Last active June 18, 2019 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barthelemypousset/e94ade6b55bdda4faf1987c1c6b30323 to your computer and use it in GitHub Desktop.
Save barthelemypousset/e94ade6b55bdda4faf1987c1c6b30323 to your computer and use it in GitHub Desktop.
Show build history of an image:
docker history --format "Date: {{.CreatedSince}}\nCommand: {{.CreatedBy}}\nSize: {{.Size}}\n" --no-trunc decastore-build-tools
Reduce filesize:
Tail -c 100000000 file.original > file.light; chown --reference=file.original file.light; rm file.original
Remove file older than 40 days:
find /path/to/files* -mtime +40 -exec ls {} \;
Save a file in VI without beeing logged as root (must have sudo rights):
:w !sudo tee %
Utiliser sed pour creer des groupe et filtre des infos:
cat serverlist/servers_zes.list | sed -r 's/(^.*)\.(.*)\.(.*$)/\1/g'
Dans VI,Supprimer les lignes commencant par #:
:g/^#.*$/d
Comment multiple line in vim:
ctrl-v
shift-i
# escape (wait a little)
Trouver un service qui attaque un serveur particulier:
netstat -nltp | grep ip_serveur
Puis observer le numero de process et le chercher:
ps -eaf | grep xxx
regarder log pour un service:
journlctl -u service --since "2 days ago"
Acceder aux cron des autres users:
/var/spool/cron
Tunnel SSH:
ssh -L 1234:Serveur_Cible:Port_Cible user@server
next connect to whatever service using port 1234
Afficher les process:
ps -eo rss,pid,cmd|sort -n| cut -c 1-200
ps -eo rss,pid,cmd --sort rss| cut -c 1-200
reset yum:
rm -f /var/lib/rpm/__db*
db_verify /var/lib/rpm/Packages
rpm --rebuilddb
yum clean all
Undo commit to wrong branch:
git reset --soft
clear ram and swap:
echo 3 > /proc/sys/vm/drop_caches
swapoff -a && swapon -a
search on git (https://help.github.com/en/articles/searching-code):
org:<Company> filename:<exactfilename you're searching> <patern in file> in:file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment