How To Find a Directory On Linux Based System

Configurare noua (How To)

Situatie

The find command will search live file-system for files that match the search criteria.

Solutie

Pasi de urmat

How to find a directory on Linux

The find command syntax is:
find /where/to/look/up criteria action
OR
find /dir/path/look/up criteria action
OR
find /dir/path/look/up -name "dir-name-here"
OR
find /dir/path/look/up -name "pattern"
OR
find /dir/path/look/up -name "dir-name-here" -print
OR
find /dir/path/look/up -name "dir-name-here"
OR
find / -name "dir-name-here"
OR
find / -type d -name "dir-name-here"
OR
find / -type d -name "dir-name-here" 2>/dev/null

Linux find directory command

The following example will show all files in the current directory and all subdirectories:

find 
find .
find . -print

Finding a directory

To find a directory called apt in / (root) file system, enter:

Alert: When searching / (root) file system, you need to run the find command as root user.

find / -type d -name "apt" 
sudo find / -type d -name "apt"

Sample outputs:

/var/log/apt
/var/lib/apt
/var/cache/apt
/etc/apt
/etc/logrotate.d/apt
/etc/cron.daily/apt

Tip solutie

Permanent

Voteaza

(11 din 28 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?