OS Installation on USB drive with VirtualBox

VirtualBox virtualization software allows you to install any operation system directly to any attached block device such as USB stick/drive etc. This is actually a cool way to create you personalized Live Linux USB stick. This short “howto” describes how it works.
For the sake of this tutorial we will be using block device file name /dev/sdb to refer to our attached USB drive. First we need to create a raw vmdk virtual file disk linked to our /dev/sdb USB drive. As a privileged user execute the below command:

# vboxmanage internalcommands createrawvmdk -filename linux-live.vmdk -rawdisk /dev/sdb

Read more

How to resize ext4 root partition live without umount on Linux

This article will focus on how to resize EXT4 root partition without unmount. This is an easy way for some system where you are unable to unmount root partition and the system can be recovered easily if something goes wrong like for example AWS instance.

Resizing any live partition without unmout comes with a tremendous risk of loosing data thus it is not recommended. If you a have a sensitive data stored on your system, it is always recommended to take the system down make a backup and resize the partition while it is not mounted.

In the following example we are going to resize a partition of a fresh single partition AWS Linux instance. The current partition size is 7.8GB:

# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      7.8G  642M  6.8G   9% /

Read more

How to find IP address on linux?

Question:
Hi everyone!

I am very new to linux so sorry for a very basic question. I would like to find out what is the IP address of my computer using the linux operating system. Can someone help?
Answer:
The easiest way to find your IP address on Linux is with ifconfig or ip command or follow this link to check your Local and Public IP address directly using your web browser. The manual process of finding your internal IP address would be as follows. Start by opening your terminal and type:

Read more

How to explicitly exclude directory from find command’s search

This config shows some examples of find command allowing you to exclude directories explicitly from its search. Below you can find our sandbox directory containing multiple directories and files:

.
├── dir1
│   ├── dir2
│   │   └── dir3
│   │       └── file2
│   └── file1
├── dir4
│   └── file3
└── dir5
    └── dir6
        ├── dir4
        │   └── file4
        └── file4

7 directories, 5 files

Read more

Linux command line basics for beginners: Part 2

Hello, and welcome to part two of our Linux command line series. You will learn some more interesting tips that you can use to master your system, so hold on to your seats, because here we go.

The tasks, part two

Setting date and time

I must confess, this was a task that I had to do a long time ago in front of a terminal and had no idea how to do it. That is because I was used to the Gnome way of doing that but at the time I had no Gnome. So what to do?

man date

, of course. Depending on the country you live in, the date format differs from other parts of the world. In the United States, the date/time format is of the form mm/dd/yy or mm/dd/yyyy, where m is month, d is day and y is year, either in two-digit format (e.g. 86 for 1986). Where I’m getting at is the fact that the way that you set your date with the date command may differ from the format you’re used to (or what is used in your country). This paragraph will not be a manual page replacement, but it will help you set your system’s date/time quickly, provided you have root privileges. If you simply type

date

with no other arguments/flags, it will show you the current date. To set the date, you should type something like

date [MMDDhhmm[[CC]YY][.ss]]

M is month, D is day, h is hour, m is minute, C is century (the first two digits of year, like 20 for 2012), Y is year and s stands for seconds. Therefore to set your date for example to “Fri Jul 6 13:45:50 2012” you would do:

# date 070613452012.50

Read more

How to check CoreOS version and codename

Below you can find few ways on how to determine CoreOS version number.

Method 1

First method is dome simply by login. Every time you login to your CoreOS system a “Message of the day” located in /etc/motd is displayed:

Last login: Thu Dec 10 09:05:41 2015 from 10.0.0.8
CoreOS stable (835.9.0)

Alternatively, see the content /etc/motd:

# cat /etc/motd 
CoreOS stable (835.9.0)

Read more

How to create a file based filesystem using dd command on Linux

The following article will describe a procedure on how to create a file based filesystems using dd command on Linux.

First, create a zero filled file with a specific size using dd command. Below are few examples on how to create a such file of specific size:

1GB:
$ dd if=/dev/zero of=file.fs bs=1024 count=1024000
100MB:
$ dd if=/dev/zero of=file.fs bs=1024 count=102400
10MB:
$ dd if=/dev/zero of=file.fs bs=1024 count=10240
1MB:
$ dd if=/dev/zero of=file.fs bs=1024 count=1024

Read more

Linux command line basics for beginners: Part 3

Here’s another installment of the Linux CLI basics series. This time we will deal with other interest-worthy tasks, like setting up your keyboard layout or using utilities to find files on your drive(s). We hope that the series will help you become a keyboard/terminal guru.

The tasks, part three

Setting the keyboard layout

When you’re using some fancy desktop environment, changing the layout of your keyboard is simple and easy. A few clicks, you choose your preferred layout and maybe other localization settings and that’s that. But what if you find yourself at a command-line-only machine and you have to use the machine, but the layout is set to French? The keys show a symbol but you type another and nothing works as it should. What to do? Or you decided to dump bloated GNOME or KDE for some lightweight window manager like Fluxbox. What you should use for this task strictly depends on whether you have X installed or not. If you do, the utility is called setxkbmap. If you don’t you can use various tools provided by your distro (by the way, remember that we are using Ubuntu for our examples), but we will show you how to do it in terminal-only mode without depending on some distro-specific tools.

Read more

How to backup and restore permissions of the entire directory on Linux

The following two commands getfacl and setfacl are very handy tools as they allow Linux administrators to take a snapshot of any current permissions settings of any directory and if needed re-apply those permissions back recursively. Let’s have a look at the following example:

$ tree -p
.
├── [dr---w----]  dir1
│   └── [drwxr-xr-x]  dir2
│       ├── [dr--r-xrw-]  dir3
│       └── [---x--x--x]  file1
├── [drwxr-xr-x]  dir4
│   └── [-rw-r--r--]  file3
└── [-rwxrwxrwx]  file2

4 directories, 3 files

Read more

How to remove all docker images stored in a local repository

The following linux commands can be used to remove all Docker images stored in your local repository. Be aware that you would not be able to undo any of the removed docker images. First, list all your docker images to make sure that there is nothing you want to remove:

# docker images

Using the following linux command you can obtain image IDs of all your docker images:

# docker images -q

To remove a single docker image simply run docker rmi followed by the image ID. For example:

# docker rmi 9fa0e1f381ad

Read more