Friday, August 28, 2015

Ubuntu Command Line Interface (CLI) Find Command - How to Find FIles In Ubuntu With Terminal.

The Fantastic Find Command:

Ubuntu and most Linux distributions (called distro's) come standard with a GUI (graphic user interface) file management system. In other words this file manager may look pretty, and is even almost adequately functional to the casual user. From a power-users perspective though, the GUI is notoriously more frustrating then practical. Querries are often incomplete, and because of the open source nature of Linux files and packages are often installed incorrectly.

Besides... if you wanted a pretty, bloated, function less, overpriced, virus magnet, by all means Windows 10 is coming out....but that's not you or me, is it?

The real power of Linux lies in the CLI... so lets start looking for nerd-zen and bust through that learning curve.

Locate

The Locate command will not show files that you don't have access to. (examples would be hidden system files, protected user files etc)

Open up Terminal:
locate -i file.extension   
eg: locate -i kdenlive.desktop
{note: the "-i" tells Linux to turn off case sensitivity....unlike Windows, Linux is case sensative}

Find

To find files that are hidden and/or assign modifiers to your querries use the: find command
To gain access to hidden files, directories and packages you need to log in as super user.

Open up Terminal
sudo find / -type f -mmin -10 
{sudo = super user, find = find, / = which directory to explore, this / tells Linux to look in the root directory, -type f = normal file type's,  -mmin -10 = finding files that were modified less then 10 minutes ago. the 10 can be substituted with any time you need that fits your situation}

Find and Execute a command at the same time

How to find a file/package/directory/etc and execute a command to it at the same time

Open up Terminal
find ~ -iname "*xxx*" -exec mv -v {} /media/pr
{find =find, ~ = in home directory,  -iname  = ignore case ,"*xxx*" package containing "xxx", -exec = execute,  mv -v {} /media/pr }





No comments:

Post a Comment