Linux: How To find files or directories

There are different linux commands to locate files in linux system.you can use linux find command to search files or use locate comand to locate a file position quickly. Or use another linux command whereis to locate the binary,sourcea and manual page files for a command. there is another command is which command, which is use to locate the executable file associated with a given command.

Examples:

#1 find all files in the current directory using linux find command

type:

find . -type f

outputs:

[root@devops Desktop]# find . -type f

./aaa

./epel-release-7-5.noarch.rpm

#2 locate a file in the current directory using linux locate command

type:

locate foo*

outputs:

[root@devops home]# locate foo*

/home/foo

/home/foo.txt

...

/usr/lib64/pygtk/2.0/demos/images/gnome-foot.png

/usr/lib64/python2.7/__phello__.foo.py

/usr/lib64/python2.7/__phello__.foo.pyc

/usr/lib64/python2.7/__phello__.foo.pyo

/usr/share/automake-1.13/am/footer.am

/usr/share/doc/krb5-workstation-1.11.3/_static/bgfooter.png

/usr/share/doc/python-mako-0.8.1/examples/bench/cheetah/footer.tmpl

/usr/share/pixmaps/gdm-foot-logo.png

/usr/share/yelp-xsl/xslt/docbook/html/db2html-footnote.xsl

/usr/src/kernels/3.10.0-123.el7.x86_64/arch/arm/mach-footbridge

#3 find a path of a command using whereis linux command

type:

whereis cat

output:

[root@devops home]# whereis cat

cat:

/usr/bin/cat

/usr/share/man/man1/cat.1.gz

/usr/share/man/man1p/cat.1p.gz

#4 find the executable file for a given command using linux which command

type:

which grep

outputs:

[root@devops home]# which grep

alias grep='grep --color=auto'

/usr/bin/grep

done…

You might also like:

Sidebar



back to top