Sunday, May 29

Quick Linux Question: Find files or folders in shell?


Using the Linux shell, or command line, can some times be daunting. I will be highlighting a hopefully helpful command in each of these posts.





Question: How can I find where a file or folder is on Linux file system?

Answer: use the "find" command

There are many ways to use the "find" command. Though most of your usage will follow into the pattern of trying to find a specific file or set of files by name.

find . -name file\*

  • the "." means it will start looking in the current directory, and the directories it contains.
  • the "-name" means we are looking for a match with the file name
  • This will find any file with the starting label of "file".
    • if you want to use metacharacters it is best to escape the character with a "\" in front of it.

If you see "find: .... : Permission denied"

This means you are searching in areas that your user rights do not have permission. Your two options are:

  1. sudo find / -name ls 2>/dev/null
    If your user account has administration rights, all you need to do is run the find command with sudo.
  2. find / -name ls 2>/dev/null
    You could also pipe all the errors to null, which would hide the "Permission denied" errors from your view.



--help

0 comments :

Post a Comment