103.3 Perform basic file management

Description

103.3 Perform basic file management
Rolando Martinez
Mind Map by Rolando Martinez, updated more than 1 year ago
Rolando Martinez
Created by Rolando Martinez over 3 years ago
11
0

Resource summary

103.3 Perform basic file management
  1. How to Find Files
    1. find STARTING_PATH OPTIONS EXPRESSION
      1. find . -name "myfile.txt"
        1. find /home/frank -name "*.png"
        2. Using Criteria to Speed Search with find
          1. -type f archivo plano -type d archivo directorio -type l archivo link
            1. find . -type d -name "example"
            2. criterio
              1. -name
                1. -iname
                  1. -not
                    1. -maxdepth N
                  2. Locating Files by Modification Time
                    1. sudo find / -name "*.conf" -mtime 7
                    2. Locating Files by Size
                      1. sudo find /var -size +2G
                        1. -size 100b
                          1. -size +100k
                            1. -size -20M
                              1. -size +2G
                    3. Acting on the Result Set
                      1. find . -name "*.conf" -exec chmod 644 '{}' \;
                      2. Using grep to Filter for Files Based on Content
                        1. find . -type f -exec grep "lpi" '{}' \; -print
                          1. find . -name "*.bak" -delete
                        2. Archiving Files
                          1. The tar Command (Archiving and Compresssion)
                            1. --create (-c)
                              1. --extract (-x)
                                1. --list (-t)
                                  1. --verbose (-v)
                                    1. --file=archive=name (-f archive-name)
                                  2. tar -cvf archive.tar stuff
                                    1. -c Create an archive.
                                      1. -v Display progress
                                        1. -f Allows to specify the filename of the archive.
                                        2. tar -cvf NAME-OF-ARCHIVE.tar /PATH/TO/DIRECTORY-OR-FILE
                                          1. tar -cvf archive.tar stuff1 stuff2
                                            1. tar -xvf archive.tar
                                              1. tar -xvf archive.tar -C /tmp
                                              2. Compressing with tar
                                                1. tar -czvf name-of-archive.tar.gz stuff
                                                  1. tar -cjvf name-of-archive.tar.bz stuff
                                                    1. tar -xzvf archive.tar.gz
                                                    2. gzip FILE-TO-COMPRESS
                                                      1. gzip
                                                        1. gunzip
                                                        2. bzip2
                                                          1. bunzip2
                                                        3. The cpio Command
                                                          1. ls | cpio -o > archive.cpio
                                                            1. cpio -id < archive.cpio
                                                            2. The dd Command
                                                              1. dd if=oldfile of=newfile
                                                                1. dd if=oldfile of=newfile conv=ucase
                                                                  1. dd if=/dev/sda of=backup.dd bs=4096
                                                                  2. Guided Exercises
                                                                    1. find /home/frank/Documents/ -type d
                                                                      1. tar cvzf /home/frank/backup.tar.gz /home/frank/dir1
                                                                        1. find /var -name *.backup
                                                                          1. find /var -name *.backup -size +100M -size -1000M
                                                                            1. find /var -name *.backup -size +100M -size -1000M -delete
                                                                              1. tar -cvf db-first-quarter-2018.backup.tar db-jan-2018.backup db-feb-2018.backup db-march-2018.backup db-apr-2018.backup
                                                                                1. 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
                                                                              2. Find Criteria
                                                                                1. -daystart
                                                                                  1. -amin, -atime, -cmin, -ctime, -mmin, and -mtime
                                                                                    1. -amin n
                                                                                      1. File was last accessed n minutes ago.
                                                                                      2. +n for greater than n
                                                                                        1. -n for less than n
                                                                                          1. n for exactly n.
                                                                                            1. -atime n
                                                                                              1. File was last accessed n*24 hours ago
                                                                                              2. -cmin n
                                                                                                1. File's status was last changed n minutes ago
                                                                                                2. -ctime n
                                                                                                  1. File's status was last changed n*24 hours ago
                                                                                                  2. -a : accesado -c:change, -m:modified
                                                                                              3. Exampes find
                                                                                                1. find /tmp -name core -type f -print | xargs /bin/rm -f
                                                                                                  1. los nombres que contienen comillas simples o dobles, espacios o nuevas líneas no se manejan correctamente
                                                                                                  2. find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
                                                                                                    1. los nombres que contienen comillas simples o dobles, espacios o nuevas líneas se manejan correctamente
                                                                                                      1. -printf0
                                                                                                        1. Le dice a find que imprima todos los resultados en std, cada uno separado con el carácter ASCII NUL "\ 000"
                                                                                                      2. xargs -0 Le dice a xargs que la entrada se separará con el carácter ASCII NUL "\ 000"
                                                                                                      3. find . -type f -exec file '{}' \;
                                                                                                        1. find / \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \ \( -size +100M -fprintf /root/big.txt '%-10s %p\n' \)
                                                                                                          1. find $HOME -mtime 0
                                                                                                            1. find /sbin /usr/sbin -executable \! -readable -print
                                                                                                              1. find . -perm 664
                                                                                                                1. find . -perm -664
                                                                                                                  1. find . -perm /222
                                                                                                                2. find . -perm /220 find . -perm /u+w,g+w find . -perm /u=w,g=w
                                                                                                                  1. find . -perm -220 find . -perm -g+w,u+w
                                                                                                                    1. find . -perm -444 -perm /222 \! -perm /111 find . -perm -a+r -perm /a+w \! -perm /a+x
                                                                                                                      1. find -type d -fprint allDirs -o -type f -fprint allFiles
                                                                                                                        1. sudo find . -name \*.php -type f -exec grep -Hn '$test' {} \;
                                                                                                                          1. find . -name \*.php -type f -exec grep -Hn '$test' {} \+
                                                                                                                            1. find . -name \*.php -type f -print0 | xargs -0 -n1 grep -Hn '$test'
                                                                                                                              1. find . -name \*.php -type f -print0 | xargs -0 grep -Hn '$test'
                                                                                                                                1. Si no se especifica -n [int], xargs usa el valor predeterminado de -n5000
                                                                                                                                  1. time find . -name \*.php -type f -exec grep -Hn '$test' {} \
                                                                                                                                    1. time: determine tiempo de ejecucion
                                                                                                                                      1. time find . -name \*.php -type f -exec grep -Hn '$test' {} \+
                                                                                                                                        1. time find . -name \*.php -type f -print0 | xargs -0 -n1 grep -Hn '$test'
                                                                                                                                          1. time find . -name \*.php -type f -print0 | xargs -0 -grep -Hn '$test'
                                                                                                                                    2. -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).
                                                                                                                                2. find . -name \*.log -mtime +30 | xargs -n 500 rm
                                                                                                                                  1. find . -name \*.log -mtime +30 -print0 | xargs -0 -n 500 rm
                                                                                                                                    1. eliminar 1.2 millones de archivos en un directorio de más de 30 días
                                                                                                                                  2. find . -maxdepth 1 -type f -name "*.txt" -size 1205c -print0 | xargs -0 ls -l
                                                                                                                                    1. find . -maxdepth 1 -type f -name "*.txt" -size 1205G -print0 | xargs -0 ls -l
                                                                                                                                  Show full summary Hide full summary

                                                                                                                                  Similar

                                                                                                                                  103.3 Perform basic file management
                                                                                                                                  Rolando Martinez
                                                                                                                                  Food Chains and Food Webs Quiz
                                                                                                                                  Selam H
                                                                                                                                  Cell Structure
                                                                                                                                  daniel.praecox
                                                                                                                                  Physics Revision
                                                                                                                                  Tom Mitchell
                                                                                                                                  BIOLOGY B1 3
                                                                                                                                  x_clairey_x
                                                                                                                                  English Speech Analysis Terminology
                                                                                                                                  Fionnghuala Malone
                                                                                                                                  20 Study Hacks To Improve Your Memory
                                                                                                                                  jen.sch.ca
                                                                                                                                  a christmas carol
                                                                                                                                  maha.als10
                                                                                                                                  SalesForce ADM 201 Study Quiz
                                                                                                                                  Brianne Wright