How to Find a Directory in Linux
Ads by Google
Linux comes with lots of tools to manage files and folders. For a computer user who shifted from windows to Linux, he might find file management a little daunting. In this article we are going to learn how to find a directory in Ubuntu (A popular distribution of Linux).
Using ‘find’ command
The easiest way to find a directory is using the find command. The general syntax of find command is as following:
“/directory/to/search/in” is the starting directory for the search, options is the criteria for search
expression is used to find files that match the given expression.
Examples:
If you want to search a folder for a certain file or directory, we can do it in the following manner.
we have a folder named ‘docs’ in our users home directory. We want to find the ‘notes’ directory present in ‘docs’ directory.
The docs folder contains three more directories; therefore, it can be tedious to search all directories for a certain folder we need. The ‘find’ command can help us here.
We give the starting directory and the name of the directory of file we need to find and the ‘find’
command will provide us with the exact directory location.
We can also search a file using find command.
If we want to only find directory, we can specify it by using the ‘type’ parameter.
‘-type d ‘ specifies that the ‘find’ command will only return locations of the directories matching the name provided. If a file also has the same name as the directory we are trying to find,
‘type -d’ will remove that file from the results provided.
If we want to use the root directory as the starting location for the search, we need it to run the command as root user.
If we want detailed info about the results or our search we can use the -ls parameter.
We can also perform a case insensitive search by using the ‘-iname’ parameter instead of ‘-name’.
By using ‘iname’ the pattern ‘apt’ matches directory names such as ‘Apt’, ‘aPT’, ‘APT’ etc.
Using ‘locate’ command
Linux provides as with another command to search directories. The general syntax of locate command is as follows:
We can use locate to find the ‘notes’ directory as we did before.
The ‘find’ and ‘locate’ commands are the most accessible and easy to use commands. There are also several other third-party utilities available that can be used for searching. This versatility is what makes Linux so popular.
How do I search for a directory in Linux?
- To list all files in the current directory, type the following: ls -a This lists all files, including. dot (.)
- To display detailed information, type the following: ls -l chap1 .profile.
- To display detailed information about a directory, type the following: ls -d -l .
How do I find my directory?
How do I use grep to find a directory?
How do you create a directory?
- Creating Folders with mkdir. Creating a new directory (or folder) is done using the “mkdir” command (which stands for make directory.)
- Renaming Folders with mv. The “mv” command works exactly the same with directories as it does with files.
- Moving Folders with mv.
What is a directory within a directory called?
Does planning center have a church directory?
What does Directory mean in history?
Can you join an online church?
Is church a online?
Is elevation worship a church?
What’s wrong with Elevation Church?
Who is the pastor of Elevation Worship?
Who is the drummer for elevation worship?
What is a worship drummer?
Ads by Google