Find File by Name in Linux – 7 Basic Examples

Linux find file by name command

Finding files in Linux can be tricky, especially when you need to search through thousands of files across multiple directories. However, this is achievable, using the Linux find command. It lets you search for files in Linux recursively by full name, partial name, or pattern.

Many users waste time manually browsing folders. With the right Linux find command syntax, you can locate anything fast. This guide shows how to use the Linux find command to search files recursively by exact name, extension, regex, and more. You’ll also learn how to combine find with grep for finding which of the files contain a certain string. (more…)

Force `cp` Command to Overwrite Without Confirmation

`cp` command among aliases in Linux terminal

The cp command in Linux is used to copy files and directories, but by default, it may prompt for a confirmation before overwriting an existing destination. If you’re running the cp command from some script, these prompts can interrupt the execution. To ensure the cp command overwrites files without confirmation, you can bypass aliases or use the yes command. Below, you’ll find practical ways to achieve this. (more…)

Dig Without Cache

dig can return cached responses because it caches the results of previous queries to improve performance.

For the same reason the cache responses can come from the configured name servers.

This is useful when you are querying the same domain multiple times, but it can be problematic when you need to check if a change you made to a DNS record has propagated.

Luckily, the dig command can be forced to resolve without using cache and this post demonstrates how to do this. (more…)

OOM Killer Doesn’t Work Properly [SOLVED]

An out-of-memory (OOM) killer is a mechanism of the Linux kernel that is supposed to terminate (kill) high memory consuming processes if a system is critically low on memory.

Unfortunately, the OOM killer doesn’t always work properly.

It often starts too late, when the system is already out of memory, so it doesn’t have enough memory for itself, that leads to the frozen system.

This note shows how to call the OOM killer earlier, before the system gets into an unresponsive state. (more…)

Restart X Server – Ubuntu Linux

While working on a Linux systems like Ubuntu, Linux Mint, etc., through a graphical user interface (GUI) it may happen that some application will hang the GUI and freeze a system.

To unfreeze the system without rebooting a machine we can restart an X server (also known as X11, or just X) that is the default GUI environment on most Linux distributions.

This note shows how to restart the X server from a command line and unfreeze the system. (more…)

Systemd Service Not Starting (status=217/USER)

A systemd service may fail to start with the error:

Main process exited, code=exited, status=217/USER

The status=217/USER indicates that the user that is configured to run the service could not be found.

This could happen if there is a typo in a username or you have copied a service file from another machine and it contains the user that doesn’t exists on your system.

This also could happen if the user that should run the service is not the local one but comes from some external authentication provider, like LDAP or Active Directory.

This short note shows how to fix the “Main process exited, code=exited, status=217/USER” error for such external user. (more…)

Linux: Find Files by Name & Grep Contents

The Linux find command can be used for searching files and directories and performing subsequent operations on them.

If you use the find command to recursively search for some files and then pipe the result to the grep command, by doing this you will actually parse the file paths/names but not their contents.

This short note shows how to recursively find files by name and grep their contents for some word or pattern. (more…)