Listado de la etiqueta: Files

This article explains how to find all files containing specific text on Linux. For this we’ll use grep, a standard Unix program.

grep is a command-line utility which prints lines that match a given pattern, and should be installed by default.

Let’s start simple. Say you want to search for the word text (case-sensitive!) in all the files in the current directory and its subdirectories. To do this, you need to open the terminal, navigate to the folder where you want to perform the search, and run:

grep -r 'text'

This lists all the files in the current folder and subfolders containing text. This includes strings like texting for example, because it contains our search pattern, text. -r stands for recursive, reading all the files in the directory and its subdirectories. If you require following all symbolic links, use -R instead of -r.

If you only want to list the filenames containing the exact whole word text (as opposed to the default partial word matching), and not things like texting, 123text, and so on, you’d need to append the -w (whole words) command line option, like this:

grep -rw 'text'

If you don’t want to search in the current folder, but in a specific folder, you can specify the path in which grep should look into, by adding it at the end of the command, like this:

grep -rw 'text' /path/to/search/into

You might also be interested in: How To Repeat A Command Every X Seconds On Linux

Grep has many options, but below I’ll only list a few that you might find especially useful when trying to find all files containing specific text on Linux (besides those already mentioned above):

  • -n shows the line numbers. When a match is found, besides the file path in which it was found, grep will also display the line number on which the pattern was found
  • -i performs the search case-insensitive (it’s case-sensitive by default). Depending on the number of files, this can slow down the search, so take this into consideration when using it
  • --include=GLOB / --exclude=GLOB includes or excludes certain files
  • --exclude-dir=GLOB is used to exclude folders from being searched

Let’s take a look at an example which combines these command line flags. Let’s say you want to find all files containing the case-insensitive (-i) text in the ~/Documents folder and its subfolders except for the Private and Personal subfolders (--exclude-dir), and only search in the files that have the .txt and .js extensions (--include). Also, you want to show the line numbers (-n), search recursively and also follow all symbolic links (-R). In that case, the command you’d need to use would be (this is a single command):

grep -Rni --exclude-dir={Private,Personal} --include={*.txt,*.js} 'text' ~/Documents

Example output:


Here, 7 is the line number on which the pattern we’ve searched for (text) was found.

For more information and advanced usage, see the grep man page.

You may also want to check out ripgrep, a line-oriented search tool that recursively searches the current directory for a regex pattern that comes with some extra features, and is very fast.

You  might also like: rga: Search Text In PDF, Ebooks, Office Documents, Archives And More (ripgrep Wrapper) and How To Find Files Modified In The Last N Days Or Minutes Using find

File sharing programs improve work efficiency and assist in saving time. There are many programs to share files; one of the simplest file-sharing systems is FileZilla, which works on the principle of FTP and allows you the freedom to share files from your Raspberry Pi to your PC or any other device.

In this article, we will guide you on how you can install FileZilla on your Raspberry Pi device and start sharing files to another system.

How to Install FileZilla on Raspberry Pi

Since FileZilla is an open-source file-sharing program, the Raspberry Pi developers include its repository in the official source list, which allows you to easily install it on your device within seconds. To begin the installation, you must need to follow the below-mentioned steps:

Step 1: Update and Upgrade Raspberry Pi Packages

Before beginning the installation of FileZilla, you must need to check whether there is an update available for the currently installed packages on your Raspberry Pi device. You can isse the below-given command to ensure the Raspberry Pi packages are updated successfully:

If there is an update available, you must immediately execute the following command to make your Raspberry Pi system up to date:

Step 2: Install Dependencies for FileZilla on Raspberry Pi

Next, you will need to install some dependencies which are required to operate FileZilla on your Raspberry Pi and to do this, execute the following command:

$ sudo apt install software-properties-common apt-transport-https -y

Step 3: Install FileZilla on Raspberry Pi

After installing the required dependencies on Raspberry Pi, use the following command to install FileZilla on Raspberry Pi successfully:

$ sudo apt install filezilla -y

Step 4: Run FileZilla on Raspberry Pi

Merienda the installation of FileZilla is completed, you can run the following command in the terminal to execute FileZilla on your Raspberry Pi device:

At the FileZilla dashboard, you will need the following things to connect to the system you want to share files:

  • Host: It’s the IP address of a host laptop, PC, or mobile phone.
  • Username: It’s the username of a host laptop, PC, or mobile phone.
  • Password: The password of a host laptop, PC, or mobile phone.
  • Port: FileZilla operates on port 22, so you must select the same port number.

Remove FileZilla From Raspberry Pi

In case you are done with using FileZilla on Raspberry Pi, you can remove it anytime using the following command:

$ sudo apt remove filezilla -y


FileZilla is a simple file sharing application that helps Raspberry Pi users to easily share files between your device and another system like laptop or PC. Its installation on Raspberry Pi is straightforward, which requires installing dependencies and a FileZilla package to complete the installation. To open the FileZilla dashboard, you just need to enter the “filezilla” command and with the host IP address, username, password and port number, you can successfully connect another system to your device and start sharing files with ease.

Source link

Compressed files save on bandwidth when sending them to someone. You can compress any files, and there are different tools, such as zip and tar. The compressed files get extracted to the current working directory unless you specify a different one. Besides, the different utilities have various options that you must add to aid in extracting archive files to specific folders.

When using a decompressing tool, there is a way to specify a different directory for the extracted files. This guide will discuss how to create archive files and extract the contents to specific directories using unzip and tar in Linux.

Extracting zip Files

The zip files are created using zip, a cross-platform compression and packaging utility that allows specifying the compression levels, ranging from 1 to 9.

When using zip to create zip files, the extracted files are stored in the current directory. Let’s create zip files in the current directory, then extract the contents to a different location.

To create zip files, the syntax is:

$ zip [options] [zip-name] [zip-files]

In our case, we are compressing different files and folders. Our zip file name is The following command will be:

$ zip *.txt *.bin names details

Our zip file is ready and is currently in the /Documents directory. If we were to extract it without specifying the path, the following command would be:

However, let’s specify the path and extract the file contents to /Downloads directory. Furthermore, you must add the -d flag to specify the path. Now, the syntax is:

$ unzip [zip-file] -d /path/directory

Create a directory to extract the zip file contents, then use unzip to extract the files using the following command:

$ mkdir -p ~/Downloads/zip-extracted
$ unzip -d ~/Downloads/zip-extracted

If we list the contents of the created directory, we see that the extraction was a success.

That’s all to it. Whether you are working with a created or downloaded zip file, the process and concept are the same.

Extracting tar Archive Files

The tar format is the most common compression format. Most files are either tar.gz, tar, or tzg format. The extraction will work the same, and like zip files, the default extraction occurs in the current directory unless otherwise specified.

Quickly create a tar archive to use for the following example. In our case, our archive is example2.tar:

You can use the -C or —directory flags to extract the tar file. Also, you need to create the directory to hold the extracted files, as we did with unzip.

The syntax for the extraction is:

$ tar -xvf [tar-file] -C /path/directrory


$ tar -xvf [tar-file] –directory /path/directory

In our case, our commands will be:

$ mkdir -p ~/Downloads/tar-extracted
$ tar -xvf example2.tar -C ~/Downloads/tar-extracted

Note that example2.tar is the name of our tar archived file, and our path and directory to extract to is ~/Downloads/tar-extracted. Therefore, replace the names to match your case.

We can list and confirm if the extraction was a success, and the following output shows everything worked as expected:

The process is the same for other tar formats. For instance, to extract a .tgz file, the commands will be similar to those shown in the following image. Also, note that we are using the —directory flag, which is the same as -C.


The bottom line is that by default, extracting files on Linux stores the extracted files in the current working directory. You must specify the path if you need to use different directories to extract the files. Moreover, there are various options that you need to add when using different file extraction utilities. We’ve covered extraction using unzip and tar, the two common utilities you can use.

Source link

Syncthing is an open-source file synchronization application used to synchronize files between multiple devices, such as smartphones, personal computers, or embedded devices like Raspberry Pi. It provides a secure platform to easily share your files to other devices without using any third-party application, thus making life relatively easy and fast.

This article is a detailed guideline for synchronizing files on your Raspberry Pi device using Syncthing.

Synchronizing Files on Raspberry Pi with Syncthing

The installation of Syncthing doesn’t requires any complex installation method instead you can easily complete its installation of your Raspberry Pi device using the following simple steps:

Step 1: Updating Raspberry Pi Packages

Before moving towards Syncthing setup, it’s better to first update your Raspberry Pi packages using the below-mentioned command:

$ sudo apt update && sudo apt upgrade

Step 2: Installing Prerequisite

After updating the package, you will also need to install an additional package called “apt-transport-https” as this will handle the source that will operate over HTTPS service. You can install this package through following command:

$ sudo apt install apt-transport-https

Step 3: Downloading GPG Key

Next, you will also need to download and save GPG Key using the following command to ensure that the package is coming from a trusted source.

$ curl -s | gpg –dearmor | sudo tee /usr/share/keyrings/syncthing-archive-keyring.gpg >/dev/null

The above command will successfully add the GPG key.

Step 4: Adding Syncthing Repository

After adding the GPG key, you can apply the following command to add the Syncthing repository to the Raspberry Pi source list.

$ echo «deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] syncthing stable» | sudo tee /etc/apt/sources.list.d/syncthing.list

Step 5: Updating the Source List

Merienda, you add the Syncthing repository, you will need to update the Raspberry Pi source list using the following command:

The above command updates the Raspberry Pi’s repository list.

Step 6: Install Syncthing on Raspberry Pi

With source list updated, you can use the following command to install Syncthing on Raspberry Pi:

$ sudo apt install syncthing

Step 7: Running Syncthing on Raspberry Pi

After successfully installing Syncthing on Raspberry Pi, execute the following command to run Syncthing on Raspberry Pi.

When you execute the above command, it will open the Syncthing web interface with the address “” on your browser. It also generates the configuration file with the first time execution. You have to close the browser and use the “Ctrl+C” keys in the terminal to stop Syncthing on Raspberry Pi.

Note: It is important to open Syncthing at least merienda before moving towards the next step.

Step 8: Opening Syncthing Configuration File

To make the changes, you have to open the Syncthing configuration file using the following command:

$ sudo nano ~/.config/syncthing/config.xml

Within this file, find the below-given line:


You can use “Ctrl+W” to find the above line in the file.

Now, change the IP inside the line with the IP address of your Raspberry Pi and you can find your Raspberry Pi address through following command:

Save the above file by using the keys “CTRL+X”, Y and press enter to exit. We are doing this step just to ensure that only the trusted users who are connected with our restringido network will have access to the files.

Step 9: Creating a Service File

In the final configuration step, we have to do one last task that is to make a service file for Syncthing using the following command:

$ sudo nano /lib/systemd/system/syncthing.service

Add the following information inside the file:


ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

# Hardening


Save the file and finish creating the Syncthing service file on Raspberry Pi .

Step 10: Enabling Syncthing Service

After creating a service file for Syncthing, you will need to enable the service again through the following command:

$ sudo systemctl enable syncthing

Step 11: Starting Syncthing Service

Now start the Syncthing service on Raspberry Pi using the below-mentioned command:

$ sudo systemctl start syncthing

Step 12: Checking Syncthing Service

You will also need to ensure whether the Syncthing service is running fine on your Raspberry Pi and you can do so by issuing the following command::

$ sudo systemctl status syncthing

This ensures that the Syncthing service is running perfectly fine.

Step 13: Accessing Syncthing Web Interface

Now use the address to access the web interface on your browser.

First, you will need to ensure Syncthing privacy so only you can can access your files on your system and you can do this by clicking on the “Settings” option.

In the “GUI” tab, enter username, provide password and then click on the “Save” button.

As soon as you save the changes, you will have to provide your username and password to access the web interface.

To synchronize the files between the devices, you will need to add the device ID by clicking on the “Add Remote Device” option. The device you want to add must have a Syncthing install and the device ID will be inside the application. After that, you can share your Raspberry Pi folder with that particular device by clicking on the “Add Folder” option.


Syncthing is a robust application that provides users the freedom to share files between multiple devices in a secure way. You can install and run this application on your Raspberry Pi browser through the above-given steps that include adding a GPG key and repository and using the installation command to install the application on your device. After the installation, you will need to make some changes in the configuration files to access the Syncthing web interface on your browser. With the remote device ID, you can allow the device to perform file sharing with your Raspberry Pi.

Source link