Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find a specific file from a Linux terminal?

Tags:

linux

debian

I am trying to find where index.html is located on my linux server, and was wondering if there was a command to do that. Very new to linux and appreciate any help I can get.

like image 940
Andy Avatar asked Sep 18 '11 04:09

Andy


People also ask

How do I find a specific folder in Linux terminal?

1 Open your favorite terminal app. ... 2 Type the following command: find /path/to/folder/ -iname *file_name_portion* The arguments above are as follows: /path/to/folder/ - the folder where to begin searching. ... 3 If you need to find only files or only folders, add the option -type f for files or - type d for directories. ... More items...

How do I search for a specific file in Linux?

1. Search for a file by its file name. This is the most basic search you can perform using the find command. The command below will search for the query in the current directory and any subdirectories. find -iname "filename". Using -iname instead of -name ignores the case of your query.

What does {} mean in a Linux terminal?

The " {} " portion stands for files found by the find command. The "\;" ending specifies the end of the command for the -exec option. The locate search tool uses a special file database to find files instantly. The index for the command can be created and updated by the updatedb command.

How do you search for files in terminal?

Also, there's Catfish, a popular search tool with a search index, which can find your files really quickly. I would like to share the methods I use myself when I work in terminal. The first method involves the find utility, which exists in any distro, even in embedded systems built on busybox. The other method is the locate command.


2 Answers

Find from root path find / -name "index.html"

Find from current path find . -name "index.html"

like image 80
datalost Avatar answered Sep 28 '22 07:09

datalost


The below line of code would do it for you.

find / -name index.html

However, on most Linux servers, your files will be located in /var/www or in your user directory folder /home/(user) depending on how you have it set up. If you're using a control panel, most likely it'll be under your user folder.

like image 42
Taylor Jasko Avatar answered Sep 28 '22 09:09

Taylor Jasko