Finding Things Under Linux – InApps is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn Finding Things Under Linux – InApps in today’s post !

Read more about Finding Things Under Linux – InApps at Wikipedia



You can find content about Finding Things Under Linux – InApps from the Wikipedia website

We humans always need to find things while computing. Maybe we want to know what machines are currently up and running on our local network. Linux can tell us that. Perhaps we need to sift through a bunch of files to find a certain keyword or tidbit of information. Linux can help in that situation, too. For that matter, we could simply be searching for a certain file, from a year ago on our Linux box. Punch in a handful of characters on the Linux command line and you’re in business.

Today, we’ll look at a collection of Linux commands to find things. These commands are universal across Linux systems, from the largest supercomputers all the way down to the lowly Raspberry Pi. We’ll start with a program that may or may not be in the standard load of applications on your version of Linux. It’s easy to fix by installing it with an application manager like synaptic or apt-get. All the rest are likely already installed in the core Linux build on your machine.

Find Your Network Address with nmap

Nmap is used to find IP addresses on your local network. You might use the IP to ascertain which machines are currently up and running on your network. The first thing to do is use another program, called ifconfig, to find the IP of your own machine.

Read More:   3 Reasons to Bring Stateful Applications to Kubernetes – InApps Technology 2022

rob% ifconfig

Ifconfig results

Here we see that my machine has an IP of 192.168.1.109 on the enp6s0 (wired) Ethernet interface. Now just plug most of the address into the nmap command using a wildcard character.

rob% sudo nmap -sn 192.168.1.*

Nmap results

Be sure to use the sudo root command, otherwise you’ll likely not get all the addresses. Additionally, sudo allows nmap to query the machine manufacturer information. As you can see, the 192.168.1.40 device is a Hewlett-Packard. I’ve set up a laser printer with that address, for network printing.

The “-sn” option helps simplify the output a bit.

You’ll also notice that some devices show an unknown manufacturer. You might have to dig into the data a little more using Wireshark or go searching for rogue devices if you can’t relate the IP to one of your known machines.

Let’s next look at grep.

Search for a String with grep

Grep is a powerful tool for finding text strings in a file. The basic command is simply grep followed by the text string, then the file name you want to search through. Here’s an example.

rob% grep LinuxToday robnet.htm

If you want to know the particular line of text in the file, add the “-n” option to get the line number of each instance found. Also, remember that Linux recognizes upper and lower case letters as separate and distinct characters.

Grep results

I save web page addresses and their titles in a series of files, under my “ideas” directory with dates in the file name. Examples might include 12052019.txt or 07192018.txt. The web address and title are easy to copy and paste into a text file using CTRL-C (copy) and CTRL-V (paste), respectively. It also works with the copy/paste capabilities in the Firefox and Chrome browsers.

Then if I want to find a certain keyword, using either the title or web page address, I just need to use the grep command with a wildcard character, to search through all the files in one shot. Check this example.

Read More:   How Persistent Memory Will Change Databases – InApps Technology 2022

rob% grep innovation *.txt

Grepping through a directory of files

Grep lets you search for strings in text, html and even binary files.

Moving on to searching for files, let’s look at find and locate.

Discover Your File with find

The find command methodically steps through your directories to find the file you seek. Say we want to find the 11222017.txt file. Let’s say we are in my home directory, which is /home/rob.

We could issue the following.

rob% find . -name 11222017.txt

The “.” tells find to start in the current directory and search downward through the file system.

Using find to search for a specific file in the Linux directory tree structure

There it is at the bottom, along with the pathname, from the current directory.
If you want to search through the whole partition use the “/” instead of the “.” for the starting directory. There’s no real easy way to suppress the “permission denied” messages. I just ignore them.

The thing to remember about find is that it steps through the directories, each time you search. This can take some time if you have a lot of directories, sub-directories and long file names. Starting from the root (/) directory for the above text file took about a minute in a 100+ GB partition on my antique ASUS duo-core notebook. Faster file searches are possible with the locate command, although there is a trade-off.

Find Your File Quickly with locate

Locate queries a cache that it uses to map out files, instead of stepping through the file tree structure, during a search. It updates the database once a day or so using the updatedb command.

Suppose we are back at my home directory and want to find that text file from 2017. Here’s the command line.

rob% locate 11222017.txt

Using locate to search for a specific file in the Linux tree structure

Locate only took about two seconds to return the location of the file. Notice that it also displayed the full path.

Read More:   Get Teams on Board — Deliver Innovation with Simplified Change – InApps Technology 2022

While locate is fast, keep in mind that if you have files that were created or copied over to your file system within the last 24 hours, they may not show up in the results.

Going Further

We’ve looked at a few commands and techniques that I regularly use to find things under Linux. You can always use the “–help” option, on all the commands to get more information on usage. The “man” pages are helpful too, when you are learning to use programs on the Linux command line. It’s a little awkward and quirky, at first. Keep at it and practice. You might even keep a little notebook or cheat sheet of frequently used commands and options until they become second nature.

Contact Rob “drtorq” Reilly for consultation, speaking engagements and commissioned projects at [email protected] or 407-718-3274.

Feature image: “Rama and Lakshmana Search in Vain for Sita: Illustrated folio from a dispersed Ramayana series,” ca. 1680–90, India, Rajasthan, Mewar, New York Metropolitan Museum of Art.



Source: InApps.net

Rate this post
As a Senior Tech Enthusiast, I bring a decade of experience to the realm of tech writing, blending deep industry knowledge with a passion for storytelling. With expertise in software development to emerging tech trends like AI and IoT—my articles not only inform but also inspire. My journey in tech writing has been marked by a commitment to accuracy, clarity, and engaging storytelling, making me a trusted voice in the tech community.

Let’s create the next big thing together!

Coming together is a beginning. Keeping together is progress. Working together is success.

Let’s talk

Get a custom Proposal

Please fill in your information and your need to get a suitable solution.

    You need to enter your email to download

      [cf7sr-simple-recaptcha]

      Success. Downloading...