0Pricing
Linux Command Line Mastery · Aula

Pesquisa de arquivos: `find` e `locate`

Descubra ferramentas poderosas para pesquisar arquivos e diretórios com eficiência em todo o sistema, com base em diversos critérios.

Pesquisa de arquivos: `find` e `locate` é uma aula grátis de Linux Command Line Mastery no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Linux Command Line Mastery, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Linux Command Line Mastery inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Find Your Files!

Ever lost a file or needed to find all documents of a certain type on your Linux system? It happens to everyone!

The Linux terminal offers powerful tools to help you search for files and directories efficiently. In this lesson, we'll explore two essential commands: locate and find.

`locate`: The Quick Search

First up is locate. This command is incredibly fast because it doesn't search your filesystem directly in real-time. Instead, it queries a pre-built database of all files on your system.

Think of it like searching an index in a book – it's quick, but the index might not always be perfectly up-to-date.

Basic `locate` Usage

Using locate is straightforward. Just type locate followed by the filename or pattern you're looking for. It will show you all paths that contain that string.

For example, to find all files named "my_document.txt":

locate my_document.txt

Updating `locate`'s Database

Since locate uses a database, its results can sometimes be outdated if new files have been created or deleted since the last database update.

To refresh the database, you can run the updatedb command. This usually requires administrator (root) privileges:

sudo updatedb

`find`: The Real-Time Search

While locate is fast, find is much more powerful and always up-to-date. Instead of a database, find actively traverses your filesystem in real-time, checking every file and directory against your criteria.

This makes find slower than locate for simple searches, but it's perfect for complex, real-time, and precise searches.

`find` Command Structure

The basic syntax for find is:

find [path] [expression]

`find` by Name

One of the most common ways to use find is to search for files by their name. You use the -name option, and you can include wildcards like * (any characters) and ? (any single character).

To find all files ending with .log in your home directory:

find /home -name "*.log"

`find` by File Type

find can also filter results by file type. This is super useful when you only want to see directories or regular files.

  • -type f: Searches for regular files.
  • -type d: Searches for directories.

To find all directories starting with "project" in the current location:

find . -type d -name "project*"

`find` by File Size

Need to find large files taking up space? The -size option is your friend! You can specify sizes using suffixes like c (bytes), k (kilobytes), M (megabytes), G (gigabytes).

  • +: Greater than specified size.
  • -: Less than specified size.
  • No prefix: Exactly specified size.

Example: Find files larger than 10MB in the current directory.

find . -size +10M -name "*.zip"

Comparing Search Tools

You've learned about locate and find. Which of the following statements about these commands are TRUE?

Recap: Finding Files

Great job! You now have two powerful tools for searching files on your Linux system:

  • locate: Fast, database-driven searches. Great for quick checks but needs updatedb for freshness.
  • find: Slower but real-time, powerful, and highly customizable. Essential for complex searches by name, type, size, and more.

Practice using both commands to become a master file finder!

Perguntas Frequentes

A aula “Pesquisa de arquivos: `find` e `locate`” é grátis?

Sim — o texto completo de “Pesquisa de arquivos: `find` e `locate`” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Linux Command Line Mastery, atualize para CoddyKit PRO. O curso de Linux Command Line Mastery inclui 4 aulas no total.

O que vou aprender em “Pesquisa de arquivos: `find` e `locate`”?

Descubra ferramentas poderosas para pesquisar arquivos e diretórios com eficiência em todo o sistema, com base em diversos critérios. Você pratica Linux Command Line Mastery com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Linux Command Line Mastery?

Nenhuma experiência prévia é necessária. Linux Command Line Mastery no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Pesquisa de arquivos: `find` e `locate`”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Linux Command Line Mastery?

Sim. Cada aula de Linux Command Line Mastery inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Visualização do conteúdo de arquivos: `cat`, `less`, `more`
  2. Pesquisa de arquivos: `find` e `locate`
  3. Permissões e propriedade: `chmod`, `chown`
  4. Criando e Seguindo Links Simbólicos
← Voltar para Linux Command Line Mastery