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!

How to enable git-completion on PS1 variable

A nicer bash prompt I use includes a git completion script that indicates the branch of a repository I may be into. Like this:

git_completion

Green indicates “master” is clean and no modified files are present. Red indicates there is something new in that branch.

In order to configure that, I had to include some instructions on my .bashrc file. It looks like this:

# git completion
source /usr/share/git-core/contrib/completion/git-prompt.sh

(…)

PS1=’\[\e[01;30m\]\t`if [ $? = 0 ]; then echo “\[\e[32m\] ✔ “; else echo “\[\e[31m\] ✘ “; fi`\[\e[00;40;37m\]\u\[\e[01;37m\]:`[[ $(git status 2> /dev/null | head -n2 | tail -n1) != “# Changes to be committed:” ]] && echo “\[\e[31m\]” || echo “\[\e[33m\]”“[[ $(git status 2> /dev/null | tail -n1) != “nothing to commit, working directory clean” ]] || echo “\[\e[32m\]”`$(__git_ps1 “(%s)\[\e[00m\0]”)\[\e[01;34m\]\w\[\e[00m\]\$ ‘

Now, sometimes (in a new environment mostly), we may configure the .bashrc just the way we want it and then:

git_2

Boom! You see a big "__git_ps1: command not found"  message.

That is because you don’t have the git-prompt.sh file you included in the directory loaded at the top of you .bashrc file (the /usr/share/git-core/contrib/completion/git-prompt.sh)

So in order to get rid of that, we need to include it. The file is available in contrib/completion/git-prompt.bash from the git repository git://git.kernel.org/pub/scm/git/git.git

So after you clone it, you should simply copy the missing files to your system file system. In my case, I preferred to copy the whole “completion” dir to my file systems, as I did not have it. So:

$ sudo cp -r completion/ /usr/share/git-core/contrib/

Now I have my git-completion.bash file in the correct place. Let’s see if that worked when running a new bash session:

git_3

Great! Worked like a charm.

Let me know if you have a different solution for it or if this did not solve your problem.

Thanks for reading.

Cheers!

Technically Speaking was used as a reference for this post.

Create a new user on your system

This is a quick checklist on how to create a user from the command line:
1. useradd -m your_username (add a user called your_username with a home directory)
2. passwd your_username (set a password for your_username)
3. usermod -aG wheel your_username  (to include the user in the sudoers list)
4. su - your_username (to change to the your_username account)
NOTE: sudo usermod -a -G sudo username (to include user ‘username’ in the sudo group)

Installing clang on RHEL/CentOS and Ubuntu

For RHEL and CentOS:

1) Install EPEL repository (read here on how to install it)

2) Install clang package:
$ sudo yum install clang

For Ubuntu 16.04:

1) Install clang packages:
$ sudo apt-get install clang libclang-dev

2) Create a symlink to libclang:
$ cd /usr/lib/-linux-gnu
$ sudo ln -s libclang-.so libclang.so

Example:
$ cd /usr/lib/powerpc64le-linux-gnu
$ sudo ln -s libclang-3.8.so libclang.so