How to find files and folders in Linux:
|Workable Solutions||Step-by-step Troubleshooting|
|Find Linux Files and Folders with Command Lines||Use these command lines to find a file in Linux: find ~ -name "filename"; find ~ -mtime – amount of days (in number); find ~ -type (type symbol) –name "filename"; use Locate and Grep commands...Full steps|
|Find a File in Linux Using Terminal||Launch your virtual machine, such as Ubuntu, on your PC. Open your Linux terminal. Enter the file find commands...Full steps|
|Find Deleted or Lost Files in Linux||If you want to find deleted or lost files on Linux, use professional Linux data recovery software...Full steps|
But since Linux is more complicated than other operating systems, it is common to wonder how to use these commands to find files Linux. But don't worry, this article covers all the correct ways to find the lost files and folders in Linux. Let's get started!
How to Find Files and Folders in Linux with Command Lines
Most users use a graphical file manager to search files on Linux, such as Nautilus in Gnome, Dolphin in KDE, or Thunar in Xfce. However, regardless of whatever desktop manager you use, there are various methods to utilize the command line to locate files in Linux.
1. Use Find Command
You can utilize the "find" command to look for files whose names you have an idea of. The most basic version of the command examines the folder and its subdirectories for files that meet the search parameters. Files may be found using a variety of search parameters, including name, owner, group, type, rights, and date.
You can find a file by its filename by utilizing regular expressions to provide the full file name or sections of the file name.
Syntax: find ~ -name "filename"
Use the -mtime option with a (negative) number of days in the past to discover a file you last updated last week.
Syntax: find ~ -mtime – amount of days (in number)
It's usual to optimize the "find" command results by providing the file type you're searching for. The option is -type, and its parameters are letter codes denoting various data types.
Syntax: find ~ -type (type symbol) –name "filename"
Some of the basic type symbols are:
- d - directory
- l - symbolic link
- b - block special
- p - named pipe
- s – socket
- f – file
To understand how to find a file in Linux using the find command, follow these instructions:
Step 1. Open the command line and type cd folder name/, and hit the Enter button.
Note: Here folder name indicates the folder in which you wish to search a file.
Step 2. Now type the find command with one of the above syntaxes according to your need, and press Enter to list the files.
2. Use Locate Command
If you're looking for anything in a database, the locate command is much quicker than the find command since it doesn't have to search over the whole system. For the required parameter and syntaxes, locate command provides a list of all possible pathnames.
In its most basic form, the locate command discovers all files on the file system, beginning with the path that contains all or part of the search parameters.
Syntax: locate filename
Use the -b argument with the locate command to identify all files or directories that match just your search criteria.
Syntax: locate –b \filename
The backslash is a globing character here to expand the wildcards.
To understand how to find a file in Linux using the locate command, follow these instructions:
Step 1. Launch the command line and type sudo apt-get install mlocate to get the locate command. After that, press Enter and type your password to proceed with the installation process.
Step 2. After that, create a database by typing sudo /etc/cron.daily/mlocate on the command line and hit the Enter key.
Note: locate command does not work without a database.
Step 3. Now, write "locate" with any of the above syntaxes and hit the Enter key to locate the file or folder.
3. Use Grep Command
Another way to search the files in Linux with the command line is by using the grep command. Grep allows you to search for the text files.
To find a file that includes a specific sentence or combination of letters, use the grep command using the following syntax.
Syntax: grep -r -i "text" /path
-r: causes the search to be recursive, which means it will scan the current directory and all subdirectories.
-i: specifies that the query is case-insensitive.
You can suppress the matched text and show the file names and paths.
Syntax: grep -r -i "text" /path | cut -d: -f1
When the grep command attempts to access directories without the proper permissions or encounters empty folders, it will produce an error. The error messages could be sent to /dev/null.
Syntax: grep -r -i "text" /path 2>/dev/null
To understand how to find a file in Linux using the grep command, follow these instructions:
Step 1. Open the command line in Linux
Step 2. Now, use grep with any of the above syntaxes to find the file path.
How to Find a File in Linux Using Terminal
Many graphical user interface (GUI) service enables you to browse for files while operating under Linux, regardless of distribution. However, in other cases, such as when managing servers or using SSH to access the service, you will only have accessibility to the Linux terminal.
A Linux terminal is a text-based interface for controlling a Linux machine. It's simply one of several tools accessible to Linux users for completing any given work, but it's often regarded as the most appropriate solution. You can utilize the find, locate, grep, which, and whereis commands to find the find or folders on the Linux terminal.
- The syntax for which command: which filename
- The syntax for whereis command whereis filename
For Linux find a file by name, follow these steps:
Step 1. Launch your virtual machine, such as Ubuntu, on your PC.
Step 2. Open your Linux terminal.
Step 3. Now, enter any of the above-discussed command and their syntax to find the pile or folder you're trying to locate.
Note: To utilize the "find" command, first go to the folder by typing the cd folder name on the terminal.
How to Find Lost or Deleted Files with Linux Data Recovery Software
Lost data and unintentional loss of critical files can be a nightmare. Consider the possibility of mistakenly deleting a collection of your critical work files. While Linux provides the trash bin as a last resort for recovery, there is no chance of recovering once lost from there.
Unless you've been keeping backups, your prospects of recovery are minimal. However, not everyone maintains a backup. In this scenario, you will want specialized data recovery software like EaseUS Data Recovery Wizard.
It is a professional file recovery tool that can recover lost data by utilizing its software algorithm and the fact that the majority of the deleted files are there on the disk but cannot be retrieved. That's how the operating system works. EaseUS data recovery wizard, on the other hand, is intelligent enough to locate them and recover deleted files quickly.
So if you're trying to recover your lost or deleted files on Linux, the EaseUS data recovery wizard is your bet because of its straightforward and efficient interface. Free download this Linux data recovery software and restore your lost data on Windows PC through a simple connection.
Step 1. Install and Launch EaseUS Data Recovery Wizard on your Windows PC. Choose "Linux Recovery" on the left panel.
Step 2. This software will detect your IP and Port automatically. You need to input the user name and password. If the IP address or Port is not right, you can correct it manually. Then, click "Connect Now".
Step 3. After successfully connecting to your Linux device, EaseUS recovery software will start scanning the disk to find all lost and deleted files. When the scan process completes, click "Filter" > "Type" to specify lost file types.
Step 4. You can preview the scanned files first. Then, select the target data and click the "Recover" button to restore lost files in Linux.
Even though Windows is the most commonly used operating system, people still use Linux since it provides more security. However, Linux is a bit complicated compared to Windows, making it difficult to find files in Linux. But with the methods discussed in this article, you can easily find files in Linux.
Moreover, if you've accidentally deleted or lost your files, we recommend using EaseUS Data Recovery Wizard to find the lost files in Linux. Since it provides proper protection to the data, it's your safest the most efficient approach to recovering the files.
Was This Page Helpful?
Cedric Grantham is one of the senior editors and data recovery specialists of EaseUS who lives and works in Chengdu, China. He mainly writes articles and how-to tips about data recovery tutorials on PC and Mac. He has handled 10,000+ data recovery cases and is mainly good at data recovery of NTFS, FAT (FAT32 and ExFAT) file systems, and RAID structure reorganization of RAID 0, 5, and 10.
2 Ways to Recover Deleted or Lost Webcam Videos
Tracy King/Feb 22, 2023
[Solved] Cannot Connect to Camera Please Make Sure to Close Other Apps
Brithny/Feb 22, 2023
[Video Repair] How to Fix 'Moov Atom Not Found' Error
Dany/Apr 17, 2023
How to Fix EaseUS Data Recovery Wizard Crashes, Stuck, Hangs and Freezes Up Error
Tracy King/Feb 22, 2023