Quantcast
Image

Search Results for: empty

How to list files recursively in Linux

By  •  May 28, 2018

The command used to list directory content in Linux is ls. With the -R option, ls will traverse the directory recursively, showing the content of the particular directory and all its subdirectories. Relative directory path is displayed before the directory content is actually listed.

The following is an example of the command in use;

$ ls -R testdir/
testdir/:
subdir1  subdir2

testdir/subdir1:
subsubdir1  subsubdir2

testdir/subdir1/subsubdir1:
file1

testdir/subdir1/subsubdir2:
file2

testdir/subdir2:
subsubdir1  subsubdir2

testdir/subdir2/subsubdir1:
file3

testdir/subdir2/subsubdir2:
file4

How to clone MySQL table

By  •  May 28, 2018

If you want to create a new MySQL table with the same structure as an existing table, you can use the following MySQL statement;

CREATE TABLE new_table LIKE source_table;

This will just create a new, empty table and does not copy the following;

  • Foreign key definitions
  • DATA DIRECTORY
  • INDEX DIRECTORY
  • Data

To also copy the data from the source table, use the following INSERT statement after the table is created;

INSERT INTO new_table SELECT * FROM source_table;

How to generate SSH keypair

By  •  May 28, 2018

You can easily create an SSH key pair by using ssh-keygen as in the following example.

$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
1a:6c:a4:94:df:e0:19:ec:85:b0:3f:27:e4:a1:de:65 user@host
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|   .             |
|    o E          |
|     O o         |
|    c @ S        |
|   o A @         |
|    . E .        |
|   . =           |
|    .            |
+-----------------+

There are a few things that you might want need to take note;

  1. A 2048 bit RSA key pair will be generated by default. You can use different key type by using -t option and specify any of the supported key types

    dsa ecdsa ed25519 rsa rsa1
  2. The private key will be stored in ~/.ssh/id_rsa while the public key will be stored in ~/.ssh/id_rsa.pub. You can specify other location when prompted during the key generation process if you already have a key pair at the default location
  3. You can specify passphrase for your key pair when prompted but you’ll have to not set the passphrase to use passwordless SSH login

How to recover lost GRUB bootloader in Linux

By  •  May 28, 2018

GRUB is a small program used to manage booting into operating systems, loaded by the MBR. It allows you to select operating systems to boot and specify boot options …
Read More

How to extract 7z file in Linux

By  •  May 28, 2018

7-Zip is a file archiver program that claims to compress files into smaller size compared to other programs such as WinRAR and WinZip. The program can pack and unpack various formats such as ZIP, GZIP, BZIP2, TAR, and of course, its own format, 7z. The 7z format itself is actually a container that supports few compression method such as LZMA, Deflate and BZIP2, with LZMA as default.

Top