How to search for files by type?

QuestionsQuestions8 SkillsProYour First Linux LabOct, 16 2025
082

To search for files by type in a Linux system, you can use the find command with the -type option. Here are some common types you can specify:

  • f for regular files
  • d for directories
  • l for symbolic links
  • c for character devices
  • b for block devices
  • s for sockets
  • p for named pipes (FIFOs)

Example Commands

  1. Search for regular files:

    find /path/to/search -type f
  2. Search for directories:

    find /path/to/search -type d
  3. Search for symbolic links:

    find /path/to/search -type l

Example Usage

To search for all regular files in the home directory, you would use:

find ~ -type f

To search for all directories in the /etc directory, you would use:

find /etc -type d

These commands will help you locate files and directories based on their type.

0 Comments

no data
Be the first to share your comment!