Linux Resources

Replace a String in a File Using Ansible

This article covers the usage of the 'replace' module in Ansible for replacing a string in a file. In fact, Ansible provide multiple ways that you can use to replace a string, an entire line or words that match a certain pattern. There are two modules that you can use to achieve this: the replace module and the inline module. 

Rsync Command Options - Explained with Examples

This article covers a few options of the RSYNC command along with a few examples that elaborated on the usage of this command. In fact, with rsync, you will be able to use this tool very efficiently for transferring data from one location to another.

What is the Rsync Command Syntax ?

The syntax for the rsync command changes depending on the usage of the tool. We will cover all the scenarios in the following examples. Rsync syntax in its most basic form looks like this:

$ rsync options SOURCE DESTINATION

Remote data transfers require you to specify a host's address, but more on that later.

What are Rsync Command Options ?

The rsync tool comes with many options. You can enter rsync in your terminal and get all the details. We will list some of the most common rsync options:

  • -r Allows to sync data recursively but does not keep ownership for users and groups, permissions, timestamps, or symbolic links.
  • -a The archive mode behaves like the recursive mode but keeps all file permissions, symbolic links, file ownership, etc.
  • -z Used to compress data during transfers to save space.
  • -b Performs a backup during data synchronization.
  • -h Shows the numbers in the output in a human-readable format.
  • -n Does a dry run. Used for testing before the actual synchronization takes place.
  • -e Instructs the rsync to use the SSH protocol for remote transfers.
  • -progress Displays the transfer progress during synchronization.
  • -v Verbose output. Displays the details of the transfer.
  • -q Used to suppress the output for the rsync command and options.

Execute Remote Command with SSH

This article covers the process of running a remote command with SSH on a Linux system along with actually running a command remotely. In fact, you will be able to run any command on a remote system of your choice provided that you know the correct username of that system as well as its password with which you will be able to access it remotely.

Linux sed Command Options - Explained with examples ?

This article covers the concept of the SED command in Linux along with a few useful examples to elaborate on its usage. In fact, SED is a text stream editor used on Unix systems to edit files quickly and efficiently. The tool searches through, replaces, adds, and deletes lines in a text file without opening the file in a text editor.

What is the Linux sed Syntax ?

The main syntax for using the Linux sed command is:


What is sed Linux Options ?

You can execute sed with the following command-line options:

  • -b, --binary Open input files in binary mode to consider lines to end at a line feed.
  • --debug Switch to debug mode to print input in canonical form and annotate program execution.
  • --follow-symlinks Edit the ultimate destination if the specified file is a symbolic link. It only works when combined with the -i option.
  • --help Display the usage information.
  • --i, --in-place [=SUFFIX] Perform edits in-place by overwriting the original file.
  • --posix Disable all extensions to POSIX sed to simplify writing portable scripts.
  • --version Display the version of sed running on the system.
  • -E, -r, --regexp-extended Use extended regular expressions.
  • -e <em>script</em>, --expression=<em>script</em> Add a specified script to run with the commands.
  • -f <em>script-file</em> Add the contents of a specified script-file to run with the commands.
  • -l <em>N</em>, --line-length=<em>N</em> Define the desired line-wrap length for the l command (default value is 70).
  • -n, --quiet, --silent Disable output printing.
  • -s, --separate View specified files as separate, not as a single continuous long stream.
  • --sandbox Disable running external programs and operate only on input files on the command line.
  • -u, --unbuffered Minimalize input and output buffer.
  • -z, --null-data, --zero-terminated View input as a set of lines where each ends with a zero byte.

How Tags in Ansible Playbook works running Ubuntu 22.04 (Jammy Jellyfish) ?

This article covers how to Use Tags in Ansible Playbook. In fact, you might want to run specific tasks instead of running an entire playbook file.  This helps to reduce the total playbook execution time, especially when dealing with a large playbook file.

TAR Command Options in Linux - Explained with Examples

This article covers the usage of the TAR command in Linux. In fact, the GNU tar (short for Tape ARchiver) command is the most widely used archiving utility in Linux systems. Available directly in the terminal, the tar command helps create, extract, and list archive contents.

How to tar a file in Linux using command line ?

  • Open the terminal app in Linux.
  • Compress an entire directory by running tar -zcvf file.tar.gz /path/to/dir/ command in Linux.
  • To compress a single file by running tar -zcvf file.tar.gz /path/to/filename command on Linux.
  • Tar and compress multiple directories file by running tar -zcvf file.tar.gz dir1 dir2 dir3 command in Linux.

Search by typing a one letter Word Term Here