From 2f570caf75b75157c0af968cd72a5ffeb3d49dc9 Mon Sep 17 00:00:00 2001 From: Yuri Slobodyanyuk Date: Mon, 20 Mar 2023 16:58:39 +0000 Subject: [PATCH 1/7] ongoing additions, changes, and fixes --- ...e-debug-diagnose-complete-cheat-sheet.adoc | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc b/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc index dc3fc74..885cee7 100644 --- a/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc +++ b/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc @@ -1007,6 +1007,29 @@ format). |=== +== Automation stitches debug + +[cols=2, options="header"] +|=== +|Command +|Description + +|*diag test app autod 1* +|Enable automation stitches logging. + +|*diag debug cli 7* +|Show stitches' running log on the CLI. + +|*diag debug enable* +|Enable debug. + +|*diagnose automation test * +|Run the specified _stitch name_, optionally adding log when using Log based +events. + +|=== + + == Alerts Sending debug [cols=2, options="header"] From 85259c8edd86fb588417602506813d0125512c01 Mon Sep 17 00:00:00 2001 From: Yuri Slobodyanyuk Date: Mon, 20 Mar 2023 17:00:25 +0000 Subject: [PATCH 2/7] ongoing additions, changes, and fixes --- cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc b/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc index 885cee7..769fd87 100644 --- a/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc +++ b/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc @@ -1023,7 +1023,7 @@ format). |*diag debug enable* |Enable debug. -|*diagnose automation test * +|*diagnose automation test _stitch-name_ _log if needed_* |Run the specified _stitch name_, optionally adding log when using Log based events. From 54ebfb1d3243f3a95e249b2d6d07d36c1e7085fd Mon Sep 17 00:00:00 2001 From: Yuri Slobodyanyuk Date: Mon, 20 Mar 2023 17:00:54 +0000 Subject: [PATCH 3/7] ongoing additions, changes, and fixes --- cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc b/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc index 769fd87..cfc356c 100644 --- a/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc +++ b/cheat-sheets/Fortigate-debug-diagnose-complete-cheat-sheet.adoc @@ -1023,7 +1023,7 @@ format). |*diag debug enable* |Enable debug. -|*diagnose automation test _stitch-name_ _log if needed_* +|*diagnose automation test _stitch-name_ _log-if-needed_* |Run the specified _stitch name_, optionally adding log when using Log based events. From 4e20bfb00eeaaba93a026d013eff3ded75c841be Mon Sep 17 00:00:00 2001 From: Yuri Slobodyanyuk Date: Tue, 28 Mar 2023 11:12:39 +0000 Subject: [PATCH 4/7] Added mdfind macOS cheat sheet --- .../macos-mdfind-examples-cheat-sheet.adoc | 222 ++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 cheat-sheets/macos-mdfind-examples-cheat-sheet.adoc diff --git a/cheat-sheets/macos-mdfind-examples-cheat-sheet.adoc b/cheat-sheets/macos-mdfind-examples-cheat-sheet.adoc new file mode 100644 index 0000000..31f3f56 --- /dev/null +++ b/cheat-sheets/macos-mdfind-examples-cheat-sheet.adoc @@ -0,0 +1,222 @@ += macOS `mdfind` examples cheat sheet +:source-highlighter: rouge +:date: 2023-03-28 09:55:25+00:00 +:slug: mdfind-macos-examples-cheat-sheet +:category: macOS +:tags: macOS, Apple +:toc: + +== Introduction +`mdfind` is a command-line interface to the SpotLight search tool on every +Apple macOS system. Being a CLI tool, it saves time when searching for stuff in +your Mac. Unfortunately, there is a lot of documentation on the topic which is +out of date - the examples either do not work or give an error. Otherwise, the +tool is not well-documented. Below are few examples for every day usage, tested +on the newest versions - Catalina, Big Sur, Monterrey, Ventura. + +== Find files with a given word in it +Just give the `mdfind` a word to search for, and it will find it in +file/media/applications +names, as well as in their contents. + +---- +mdfind mysearchword +---- + +== Search for a word in file names only, not their contents +Add `-name` qualifier before the search word. + +---- +mdfind -name October +---- + +Will find files named: _OctoberFest.pdf_, _inoctober.txt_, _Red October.mp4_ + + +== Find a file with multiple keywords in its name +We can specify more than 1 word to look for in the file/app name - the `mdfind` +uses logical AND by default for multiple keywords. + +---- +mdfind -name red october +---- + +Will find: _Red October.mp4_, _red octoberfest.jpg_, but NOT _red.pdf_ or +_October.mp4_. + + +== Limit search to specific file format(s) +You can use ``kind:``__file-format__ to additionally limit results to this file +format. Be aware that _kind_ is not always the file extension though. I list the +most popular file formats below. + +Find file with the _red_ in its name, but only in _mp4_, _.mov_ etc. files: + +---- +mdfind -name red kind:movie +---- + +|=== + +|*File format* |*kind term* |*File format* |*kind term* + +|jpeg/jpg, png, gif, tiff +|image +|Application +|app + +|mp3, ogg +|music +|mp4, mov, mpeg +|movie + +|Bookmarks +|bookmark +|Email messages +|email + +|Folders +|folder +|MS Word docs (docx, dot) +|word + +|=== + + +The other way to look for file extensions is with the _kMDItemFSName_ metadata +value and listing the desired extension after the asterisk. + +---- +mdfind "kMDItemFSName == '*.pdf'" +---- + +But if you want to look for a specific file name as well, you will have to pipe the +command above to _grep_ or alike. + + + + +== Look up folder names +Using (see table above) `kind:folder` we can search in folder names only. + +Find all folders with the name _document_ in them: + +`mdfind -name documents kind:folder` + +== Search for an exact match +We can do it in 2 ways. +First, wrapping search terms in double and then single quotes: + +---- +mdfind -name '"red carpet"' +---- +This will match _red carpet.txt_, but not _red 2 carpet.txt_. + +The other way to look for an exact match is with the `-literal` qualifier, which prohibits any other qualifier though. + +Find everything having _Hat, Red_ in the name: + +`mdfind -literal "kMDItemDisplayName == 'Hat, Red'"` + +Here, *kMDItemDisplayName* is a metadata field holding the item name for files/folders/etc. Any additional options will be ignored. + + + +== Search in specific folder(s) only +We can use *-onlyin* option to limit the search: + +`mdfind -name red.txt -onlyin ~/Documents` + +This will only search in the folder _Documents_ and its subfoldes. + + +== Search by created, modified dates +IMPORTANT: The date format is your current locale. So, I put dates in the +_19/1/2023_ format, but if your Mac is set to use _1/19/2023_, do so. + +Find file named _red_ and created on 19th of January 2023: + +`mdfind -name red AND created:19/1/2023` + +NOTE: The _AND_ is not explicitly needed here, but I put it for reminder yet. + +Find file named _red_ modified on 19th of January 2023: + +`mdfind -name red AND modified:19/1/2023` + +The date-related searches also understand ranges. + +Find files with _red_ in their name modified in the period from the 1st of January +2023, and up to (including) 19th of January 2023: + +`mdfind -name red modified:01/01/2023-19/1/2023` + +Same, but _created_ in that period: + +`mdfind -name red created:01/01/2023-19/1/2023` + + +== Find file by their size +We can specify file size as additional search term. +This will find files with the _red_ in their names AND of size 0 bytes. + +`mdfind name:red AND size:0` + + +`mdfind name:red AND NOT size:0` will find files named _red_ that are NOT 0 +bytes in size. + + +We can provide ranges for sizes as well. To find files named _red_ of size +between 10 and 25 bytes: + +`mdfind -interpret name:red AND size:\<25 AND size:\>10` + +NOTE: The '\' escapes '<' and '>' from the shell interpretation. + + +== Disable Spotlight/mdfind indexing for a specific volume + +* Spotlight (and thus mdfind) stores its index for each hard drive in a hidden +directory named `.Spotlight-V100` located at the root of each disk. You can list this directory contents with +sudo mdutil -L _path-to-the-disk_* , e.g. + +---- +sudo mdutil -L /Volumes/exFAT1Tb + + +/Volumes/exFAT1Tb/.Spotlight-V100: +drwxrwxrwx 1 99 99 262144 Jun 27 2021 07:46 Store-V2 +-rwxrwxrwx 1 99 99 4246 Jun 13 2022 11:09 +VolumeConfiguration.plist + +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2: +drwxrwxrwx 1 99 99 262144 Jun 27 2021 07:46 B332121F-C8CA-4FF1-924A-67FC321C3FFCC/ + + +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.assisted_import_post: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.assisted_import_pre: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.corespotlight: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.health_check: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.live: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.live_priority: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.live_system: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.live_user: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.migration: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.migration_secondchance: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.repair: +/Volumes/exFAT1Tb/.Spotlight-V100/Store-V2/B332121F-C8CA-4FF1-924A-67FC321C3FFCC/journals.scan: + +---- + +* For space savings or privacy concerns, you can turn off indexing of a given volume by running +*sudo mdutil -i off /Volumes/__volume-name__*, and even +erase the existing index with *sudo mdutil -E /Volumes/__volume-name__*. + + +== Resources +* For additional cheat sheets, see Github: https://github.com/yuriskinfo/cheat-sheets + + +_Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I +publish on Linkedin, Github, blog, and more._ From 73a6b594ca433a08cb23ff84bdced3bd63e35e87 Mon Sep 17 00:00:00 2001 From: Yuri Slobodyanyuk Date: Tue, 28 Mar 2023 11:20:21 +0000 Subject: [PATCH 5/7] ongoing additions, changes, and fixes --- ...witches-debug-and-diagnostics-commands-cheat-sheet.adoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cheat-sheets/Aruba-HP-switches-debug-and-diagnostics-commands-cheat-sheet.adoc b/cheat-sheets/Aruba-HP-switches-debug-and-diagnostics-commands-cheat-sheet.adoc index e64d870..cdc00b6 100644 --- a/cheat-sheets/Aruba-HP-switches-debug-and-diagnostics-commands-cheat-sheet.adoc +++ b/cheat-sheets/Aruba-HP-switches-debug-and-diagnostics-commands-cheat-sheet.adoc @@ -297,6 +297,13 @@ a|Debug various routing processes. The _routing-process_ is one of the: * `pim` Enable/disable tracing of PIM messages. * `rip` Display all RIP routing messages. + +|*show ip ssh*, *kill _session-number_* +|HP Aruba allows up to 5 SSH sessions at the same time, additional users will +not be able to connect. To disconnect existing SSH sessions, run `show ip ssh` +and notice session number in the leftmose column, then disconnect it with `kill +` + |=== == Spanning Tree Protocol (STP) From 0d2564415f49ee1e750c219ed334b459bd00be52 Mon Sep 17 00:00:00 2001 From: Yuri Slobodyanyuk Date: Tue, 28 Mar 2023 11:53:53 +0000 Subject: [PATCH 6/7] Added mdfind --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 1f7490b..7a6175f 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,12 @@ Make sure to __watch__ this repository to get notified on updates (usually updat [curl cookbook of examples](cheat-sheets/curl-cookbook-of-examples.adoc) | [PDF](cheat-sheets/curl-cookbook-of-examples.pdf) + +## Apple macOS tools + +[mdfind examples cheat sheet](cheat-sheets/macos-mdfind-examples-cheat-sheet.adoc) + + ## Windows software and utilities From 971a83997a2cf4282079a1cbb7433acfd551ff3f Mon Sep 17 00:00:00 2001 From: Yuri Slobodyanyuk Date: Tue, 28 Mar 2023 11:54:50 +0000 Subject: [PATCH 7/7] Added mdfind --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a6175f..6ccaa47 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Make sure to __watch__ this repository to get notified on updates (usually updat ## Apple macOS tools -[mdfind examples cheat sheet](cheat-sheets/macos-mdfind-examples-cheat-sheet.adoc) +[mdfind examples cheat sheet](cheat-sheets/macos-mdfind-examples-cheat-sheet.adoc) | [PDF](cheat-sheets/macos-mdfind-examples-cheat-sheet.pdf) ## Windows software and utilities