How to find and remove all empty files using shell command line

In this config you will learn how to find all empty files within a given directory using find the find command. Here is our sandbox directory /tmp/temp containing files from which some of them are empty:

.
├── dir1
│   ├── dir2
│   │   ├── file3
│   │   └── file4
│   ├── file2
│   └── file3
├── file1
└── file2

2 directories, 6 files

Let’s first locate all empty files recursively starting from a current working directory using find command:

$ pwd
/tmp/temp
$ find  . -type f -empty
OR
$ find  /tmp/temp -type f -empty
./dir1/dir2/file4
./dir1/file3
./file2

The following linux command will search for all empty file only within a current working directory, that is, not recursively:

$ find  . -maxdepth 1 -type f -empty
./file2

Read more

How to perform AUTH DIGEST-MD5 CRAM-MD5 command line SMTP authentication

This config will describe a procedure to login to SMTP server using AUTH DIGEST-MD5 CRAM-MD5 encryption authentication method via telnet. First, we need to install all prerequisites:

# apt-get install telnet sasl2-bin

Using telnet command we will connect to SMTP server. The sasl2-bin package contains gen-auth command which we will use to generate our BASE64 encoded response to server’s authentication challenge. Lets’ start by using telnet command to connect to our server:

$ telnet 10.1.1.11 25
Trying 10.1.1.11...
Connected to 10.1.1.11.
Escape character is '^]'.
220 mail.localhost.localdomain ESMTP Postfix (Ubuntu)

Read more

How to change sasl user’s password using saslpasswd2

This config we shortly describe how to update/change sasl user’s password. Firs, list sasl database to retrieve a list of all current users. If you know the exact user name for which you wish to change/update password that this step can be omitted:

# sasldblistusers2 
lubos@localhost: userPassword
radek@localhost: userPassword

Read more

Rygel – DLNA Share Media Server deployment using docker

About

The automated build Docker image of Rygel – DLNA Share Media Server “linuxconfig/rygel” can be used to instantly deploy DLNA Share Media Server on your docker hosts.

Configuration

The docker image with the Rygel – DLNA Share Media Server runs on Debian GNU/Linux system using official pre-compiled stable packages from a Debian repository.

Usage

To deploy your Rygel DLNA Share Media Server run the following linux command. Update media file paths to point to your media files located on your host system:

# docker run -d --net=host --name=rygel -v /path/video/files:/video -v /path/music/files:/music -v /path/pictures/files:/pictures linuxconfig/rygel

Read more

How to deny/allow access to files using .htaccess file

Question:

How can I allow and deny HTTP access to files based on file extension? I need to deny access to all TXT files.

Answer:

Below you can find a simple examples on how to regulate download access to files using .htaccess file. In the first example the following .htaccess code will block access to all files with file extension .txt to all requests resulting in HTTP ERROR 403: Forbidden..

<FilesMatch ".txt">
    Order Allow,Deny
    Deny from All
</FilesMatch>

Read more

How to start a docker with Exited (-1) status solution

Symptoms:

Any uttmpt to start, restart a docker container results in a following error:

coreos ~ # docker start 3cabf046fa66
Error response from daemon: Cannot restart container 3cabf046fa66: [8] System error: Unit docker-3cabf046fa66eb3484a8be2c6ac162ee4e1e5c838a74b93f9a66546c9f206c24.scope already exists.
FATA[0000] Error: failed to start one or more containers 

Read more

How to initialize a git repository with Github

The below text contains a necessary commands on how to initialize a git repository with Github. Here we assume that you have created a new repository using your Github account and now you wish to push your project files into this new Github repository. In order tu push your files to a new Github repository we need to initialize it our new repository locally.

First, navigate to your project directory containing all files:

$ cd /my/project/directory

Then, initialize git:

$ git init

Read more

How to change a time zone on CoreOS Linux

The following linux commands will allow you to change the time zone on your CoreOS Linux. Currently, the time zone is set to UTC:

coreos ~ # date
Sun Aug  9 09:34:17 UTC 2015

By using the timedatectl list-timezones command you can obtain a list of all available time zones:

coreos ~ # timedatectl list-timezones

Read more

How to set/change a hostname on CoreOS Linux

The following config will provide you we a set of commands on how to updated a hostname on your CoreOS Linux server. Let’s start by displaying the current hostname:

localhost ~ # hostnamectl       
   Static hostname: n/a
Transient hostname: localhost
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: 1759d8fe862a4c17b50a56eebb7a1e26
           Boot ID: 0de6b2cfbf31454299af6729737fc648
  Operating System: CoreOS 723.3.0
            Kernel: Linux 4.0.5
      Architecture: x86-64

Read more

How to perform a bare metal installation of CoreOS Linux

This article will describe how to load a CoreOs Linux on a bare metal server. There are more ways on how to get CoreOS Linux installed on your machine. In this article we will first boot some Live Linux distro eg. Fedora from USB or CDROM and then use CoreOS’s installation script to perform the actual CoreOS Linux on a given hard drive. What you will need:

  • Internet connection
  • USB stick

Bootable Media Preparation

First, we need to create a bootable media with Live Linux distribution such as USB stick. This simple procedure is described in guide How to create a Fedora Linux Live bootable USB key . Please note that any Live Linux distro will be good for this job so if you have Ubuntu or Knoppix CD or USB ready you can skip this step at completely. If your target computer is unable to boot from USB simply use CD-ROM to boot.

Read more

How to move a Docker image to another system

If you have created your own Docker image locally and want to move it to another docker host without first uploading it to a docker or private local repository you can use docker’s save command to save your image locally as ordinary tar archive archive and the copy and re-deploy it on another docker system. For example here we first make a backup of our docker image eg. linuxconfig:

# docker save linuxconfig > linuxconfig.tar

The above command have created a tarball of our local docker image linuxconfig which we now can move to another system and re-deploy it with Docker’s command load:

# docker load -i linuxconfig.tar

Read more

How to extract files from RPM package archive

This short article will show you how to extract a single or multiple files from a RPM package archive. To begin we first download a sample package hello.

$ wget ftp://rpmfind.net/linux/opensuse/factory/repo/oss/suse/x86_64/hello-2.9-4.3.x86_64.rpm
$ ls
hello-2.9-4.3.x86_64.rpm

Now we have an option extract all or a single file from the above RPM package archive. The following linux command will extract all file into our current working directory:

$ rpm2cpio hello-2.9-4.3.x86_64.rpm | cpio -id
525 blocks
$ ls
hello-2.9-4.3.x86_64.rpm  usr

Read more