Skip to content

Latest commit

 

History

History
118 lines (93 loc) · 3.48 KB

File metadata and controls

118 lines (93 loc) · 3.48 KB

Locate and Find Commands

To hide icons for standard folders like "Documents," "Downloads," etc., on the Ubuntu desktop, follow these steps:

Using GNOME Tweaks (if you have GNOME desktop environment)

  1. Install GNOME Tweaks (if not already installed):
    sudo apt install gnome-tweaks
  2. Open GNOME Tweaks.
  3. Go to Desktop or Extensions > Desktop Icons.
  4. Toggle off Show Personal Folder or individual options for specific folders like Documents, Downloads, etc.

Using dconf Editor

If GNOME Tweaks doesn’t work, you can use dconf Editor:

  1. Install dconf Editor if it's not installed:
    sudo apt install dconf-editor
  2. Open dconf Editor and navigate to:
    org > gnome > shell > extensions > desktop-icons
    
  3. Find options like show-home, show-documents, show-downloads, etc., and turn them off.

Here's a detailed breakdown and commands for using locate, including options for database updates and filtering results.

Reason for locate Options

The locate command uses a pre-built database to quickly find files. This database is updated only once daily by default, which means recent file changes (creations or deletions) might not appear in the search results until the next update.

To refine your search results with specific criteria:

  • Use -e or --existing to check if files still exist before displaying results.
  • Use -L or --follow to check if symbolic links point to valid files. Broken symbolic links will be excluded from the results.

Examples of Locate Options

  • To check existing files and exclude broken links:

    locate --existing --follow *.txt
  • Combining options: You can combine options to ignore case, check existing files, follow valid symbolic links, and limit results:

    locate --existing --follow -i --limit 5 *.conf | wc -l

    Here, wc -l counts the output lines for comparison.

    Observe the Differences:

    locate *.conf | wc -l
    locate -i *.conf | wc -l
    locate --existing -i *.conf | wc -l
    locate --existing --follow -i *.conf | wc -l
    locate --existing --follow -i --limit 10 *.conf | wc -l

Updating the Locate Database

The locate database can be updated manually with the updatedb command. This is useful if you've recently added or deleted files and want locate to reflect the changes immediately.

  1. Update the Database:

    sudo updatedb
  2. Check Database Details: Use locate -S to see database statistics (if supported on your system):

    locate -S

    Example Output:

    Database /var/lib/mlocate/mlocate.db:
    39,527 directories
    369,078 files
    242,425,20 bytes in file names
    9,340,974 bytes used to store database
    

Q1) Which of the following are Valid Options for the locate Command?
Options:

  • A) -i
  • B) --limit
  • C) -L
  • D) -e
  • E) --existing
  • F) --follow
  • G) All of these

Answer: G


Q2) Does the Locate Command Internally Use a Database to Find Results?
Options:

  • True
  • False

Answer: True


Q3) We Created a File Called demo.txt. It Has Been 2 Hours Since the Locate Database Was Last Updated. Is the Locate Command Able to Find This demo.txt?
Options:

  • A) Yes
  • B) No

Answer: B (No)


Q4) How to Update the Database Used by the Locate Command?
Options:

  • A) update locatedb
  • B) updatedb
  • C) sudo updatedb

Answer: C