- 63
- Sign Up
- Article
- Trending
What Is Linux?
Linux is an operating system’s kernel. You might have heard of UNIX. Well, Linux is a UNIX clone. But it was actually created by Linus Torvalds from Scratch. Linux is free and open-source, that means that you can simply change anything in Linux and redistribute it in your own name! There are several Linux Distributions, commonly called “distros”.
- Ubuntu Linux
- Red Hat Enterprise Linux
- Linux Mint
- Debian
- Fedora
Linux is Mainly used in servers. About 90% of the internet is powered by Linux servers. This is because Linux is fast, secure, and free! The main problem of using Windows servers are their cost. This is solved by using Linux servers. The OS that runs in about 80% of the smartphones in the world, Android, is also made from the Linux kernel. Most of the viruses in the world run on Windows, but not on Linux!
Linux Shell or “Terminal”
So, basically, a shell is a program that receives commands from the user and gives it to the OS to process, and it shows the output. Linux’s shell is its main part. Its distros come in GUI (graphical user interface), but basically, Linux has a CLI (command line interface). In this tutorial, we are going to cover the basic commands that we use in the shell of Linux.
Learn how to use the find command in this tutorial from our archives.
It goes without saying that every good Linux desktop environment offers the ability to search your file system for files and folders. If your default desktop doesn’t — because this is Linux — you can always install an app to make searching your directory hierarchy a breeze.
But what about the command line? If you happen to frequently work in the command line or you administer GUI-less Linux servers, where do you turn when you need to locate a file? Fortunately, Linux has exactly what you need to locate the files in question, built right into the system.
The command in question is find . To make the understanding of this command even more enticing, once you know it, you can start working it into your Bash scripts. That’s not only convenience, that’s power.
Let’s get up to speed with the find command so you can take control of locating files on your Linux servers and desktops, without the need of a GUI.
How to use the find command
When I first glimpsed Linux, back in 1997, I didn’t quite understand how the find command worked; therefore, it never seemed to function as I expected. It seemed simple; issue the command find FILENAME (where FILENAME is the name of the file) and the command was supposed to locate the file and report back. Little did I know there was more to the command than that. Much more.
If you issue the command man find , you’ll see the syntax of the find command is:
Naturally, if you’re unfamiliar with how man works, you might be confused about or overwhelmed by that syntax. For ease of understanding, let’s simplify that. The most basic syntax of a basic find command would look like this:
Now we’ll see it at work.
Find by name
Let’s break down that basic command to make it as clear as possible. The most simplistic structure of the find command should include a path for the file, an option, and the filename itself. You may be thinking, “If I know the path to the file, I’d already know where to find it!”. Well, the path for the file could be the root of your drive; so / would be a legitimate path. Entering that as your path would take find longer to process — because it has to start from scratch — but if you have no idea where the file is, you can start from there. In the name of efficiency, it is always best to have at least an idea where to start searching.
The next bit of the command is the option. As with most Linux commands, you have a number of available options. However, we are starting from the beginning, so let’s make it easy. Because we are attempting to find a file by name, we’ll use one of two options:
name – case sensitive
iname – case insensitive
Remember, Linux is very particular about case, so if you’re looking for a file named Linux.odt, the following command will return no results.
If, however, you were to alter the command by using the -iname option, the find command would locate your file, regardless of case. So the new command looks like:
Find by type
What if you’re not so concerned with locating a file by name but would rather locate all files of a certain type? Some of the more common file descriptors are:
f – regular file
l – symbolic link
c – character devices
b – block devices
Now, suppose you want to locate all block devices (a file that refers to a device) on your system. With the help of the -type option, we can do that like so:
The above command would result in quite a lot of output (much of it indicating permission denied ), but would include output similar to:
Voilà! Block devices.
We can use the same option to help us look for configuration files. Say, for instance, you want to locate all regular files that end in the .conf extension. This command would look something like:
The above command would traverse the entire directory structure to locate all regular files ending in .conf. If you know most of your configuration files are housed in /etc , you could specify that like so:
The above command would list all of your .conf files from /etc ( Figure 1 ).
Figure 1: Locating all of your configuration files in /etc.
Outputting results to a file
One really handy trick is to output the results of the search into a file. When you know the output might be extensive, or if you want to comb through the results later, this can be incredibly helpful. For this, we’ll use the same example as above and pipe the results into a file called conf_search. This new command would look like:
You will now have a file ( conf_search ) that contains all of the results from the find command issued.
Finding files by size
Now we get to a moment where the find command becomes incredibly helpful. I’ve had instances where desktops or servers have found their drives mysteriously filled. To quickly make space (or help locate the problem), you can use the find command to locate files of a certain size. Say, for instance, you want to go large and locate files that are over 1000MB. The find command can be issued, with the help of the -size option, like so:
You might be surprised at how many files turn up. With the output from the command, you can comb through the directory structure and free up space or troubleshoot to find out what is mysteriously filling up your drive.
You can search with the following size descriptions:
b – 512-byte blocks
Keep learning
We’ve only scratched the surface of the find command, but you now have a fundamental understanding of how to locate files on your Linux systems. Make sure to issue the command man find to get a deeper, more complete, knowledge of how to make this powerful tool work for you.
Learn more about Linux through the free “Introduction to Linux” course from The Linux Foundation and edX.
U nder KDE or Gnome desktop I get nice facility to search all man pages for particular command or phrase. I am login to remote server over the ssh session. How do I search all the man pages for a particular command at Linux shell prompt?
You need to use the following commands to search man pages:
apropos Command
The apropos command searches a set of database files containing short descriptions of system commands for keywords and shows the result on the screen. The syntax is as follows:
apropos Command Examples
To Search command / functions related to compare operation, enter:
$ apropos compare
Sample outputs:
Task: Search For a String
Search command to remove a file, enter:
$ apropos “remove file”
Sample outputs:
Task: Search Specific Section of The Man Page
To search only the given manual section use the -s option:
apropos -s 1 compare
Sample outputs:
Task: Regex Based Search
You can force apropos to interpret each keyword as a regular expression using the -r option:
$ apropos -r scanf
Sample outputs:
The ‘man -K’ Command
The -K option is passed to the man command to search for the specified string in all man pages. The syntax is as follows:
Search all man pages for fopen word, type:
$ man -K “fopen”
Output:
Type y to open/display man page, n to continue search, q to Quit search. This is a brute-force search, and is likely to take some time. So it helps to specify a man page section (1-7) using the following syntax:
$ man -s 3 -K “open”
OR
$ man -s 8 -K “user”
Please note that above commands also works with other UNIX and *BSD like oses
- Linux / Unix: Colored Man Pages With less Command
- Linux / UNIX: Getting help with man pages and how to…
- Display Colored Man Pages in Linux and Unix
- How to install man pages on CentOS Linux 6/7/8
- How to install man pages on Ubuntu Linux
- How to add/install man pages in Alpine Linux
- Finding a File Containing a Particular Text String…
| Category | List of Unix and Linux commands |
|---|---|
| File Management | cat |
| Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
| Network Utilities | dig • host • ip • nmap |
| OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
| Package Manager | apk • apt |
| Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
| Searching | grep • whereis • which |
| User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
| WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
search paricular month alone using find command in linux
It should be a lowercase “k” in man -K “fopen” .
Unfortunately man -k only searches the short description. man is great if you know the specific command or the text appears in the short description. It would be nice to search the entire man system. The only way I’ve found to do that is to uncompress them or convert them.
@dj lowercase k and uppercase K are distinct options to the man command. Lowercase k searches only the short description and is equivalent to apropos, but uppercase K searches the entire content of the man pages.
for i in /*; do zgrep $i/*; done
( I arbitrarily choose i – use whatever you want). The only downside is zgrep doesn’t support -R
Oops – HTML tags bit me, that should read:
for i in /usr/share/man/*; do zgrep $i/*; done
assuming /usr/share/man is where the man pages are located, replace with appropriate path if needed.
npm is the package manager for Node.js and the JavaScript coding language. It can be installed on a Linux system and then used on the command line to download and install JavaScript packages and their requisite dependencies.
It’s especially useful for developers working with Node.js, as npm’s online registry contains a plethora of JavaScript packages that can be browsed and downloaded with ease. It’s available for installation on any major Linux distro and operates in much the same way as a distro’s package manager, which you’re probably already familiar with.
In this guide, we’ll show you how to install npm on various Linux distributions. We’ll also show you basic usage commands for npm, such as installing and removing software packages.
In this tutorial you will learn:
- How to install npm on major Linux distributions
- Basic usage commands for npm
| Category | Requirements, Conventions or Software Version Used |
|---|---|
| System | Any Linux distro |
| Software | npm |
| Other | Privileged access to your Linux system as root or via the sudo command. |
| Conventions | # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command $ – requires given linux commands to be executed as a regular non-privileged user |