If you want to configure a static IP on your Ubuntu or Debian from command line, here is what you have to do.
First we will switch login user to root.
Then we will edit /etc/network/interfaces file:
and we will add the following lines:
auto lo iface lo inet loopback auto eth1 iface eth1 inet static address 10.0.0.2 broadcast 10.0.0.255 netmask 255.255.255.0 post-up route add default gw 10.0.0.1 pre-down route del default gw 10.0.0.1 dns-nameservers 10.0.1.1
Last thing to do is to restart network services.
service networking restart
Let’s say we’ve just added a secondary drive to our CentOS Linux machine and we want to add GPT partition table and then create a GPT partition that will fill our disk. In order to do that we will use parted.
First we will install parted package:
yum install parted
Then we will go to parted CLI:
parted -s -a optimal /dev/vdb
There we add GPT partition table (don’t type “(parted)” part, it is the parted CLI prompt):
(parted) mklabel gpt
Then we will create our new partition:
(parted) mkpart primary ext4 1 -1
If we want not to fill entire drive but to make a partition of a let’s say 100G we will run instead:
(parted) mkpart primary ext4 1 300GB
Now we can exit the parted CLI and put a filesystem on our partition:
That’s it. We can just mount the partition.
Let’s say we want to use a tool that is in a package but we don’t know which package it is.
So for example we want to use cgdisk binary to create partitions but the binary is not on our machine and we don’t know the package name that installs cgdisk. To find out we will run:
yum whatprovides "*/cgdisk
The result will be:
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.imt-systems.com * epel: mirrors.n-ix.net * extras: centosmirror.netcup.net * updates: centosmirror.netcup.net base/filelists_db | 6.1 MB 00:00 epel/filelists_db | 9.5 MB 00:00 extras/filelists_db | 32 kB 00:00 updates/filelists_db | 2.5 MB 00:00 gdisk-0.8.10-1.el6.x86_64 : An fdisk-like partitioning tool for GPT disks Repo : base Matched from: Filename : /usr/sbin/cgdisk
So now we know the package name is gdisk and we will install it:
yum install gdisk
If you want to disable password authentication and only authenticate with Public/Private keys on a CentOS 6 Linux machine when connecting via ssh here’s what you need to do.
How ssh keys auth works
We have a client an a server. On client we generate a pair of public/private keys. Then we copy the public key to the server in a specific file that will be used by ssh server to recognise the key. Then we configure the sshd server to disable password authentication and only permit public/private key auth.
If you get this warning when running perl scripts:
# perl -v perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "(unset)", LC_ALL = (unset), LC_CTYPE = "UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi
In your container config file
/var/lib/lxc/container_name/config add the following lines:
# Start at boot lxc.start.auto = 1 lxc.start.delay = 5 lxc.start.order = 100
You can test it with
To list all installed packages on CentOS Linux we will use yum command:
yum list installed
To find you some of installed packages we can use grep:
yum list installed | grep -i libdw
To fetch a project from a Git Repository run:
git clone https://github.com/dtrace4linux/linux
What is and why use LXC?
LXC is a linux container system that offers an environment as close as possible as of a virtual machine, without emulating any hardware and sharing the same kernel with the host, it is very lightweight and fast.
I prefer to keep the development environment isolated from my main machine. This assures that if everything goes wrong with the development environment, my main machine remains stable, also I can easily backup and test different configurations on the environment. For example I could setup multiple containers with different php versions.
The main objective of this article is to create a container that will behave like an app with a LEMP (Linux, NGINX, MySQL, PHP) stack that I can start and stop just as I would start a WAMP or MAMP app on Windows or OS X. The main machine is Ubuntu 14.04.