In this tutorial we will show you how to use unix commands to find certain directories present on your system.
You can use the find unix command to locate files on your hard drive. You can add various filters along with the command to narrow down your search.
To understand how to do this, follow the steps given below.
Step 1 – Enter command
First of all type in the command find / -name root and hit the enter key.
Step 2 – Locate files
This will locate all the files named “root” including sub directories and even the mounted file systems.
Step 3 – Locate files under a specific directory
If you want to locate all the files under a particular directory which are owned by the root user, type
find /home –user root and hit enter.
And you can see that all the files owned by the root user located in the home directory are being displayed in the results.
Step 4 – Locate files according to their modification dates
Similarly, you can search for files using the find unix command according to the date they were modified. For that you will use the find keyword followed by the address and the -mtime command. After that we will specify the time duration. If we write plus 60 over here, all the files that were modified more than 60 days ago will be displayed in the results.
Step 5 – Locate restricted directories
Another way to search through the files is using the hidden attribute, the $ sign.
Let’s look an example over here. The Home directory is by default a restricted directory, so if you want to search through the root directories or restricted directories in Linux through command line, you will use the dollar sign over here instead of typing up the path.
And that’s all, through this way you can use unix commands to find the directories you are searching for.