Extracting tar file on Linux

How to extract tar file on Linux

The tar file type is used to combine multiple files into a single archive. Tar actually means “tape archive,” because tar’s original purpose was to be used on tape backups – that should tell you how old this format is. Linux systems still use the tar format, and it continues to enjoy widespread use to this day.

Tar files, with the extension .tar, are often called “tarballs.” These files will preserve the Linux file permissions and can combine any number of files into the single archive, but they don’t apply any compression or space savings. However, compression can be easily applied to the tar file, resulting in extensions like .tar.gz in the case of gzip compression, or .tar.xz for xz compression.

In this guide, we’ll show how to open tar files on command line and via GUI. This will include tar files with various compression applied to the archive. Check out the examples below to find out how.

In this tutorial you will learn:

  • How to open tar file via GUI
  • How to open tar file via command line

Read more

Disabling SELinux on CentOS 8

How to disable SELinux on CentOS 8

SELinux, which stands for Security Enhanced Linux, is an extra layer of security control built into Red Hat Enterprise Linux and its derivative Linux distributions, such as CentOS. SELinux is enabled by default on CentOS 8, and would have to be manually disabled if a user doesn’t wish to use it.

Although SELinux can protect our system through access control for programs and system services, it’s not always necessary to have it enabled. Some users may even find that it interferes with certain programs they try to install. In this guide, we’ll go over the step by step instructions to disable SELinux on CentOS 8, both temporarily or persistently across reboots.

In this tutorial you will learn:

  • How to check the status of SELinux
  • How to put SELinux in permissive mode
  • How to disable SELinux

Read more

Various examples of truncating a file on Linux

How to truncate file on Linux

Truncating files on a Linux system is a rather basic and common task for users and administrators alike. Perhaps the most common use for truncating (or emptying) a file would be in the case of log files. Clearing a bunch of old data from log files to make way for newer and up to date information can make troubleshooting much easier.

In this tutorial, we’ll show several ways to truncate a file on the Linux command line, including multiple files at once. Use the methods below on your own system, applying the example you feel will best fit your scenario.

NOTE
You can only truncate files if you have the proper Linux file permissions. Specifically, you must have write permissions on whichever files you’re trying to truncate.

In this tutorial you will learn:

  • How to use the truncate command
  • How to empty a file with Bash shell operator >

Read more

lsof command on Linux

Guide to lsof Linux command with examples

The lsof Linux command is used to list open files. On Linux systems, everything is considered a file. This means that files, directories, sockets, pipes, devices, etc are all files, therefore the lsof command will list all of these things if any of them are in use.

Along with showing you what files are in use, it will give you detailed information about which user and process is using the file. As you can imagine, this can be pretty handy in a multitude of scenarios, such as when trying to figure out what connections are being made to your system or what processes are tying up a disk that you’re trying to unmount, etc.

In this guide, we’ll show you some of the most helpful examples of the lsof command to help you get the most out of it on your own system.

In this tutorial you will learn:

  • How to use the lsof command with examples

Read more

Listing environment variables

How to set and list environment variables on Linux

Environment variables are part of the Linux system shell that contain changing values. They help facilitate scripts and system programs, so that code can accommodate a variety of scenarios. Unlike regular shell variables, environment variables can be accessed system-wide, by any user or process.

Let’s look at a very simple example to see how environment variables work and why they exist. There are many system programs and user made scripts that need to access a current user’s home directory. This can be done reliably through the HOME environment variable. Therefore, a script that contains the following line can be used by any user on the system and it will generate the same result.

$ echo $SHELL > $HOME/current-shell.log

$ cat $HOME/current-shell.log
/bin/bash

In this guide, we’ll show how to list all the environment variables on a Linux system, as well as set new ones. Setting new environment variables can either be done temporarily, or permanently if you need them to survive a reboot. We’ll show instructions for both methods below.

In this tutorial you will learn:

  • How to list environment variables on Linux
  • How to set a temporary environment variable on Linux
  • How to set a permanent environment variable on Linux

Read more

Various xargs command examples on Linux

Examples on how to use xargs command on Linux

The xargs Linux command allows a user to execute command lines from standard input. If that sounds confusing, it might be easier to look at a basic example. The following command would use xargs to cat all the files listed by the ls command.

$ ls
1.txt  2.txt  3.txt

$ ls | xargs cat
this is file1
this is file2
this is file3

In the command above, we piped the output of the ls command to xargs, and used the cat command to list the contents in each of the three files. Most uses of xargs involve piping to it from a different command, and utilizing it to execute another command in succession. If you want to start off with additional basic examples, check our guides on xargs for beginners or multi-threaded xargs examples.

Read more

Using curl to get public IP address on the Linux command line

How to use curl to get public IP address

The curl command on Linux systems is commonly used to download and upload files to or from a remote server. Another interesting thing we can use it for is to determine the public IP address of our system.

To do this, we can use curl to query websites that are configured to do nothing more than return the IP address of whichever system is connecting to it. This is one of the quickest and easiest ways to get your public IP address on the Linux command line. Follow along with us below and we’ll show you a few examples.

In this tutorial you will learn:

  • How to install curl on major Linux distros
  • How to use curl to get public IP address
Using curl to get public IP address on the Linux command line

Using curl to get public IP address on the Linux command line

Read more

Appending text to a file in Bash on Linux

How to append to file on bash shell command line

The Bash shell is the most popular shell on Linux systems, and to use the shell efficiently, you need a little knowledge about Bash shell redirections. This is also an essential step in learning Bash scripting.

In this guide, we’ll show how to append text or command output to a file on the Bash shell command line. This will include several examples so you can pick the right method in any scenario.

In this tutorial you will learn:

  • How to append text or command output to a file
  • How to append and view command output at the same time
  • How to append multiple lines of text to a file
Appending text to a file in Bash on Linux

Appending text to a file in Bash on Linux

Read more

Using apt search to find relevant packages

How to use apt search Linux command

One of the most attractive features of running a Linux system is the instant access to thousands of packages that are able to be installed from the Linux distro’s package manager.

Installing packages is really easy. That is, as long as you know the name of what you’re trying to install. If you don’t, then you can always search for installable packages. On distros that use the apt package manager, like Debian, Ubuntu, and Linux Mint just to name a few, this is done with the apt search command.

In this guide, we’ll show you how to use the apt search command with multiple examples. You’ll quickly learn to master the task of finding packages to install.

In this tutorial you will learn:

  • How to search for packages with apt

Read more

Changing the hostname on Debian Linux

How to change hostname on Debian Linux

The hostname of a Linux system is important because it’s used to identify the device on a network. The hostname is also shown in other prominent places, such as in the terminal prompt. This gives you a constant reminder of which system you’re working with. It’s a real life saver when you’re managing multiple systems through SSH and those command line terminals start to blend together in your mind.

Of course, IP addresses are used when devices need to communicate with each other, but those can change frequently. Hostnames give us a way to know which device we’re interacting with either on the network or physically, without remembering a bunch of numbers that are subject to change. Thus, it’s important that your system bears a hostname which helps you to identify it quickly. For example, “backup-server” is much more informative than “server2.” If you can’t easily identify a system’s purpose from the hostname, it’s time to change it.

In this guide, we’ll show you how to change the hostname on Debian Linux. Changing the hostname can be done either by command line or GUI, and we’ll show you the steps for both methods below.

In this tutorial you will learn:

  • How to change the Debian hostname from command line
  • How to change the Debian hostname from GNOME GUI
Changing the hostname on Debian Linux

Changing the hostname on Debian Linux

Read more

Setting up a Samba share on AlmaLinux

How to setup Samba Server and client on AlmaLinux

File servers often need to accommodate a variety of different client systems. Running Samba allows Windows systems to connect and access files, as well as other Linux systems and MacOS. An alternative solution would be to run an FTP/SFTP server, which can also support the connections from many systems.

In this guide, we’ll go over the instructions to setup a Samba server on AlmaLinux. This is a great way to prepare your file server after installing AlmaLinux or migrating from CentOS to AlmaLinux. We’ll also see how to connect to the file server from other AlmaLinux client computers.

In this tutorial you will learn:

  • How to install Samba on AlmaLinux
  • How to allow Samba through firewalld
  • How to create a Samba user
  • How to configure Samba to share a directory
  • How to allow Samba through SELinux
  • How to connect to Samba server from AlmaLinux client
Setting up a Samba share on AlmaLinux

Setting up a Samba share on AlmaLinux

Read more

How to setup an FTP/SFTP server on AlmaLinux

How to setup FTP/SFTP server and client on AlmaLinux

FTP and SFTP are great protocols for downloading files from a remote or local server, or uploading files onto the server. FTP will suffice for some situations, but for connections over the internet, SFTP is recommended. In other words, FTP is not secure to use over an internet connection, since your credentials and data are transmitted without encryption. The ‘S’ in SFTP stands for ‘Secure’ and tunnels the FTP protocol through SSH, providing the encryption needed to establish a secure connection.

In this guide, we’ll go over the step by step instructions to setup an FTP server through VSFTP software or SFTP server through OpenSSH on AlmaLinux. Then, we’ll see how to connect to the server from a client AlmaLinux system. Setting up FTP/SFTP is a common step after installing AlmaLinux or migrating from CentOS to AlmaLinux.

In this tutorial you will learn:

  • How to setup an FTP server through VSFTPD
  • How to setup an SFTP server through OpenSSH
  • How to setup FTP and SFTP user accounts
  • How to allow FTP and SFTP through firewalld
  • How to connect to an FTP/SFTP server via command line
  • How to connect to an FTP/SFTP server via GNOME GUI
How to setup an FTP/SFTP server on AlmaLinux

How to setup an FTP/SFTP server on AlmaLinux

Read more