null
US
Sign In
Sign Up for Free
Sign Up
We have detected that Javascript is not enabled in your browser. The dynamic nature of our site means that Javascript must be enabled to function properly. Please read our
terms and conditions
for more information.
Next up
Copy and Edit
You need to log in to complete this action!
Register for Free
27821957
103.3 Perform basic file management
Description
103.3 Perform basic file management
No tags specified
103.3 perform basic file management
lpic-1
certificacion lpic-1
Mind Map by
Rolando Martinez
, updated more than 1 year ago
More
Less
Created by
Rolando Martinez
almost 4 years ago
11
0
0
Resource summary
103.3 Perform basic file management
How to Find Files
find STARTING_PATH OPTIONS EXPRESSION
find . -name "myfile.txt"
find /home/frank -name "*.png"
Using Criteria to Speed Search with find
-type f archivo plano -type d archivo directorio -type l archivo link
find . -type d -name "example"
criterio
-name
-iname
-not
-maxdepth N
Locating Files by Modification Time
sudo find / -name "*.conf" -mtime 7
Locating Files by Size
sudo find /var -size +2G
-size 100b
-size +100k
-size -20M
-size +2G
Acting on the Result Set
find . -name "*.conf" -exec chmod 644 '{}' \;
Using grep to Filter for Files Based on Content
find . -type f -exec grep "lpi" '{}' \; -print
find . -name "*.bak" -delete
Archiving Files
The tar Command (Archiving and Compresssion)
--create (-c)
--extract (-x)
--list (-t)
--verbose (-v)
--file=archive=name (-f archive-name)
tar -cvf archive.tar stuff
-c Create an archive.
-v Display progress
-f Allows to specify the filename of the archive.
tar -cvf NAME-OF-ARCHIVE.tar /PATH/TO/DIRECTORY-OR-FILE
tar -cvf archive.tar stuff1 stuff2
tar -xvf archive.tar
tar -xvf archive.tar -C /tmp
Compressing with tar
tar -czvf name-of-archive.tar.gz stuff
tar -cjvf name-of-archive.tar.bz stuff
tar -xzvf archive.tar.gz
gzip FILE-TO-COMPRESS
gzip
gunzip
bzip2
bunzip2
The cpio Command
ls | cpio -o > archive.cpio
cpio -id < archive.cpio
The dd Command
dd if=oldfile of=newfile
dd if=oldfile of=newfile conv=ucase
dd if=/dev/sda of=backup.dd bs=4096
Guided Exercises
find /home/frank/Documents/ -type d
tar cvzf /home/frank/backup.tar.gz /home/frank/dir1
find /var -name *.backup
find /var -name *.backup -size +100M -size -1000M
find /var -name *.backup -size +100M -size -1000M -delete
tar -cvf db-first-quarter-2018.backup.tar db-jan-2018.backup db-feb-2018.backup db-march-2018.backup db-apr-2018.backup
tar -zcvf db-first-quarter-2018.backup.tar.gz db-jan-2018.backup db-feb-2018.backup db-march-2018.backup db-apr-2018.backup
Find Criteria
-daystart
-amin, -atime, -cmin, -ctime, -mmin, and -mtime
-amin n
File was last accessed n minutes ago.
+n for greater than n
-n for less than n
n for exactly n.
-atime n
File was last accessed n*24 hours ago
-cmin n
File's status was last changed n minutes ago
-ctime n
File's status was last changed n*24 hours ago
-a : accesado -c:change, -m:modified
Exampes find
find /tmp -name core -type f -print | xargs /bin/rm -f
los nombres que contienen comillas simples o dobles, espacios o nuevas líneas no se manejan correctamente
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
los nombres que contienen comillas simples o dobles, espacios o nuevas líneas se manejan correctamente
-printf0
Le dice a find que imprima todos los resultados en std, cada uno separado con el carácter ASCII NUL "\ 000"
xargs -0 Le dice a xargs que la entrada se separará con el carácter ASCII NUL "\ 000"
find . -type f -exec file '{}' \;
find / \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \ \( -size +100M -fprintf /root/big.txt '%-10s %p\n' \)
find $HOME -mtime 0
find /sbin /usr/sbin -executable \! -readable -print
find . -perm 664
find . -perm -664
find . -perm /222
find . -perm /220 find . -perm /u+w,g+w find . -perm /u=w,g=w
find . -perm -220 find . -perm -g+w,u+w
find . -perm -444 -perm /222 \! -perm /111 find . -perm -a+r -perm /a+w \! -perm /a+x
find -type d -fprint allDirs -o -type f -fprint allFiles
sudo find . -name \*.php -type f -exec grep -Hn '$test' {} \;
find . -name \*.php -type f -exec grep -Hn '$test' {} \+
find . -name \*.php -type f -print0 | xargs -0 -n1 grep -Hn '$test'
find . -name \*.php -type f -print0 | xargs -0 grep -Hn '$test'
Si no se especifica -n [int], xargs usa el valor predeterminado de -n5000
time find . -name \*.php -type f -exec grep -Hn '$test' {} \
time: determine tiempo de ejecucion
time find . -name \*.php -type f -exec grep -Hn '$test' {} \+
time find . -name \*.php -type f -print0 | xargs -0 -n1 grep -Hn '$test'
time find . -name \*.php -type f -print0 | xargs -0 -grep -Hn '$test'
-n1 Le dice a xarg que ejecute el comando [cmd] con un solo argumento (en este caso, solo se encuentra un archivo mediante la búsqueda).
find . -name \*.log -mtime +30 | xargs -n 500 rm
find . -name \*.log -mtime +30 -print0 | xargs -0 -n 500 rm
eliminar 1.2 millones de archivos en un directorio de más de 30 días
find . -maxdepth 1 -type f -name "*.txt" -size 1205c -print0 | xargs -0 ls -l
find . -maxdepth 1 -type f -name "*.txt" -size 1205G -print0 | xargs -0 ls -l
Show full summary
Hide full summary
Want to create your own
Mind Maps
for
free
with GoConqr?
Learn more
.
Similar
103.3 Perform basic file management
Rolando Martinez
101-500
Victor Santillan
Limits AP Calculus
lakelife62
Tir na nOg - Treithe an bhealoidis
08aliso.burge
A level Henry VIII: Foreign policy
avocadolover
Know the principles of electricity
Vito Martino
Of Mice and Men
becky_e
The English Language Techniques
craycrayley
Compensation
Sandra Reed
Test Primer Parcial - Tecnologías de la Información I
Ing. José Luis A. Hernández Jiménez
2PR101 1.test - Doplňující otázky
Nikola Truong
Browse Library