List gpg keys in your system

1.1. RPM based distros (RHEL, CentOS, Fedora)

Import:

$ sudo rpm --import repomd.xml.key

List:

$ rpm -q gpg-pubkey|sort

Getting info:

rpm -qi  | grep Summary   

(or without the ‘grep’ part to view full info of the key package)

To remove:

sudo rpm -e --allmatches 

Example:

[root chip ~]# rpm -q gpg-pubkey|sort
gpg-pubkey-1ac70ce6-41bebeef
gpg-pubkey-30c9ecf8-3f9da3f7
gpg-pubkey-4f2a6fd2-3f9d9d3b
gpg-pubkey-8df56d05-3e828977
gpg-pubkey-8df56d05-3e828977
gpg-pubkey-a109b1ec-3f6e28d5
gpg-pubkey-db42a60e-37ea5438
gpg-pubkey-e42d547b-3960bdf1
[root chip ~]# rpm -e --allmatches gpg-pubkey-8df56d05-3e828977
[root chip ~]# rpm -q gpg-pubkey|sort
gpg-pubkey-1ac70ce6-41bebeef
gpg-pubkey-30c9ecf8-3f9da3f7
gpg-pubkey-4f2a6fd2-3f9d9d3b
gpg-pubkey-a109b1ec-3f6e28d5
gpg-pubkey-db42a60e-37ea5438
gpg-pubkey-e42d547b-3960bdf1

1.2 Debian / Ubuntu

$ gpg --list-keys user_ID

Example:

$ gpg --list-keys
/home/iplsdk/.gnupg/pubring.gpg
-------------------------------
pub   2048R/E5****A4 2015-01-12
uid                  IBM Software Development Kit for Linux on Power
sub   2048R/F2*****9 2015-01-12

pub   4096R/78C*****4 2016-02-11
uid                  IBM SDK for Linux on Power (The IBM Software Development Kit for Linux on Power is a free Eclipse-based Integrated Development Environment) <iplsdk@linux.vnet.ibm.com>
sub   4096R/B3*****0 2016-02-1

Add a gpg-key in your environment:

After you get the .gpg file, you need to 'add-apt-key' it into your keyring. Here:
$ sudo apt-key add .gpg

Don’t forget:
$ sudo apt-get update

Cheers!

dmidecode: Getting the serial number of your x86 system

The serial number of your system can be easily found on the bottom of your laptop in most of the systems. However, if you are working with a remote server and need to collect its info things get a little complicated. But fear not, for there is dmidecode to save your day.

From the man page:

dmidecode is a tool for dumping a computer's DMI (some say SMBIOS) table
 contents in a human-readable format. This table contains a description of
 the system's hardware components, as well as other useful pieces of informa‐
 tion such as serial numbers and BIOS revision.(...)

So, give it a try and see what a plethora of information types you can see using a single command.

As for the serial number, issue:

$ sudo dmidecode -s system-serial-number

In my system:

$ sudo dmidecode -s system-serial-number
[sudo] password for dbkreling: 
BR5D81F0N

Cheers!

Installing vim on Fedora 25

I just booted a fresh Fedora 25 (server, ppc64le) and attempted to install vim (I do not like vi) and had the following error:

Error: Transaction check error:
 file /usr/share/man/man1/vim.1.gz from install of 
vim-common-2:8.0.133-2.fc25.ppc64le conflicts with 
file from package vim-minimal-2:7.4.1989-2.fc25.ppc64le

Cool, let’s remove vim-minimal:

$ sudo dnf remove vim-minimal

If you see what I saw, this will trigger the uninstall of a whole lot of packages, including sudo.Saying it will remove sudo can scare the bejesus out of many people, but this will not be a problem if you are logged as root. (sudo -s / sudo -su).

$ sudo -su

Now you can bravely go on: remove vim-minimal and then install vim-enhanced. You should be all good.

Cheers!

Git checkout to a remote branch

There are many ways to checkout to a remote branch of a repository. The simplest one is creating a new branch in your local repository with the same name of the remote one, git fetch, and then git checkout to the new branch.

But there is an even simpler way to do so, with the use of a single git flag: -t <remote_branch>

Like this:

14:01:38 ✘ dbkreling:(master)~/my-application/src$ git branch -r
 origin/HEAD -> origin/master
 origin/develop
 origin/master
 origin/release

I want to checkout the develop branch, still not one of my branches. Then:

14:03:44 ✔ dbkreling:(master)~/my-application/src$ git checkout -t origin/develop
 Branch develop set up to track remote branch develop from origin.
 Switched to a new branch 'develop'

 14:06:36 ✔ dbkreling:(develop)~/my-application/src$ git branch
 * develop
 master

Hope it helps.

Cheers!

Creating Git Aliases from Command Line

Creating git aliases is as easy as it is useful to speed your production time in development. The hard way — not so hard, actually — is as simple as adding a string in your /home/$USER/.gitconfig file. Like so:

[alias]
    co = checkout
    st = status
    unstage = reset HEAD --
    wc = whatchanged

Well, if you do not have any aliases configured yet, create an [alias] block there and start appending your aliases.

However, the easiest way is to issue a command line in your terminal, and the alias will be added for you and will be ready to be used. E.g.:

git config --global alias.st status

or

git config --global alias.wc whatchanged

Keep adding them as you wish.

To use them, just issue git <your-alias> [args]  from the command line.

Go ahead and share your most used aliases in the comments.

Thanks for reading.

Remove single file from a commit

1. Undo the last patch, without scrapping the changes:

-> $ git reset --soft HEAD^

2. Then reset the unwanted files in order to leave them out from the commit:

-> $ git reset HEAD path/to/unwanted_file

3. Now commit again, you can even re-use the same commit message:

-> $ git commit -c ORIG_HEAD

reference: http://stackoverflow.com/questions/12481639/remove-files-from-git-commit

Find out your gateway IP address

There are two ways of collecting the IP address of your current Gateway:

  1. netstat -r
  2. route -n

The output of both commands are the almost the same:

12:29:25 ✔ dbkreling:~$ sudo netstat -r
[sudo] password for dbkreling:
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         192.168.0.1     0.0.0.0         UG        0 0          0 wlan0
172.17.0.0      *               255.255.0.0     U         0 0          0 docker0
192.168.0.0     *               255.255.255.0   U         0 0          0 wlan0

12:29:36 ✔ dbkreling:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.0.0     0.0.0.0         255.255.255.0   U     9      0        0 wlan0

In my case above IP 192.168.0.1 is the gateway for my connection. The flag U indicates that route is up and G indicates that it is gateway.

Cheers!