find commandwith path not returning results

General support questions
barry789
Posts: 2
Joined: 2017/10/13 21:00:15

find commandwith path not returning results

Postby barry789 » 2017/10/15 01:16:37

Hi Board Members,
I am currently taking an online course on udemy.com to refresh my very old Linux skills. So consider me a newbie since it has been fifteen years since I was somewhat proficient.

In the course we are covering the "find" command and my results are not what the instructor is returning. When i use find with a path is returns nothing whether the file is there or not. When I use find from the directory it returns the result. For example:
[adminuser@localhost /]$ find /sbin -name zic
[adminuser@localhost /]$ cd /sbin
[adminuser@localhost sbin]$ find -name zic
./zic
[adminuser@localhost /]$ find /sbin -name lkdfhgod
[adminuser@localhost /]$


[adminuser@localhost /]$ find /sbin
/sbin
[adminuser@localhost /]$

Can someone shed some light on this for me? Thanks!

User avatar
TrevorH
Forum Moderator
Posts: 20963
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: find commandwith path not returning results

Postby TrevorH » 2017/10/15 09:27:00

Your example doesn't work because /sbin is now a symlink to /usr/sbin in CentOS 7. Using /usr/sbin (the symlink target) works. To make it follow the symlink you'll need to use find -L /sbin -name zic
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

barry789
Posts: 2
Joined: 2017/10/13 21:00:15

Re: find commandwith path not returning results

Postby barry789 » 2017/10/15 20:24:26

Thank you very much! The instructor must be using an older version as he was using /sbin in his examples, without -L.
I finally figured it out a few minutes ago when I did this:
[adminuser@localhost /]$ find /usr -name zic
/usr/sbin/zic

Thank you for confirming that /sbin was not formerly a symlink, that clears up the confusion.