Last active
November 12, 2021 14:46
-
-
Save mpessolano/4aa0426c6a7361344e1346c40b417d05 to your computer and use it in GitHub Desktop.
Linux tips & tricks
- Buscar directorio:
find / -type d -name 'DIRNAME'- Buscar archivo en el directorio actual:
find . -name "*.txt" -type f- Añadiendo otros comandos:
find . -name "*.txt" -type f | while read file; do (file -i "$file"); done- Mostrar la ruta completa de un archivo:
readlink -f file.txthttps://stackoverflow.com/questions/5265702/how-to-get-full-path-of-a-file
https://www.hostinger.es/tutoriales/como-usar-comando-find-locate-en-linux/
- Opciones:
-c Crear un nuevo archivo .tar.gz
-f Nombre del archivo
-v Muestra una descripción detallada del progreso de la compresión
-x Extraer el archivo
-z Compresión gzip- Comprimir:
tar -czvf project.tar.gz /datadrive/www/project \
--exclude=/datadrive/www/project/app/storage \
--exclude=/datadrive/www/project/vendor
tar -czvf project.tar.gz --absolute-names /datadrive/www/project \
--exclude=/datadrive/www/project/app/storage \
--exclude=/datadrive/www/project/vendor
tar -czvf html-project.tar.gz /datadrive/www/html/project \
--exclude=/datadrive/www/html/project/core- Listar contenido:
tar -tf project.tar.gz- Descomprimir:
tar -xzvf project.tar.gz- Eliminar todos los archivos (excepto los archivos ocultos) y subdirectorios:
$ rm -rf /datadrive/moodledata/cache/*$ cd /datadrive/moodledata/cache/
$ rm -rf *- Eliminar archivos ocultos:
$ cd /datadrive/moodledata/cache/
$ rm -rf .* - Eliminar todos los archivos (incluyendo los archivos ocultos) y subdirectorios:
$ cd /datadrive/moodledata/cache/
$ rm -rf {*,.*}https://www.cyberciti.biz/faq/linux-delete-all-files-in-directory-using-command-line/
$ cd /respaldos/dumps/backup_12-2020.sql.gz
$ gzip -cd "./backup_12-2020.sql.gz" | sed -r '/INSERT INTO `(mdl_logstore_standard_log)`/d' |
gzip > "./reduced-backup_12-2020.sql.gz"cd ~/encoding
file *
file -i *
file --mime *file --mime my.txt - Ver charset distintos a utf:
cd /datadrive/www/laravel/app/views/admin
file -i */* | grep -v utf
file -i */* -r * | grep -v utf- Codificados con UTF-8: text/html; charset=utf-8 text/html; charset=us-ascii
https://unix.stackexchange.com/questions/646482/finding-text-files-encoding
https://www.datafix.com.au/cookbook/characters1.html
https://stackoverflow.com/questions/11018967/how-can-i-be-sure-of-the-file-encoding
https://stackoverflow.com/questions/805418/how-can-i-find-encoding-of-a-file-via-a-script-on-linux
https://perishablepress.com/list-files-folders-recursively-terminal/
- Ver estado actual de SELinux:
sestatus- Desactivar temporalmente:
setenforce 0- Desactivar permanentemente:
nano /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted- Mostrar solo estructura de directorios:
tree -d- Alternativa con ls
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
https://unix.stackexchange.com/questions/21838/how-to-make-tree-output-only-directories/460390
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment