Install Sublime Text 3 in Ubuntu

Editing Markdown file in Sublime Text 3 on Linux

Pretty cool! Didn’t realise this, but Sublime Text 3 is available for Linux as well! Today I took a few minutes to download/install it and to even make it use some of the GUI themes for better coding experience.

All of these steps are taken from the Sublime Text 3 website.

Step 1: Activate Sublime Text 3 repo

First, we install the key to trust Sublime Text 3 repo:

greys@xps:~ $ wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
 [sudo] password for greys: 
 OK

Now we ensure apt-get will support https protocol for working with repos:

greys@xps:~ $ sudo apt-get install apt-transport-https

We update apt sources with the repo URL:

greys@xps~ $ echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list

Step 2: Install Sublime Text 3

We refresh apt package info:

$ sudo apt-get update

and install the packages:

greys@xps:~/proj/unixtutorial/examples $ sudo apt-get install sublime-text
 Reading package lists… Done
 Building dependency tree       
 Reading state information… Done
 The following packages were automatically installed and are no longer required:
   dkms libgsoap-2.8.75 libvncserver1
 Use 'sudo apt autoremove' to remove them.
 The following NEW packages will be installed
   sublime-text
 0 to upgrade, 1 to newly install, 0 to remove and 73 not to upgrade.
 Need to get 9,835 kB of archives.
 After this operation, 34.8 MB of additional disk space will be used.
 Get:1 https://download.sublimetext.com apt/stable/ sublime-text 3211 [9,835 kB]
 Fetched 9,835 kB in 8s (1,189 kB/s)                                                                                    
 Selecting previously unselected package sublime-text.
 (Reading database … 271734 files and directories currently installed.)
 Preparing to unpack …/sublime-text_3211_amd64.deb …
 Unpacking sublime-text (3211) …
 Setting up sublime-text (3211) …
 Processing triggers for desktop-file-utils (0.24-1ubuntu1) …
 Processing triggers for mime-support (3.63ubuntu1) …
 Processing triggers for hicolor-icon-theme (0.17-2) …
 Processing triggers for gnome-menus (3.32.0-1ubuntu1) …

That’s it! Sublime Text 3 is now installed and can be started using the subl command:

Sublime Text 3

My primary environment is macOS, but it’s comforting to know that I can fall back on Dell XPS laptop with Ubuntu to edit some Ansible playbooks in a similar way.

See Also




Using grc (Generic Colouriser) for RSyslog

Colorized output for RSyslog files

I started updating my Centralised RSyslog server on Raspberry Pi the other day, and one of the things I’ve been meaning to research was syntax highlighting for RSyslog logs. After a brief search online, I found grc: a great tool for seeing output of many common Unix commands and log files in a completely new, colorful and useful way.

Install grc in Raspbian (Debian/Ubuntu)

I did this in Raspbian OS:

$ sudo apt-get install grc

It brought quote a few dependencies with it, but installed fairly quickly.

grc for looking at RSyslog output

Simply run grc and tail the messages file or RSyslog file. It will look like this:

RSyslog output with grc colouriser

Looking and process listing with ps and grc

Many common commands are used, but I’ll show just the ps command highlighting for now:

ps output with colorized syntax

That’s it for today. I think this is a must-have command line tool – am really impressed!

See Also




Sublime Text 3

Image result for sublime text 3 logo

Are you guys using Sublime Text 3?

Have heard and possibly even tried it before, wasn’t impressed. But this time I’m doing Ansible playbooks and some light Python scripting development – and Sublime Text 3 is really growing on me.

Will be updating this post in the future, to list my settings and document plugins I decided to use.

See Also




How To: Use Filesystem Labels in /etc/fstab

Filesystem label in /etc/fstab

Yesterday I have shown how to manage ext2/ext3/ext4 filesystem labels using e2label command. Continuing this topic, let’s update /etc/fstab file on my Ubuntu VM.

WARNING: don’t do this on a real server! try on a non-important virtual machine first, just to learn how to use commands, update fstab and so on. I’m using root filesystem (/) just because that’s the only filesystem I have on my Ubuntu VM.

Here’s how my /etc/fstab looks right now:

root@ubuntu:~ # cat /etc/fstab
# /etc/fstab: static file system information.
# 
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#           
# / was on /dev/sda1 during installation
UUID=ef0ca1f8-28cf-4baf-ada6-f2271aaece17 /               ext4    errors=remount-ro 0       1

Check filesystem label for / filesystem

If we run df -h command, we can see what device the root (/) filesystem is using:

root@ubuntu:~ # df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            964M     0  964M   0% /dev
tmpfs           199M  1.5M  197M   1% /run
/dev/sda1        63G  8.7G   51G  15% /
tmpfs           991M     0  991M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           991M     0  991M   0% /sys/fs/cgroup

Let’s use e2label to confirm label for /dev/sda1:

root@ubuntu:~ # e2label /dev/sda1
rootdisk

Perfect! Now that we know /dev/sda1 has label of “rootdisk“, let’s use this label to mount this filesystem going forward.

Update /etc/fstab to use filesystem labels

Editing the /etc/fstab file, comment out the UUID line for / filesystem (note the # at the start of the line now):

# UUID=ef0ca1f8-28cf-4baf-ada6-f2271aaece17 /               ext4    errors=remount-ro 0       1

and replace it with this:

LABEL=rootdisk    /               ext4    errors=remount-ro 0       1

Just to be sure things work as expected, let’s remount the filesystem rather than reboot the server:

root@ubuntu:~ # mount -o remount /

If you don’t get any errors back – this is working as expected.

See Also




How To: check and change filesystem label with e2label

e2label command for checking ext2/ext3/ext4 filesystem label

Some Linux distros (especially older ones) have preference for using filesystem labels instead of unique identifiers (UUIDs) or device names.

Long time ago there was a post here about using tune2fs for configuring filesystem label, but for ext filesystems (ext2/ext3/ext4) there’s an easier way: use e2label command.

Check ext2/ext3/ext4 Filesystem Label with e2label

Simply run e2label and specify the device name:

root@ubuntu:~ # e2label /dev/sda1

Set Filesystem Label with e2label

If you run the same command and specify the label, it will get assigned to the device:

root@ubuntu:~ # e2label /dev/sda1 rootdisk
root@ubuntu:~ # e2label /dev/sda1
rootdisk

I’ll show how to use filesystem labels in /etc/fstab tomorrow.

See Also




List Available Repositories in Red Hat

Listing repositories with subscription-manager

I have finally gotten around to launching a new RHEL 8.1 virtual machine on my macOS desktop, this time I installed it from RHEL 8.1 ISO image.

Although I have shown how to list available Red Hat subscriptions before, I never spent much time looking into various repos – so this post shows some basics.

Why You Need Repos in RHEL 8

RHEL 8 has more software repositories available via various subscriptions than ever. Each subscription maps your operating system to a number of related repos, providing utmost granularity to installing and updating software.

I had to learn how to list repos because I wanted to install Ansible packages, turning one of my servers into an Ansible deployment server. Although Ansible is an open-source project, it’s not a core element of Red Hat Enterprise Linux, and that means it’s not available via core RHEL 8 repositories.

Instead, you need to find and enable Ansible repo in RHEL 8 (I’ll show how it’s done in the next few days).

How To List Software Repositories in RHEL 8

Simply run subscription-manager command with repos parameter, you’ll get quite a number of repositories reported back (I’m only showing you the first few):

root@rhel8:~ # subscription-manager repos
+----------------------------------------------------------+
    Available Repositories in /etc/yum.repos.d/redhat.repo
+----------------------------------------------------------+
Repo ID:   rhel-atomic-7-cdk-2.4-rpms
Repo Name: Red Hat Container Development Kit 2.4 /(RPMs)
Repo URL:  https://cdn.redhat.com/content/dist/rhel/atomic/7/7Server/$basearch/cdk/2.4/os
Enabled:   0
Repo ID:   satellite-tools-6.6-for-rhel-8-x86_64-eus-rpms
Repo Name: Red Hat Satellite Tools 6.6 for RHEL 8 x86_64 - Extended Update Support (RPMs)
Repo URL:  https://cdn.redhat.com/content/eus/rhel8/$releasever/x86_64/sat-tools/6.6/os
Enabled:   0
Repo ID:   codeready-builder-for-rhel-8-x86_64-rpms
Repo Name: Red Hat CodeReady Linux Builder for RHEL 8 x86_64 (RPMs)
Repo URL:  https://cdn.redhat.com/content/dist/rhel8/$releasever/x86_64/codeready-builder/os
Enabled:   0
Repo ID:   satellite-tools-6.7-for-rhel-8-x86_64-rpms
Repo Name: Red Hat Satellite Tools 6.7 for RHEL 8 x86_64 (RPMs)
Repo URL:  https://cdn.redhat.com/content/dist/layered/rhel8/x86_64/sat-tools/6.7/os

When I say “quite a number“, I mean a lot of subscriptions are available:

root@rhel8:~ # subscription-manager repos | grep “Repo ID” | wc -l
148

See Also




Systemd Unit Types

systemd

I’m catching up on my systemd knowledge, this is almost a note to myself – a summary of the systemd unit types (yes, it’s a lot more than just startup scripts!).

How To Tell a systemd Unit Type

The quickest way to determine a systemd unit type is to just look at the last part of the unit file. For instance, if I list systemd units in /lib/systemd/system directory, I’ll find quite a mix. Here’s a fragment:

-rw-r--r--  1 root  1196 Jan 29 18:07 systemd-time-wait-sync.service
-rw-r--r-- 1 root 659 Jan 29 18:07 systemd-tmpfiles-clean.service
-rw-r--r-- 1 root 490 Feb 14 2019 systemd-tmpfiles-clean.timer
-rw-r--r-- 1 root 732 Jan 29 18:07 systemd-tmpfiles-setup-dev.service
-rw-r--r-- 1 root 772 Jan 29 18:07 systemd-tmpfiles-setup.service
-rw-r--r-- 1 root 635 Feb 14 2019 systemd-udevd-control.socket
-rw-r--r-- 1 root 610 Feb 14 2019 systemd-udevd-kernel.socket

I have highlighted the last part of each filename, and it shows the type of a particular unit: service, timer or socket (there’s more types, see below).

Types of systemd Units

Here are the systemd unit types I’ve come across so far. They must be the most common ones:

  • service: thats the one you’ve probably heard about, it’s a unit type for configuring and managing a software service (startup/shutdown) just like init scripts used to do – but in a far more flexible way
  • device – anything and everything for managing device files – stuff like operating files in /dev filesystem, etc
  • mount – Systemd style of managing filesystem mounts – for now these are mostly internal OS use filesystems of special types. The more traditional filesystems like / or /var are still managed in /etc/fstab
  • timer – scheduling system for running low-level tasks like OS self-healing and maintenance – this is where mdcheck (software RAID arrays) runs and how apt/yum repos are updated.
  • target – similar to milestones in Solaris 10, this is a boot management mechanism where you create these targets with meaningful names which become logical points of alignment for system initialisation and startup. There are targets for printing, rebooting, system update or multi-user mode – so other Systemd units can be depedencies and dedepdants for such targets.

See Also




Tower 4.0 for Mac

Tower 4.0 is out!

Great news! Tower (I still keep calling it Git Tower) released version 4.0 recently, with a number of bug fixes and a great new feature.

I’m not a software developer, but find myself writing and managing more and more code in the recent years – mostly infrastructure as code, but also Python scripts for my mini-projects.

I’ve been a user of Tower for the past 2 years and must say it’s a pleasure to use. I tried other GUI solutions for working with git, but on MacOS this Tower thing is so good there’s no competition.

Improvements in Tower 4.0

The biggest thing is the massively improved undo function – Cmd+Z now helps with undoing quite a bunch of accidental changes in your git environment.

For my (fairly basic) knowledge of git, here are the common mistakes that Cmd+Z will help with:

  • Undo deleting a branch or tag
  • Undo deleting files
  • Undo committing changes
  • Undo publishing a branch on a remote
  • Undo staging/unstaging changes

See Also




SSH Reference Mindmap

I haven’t shared this on Unix Tutorial before, but I’m a huge fan of mindmaps. I create and use them all the time for any process or knowledge that I am working with.

It seems to me that all the Unix Reference pages I’m creating will greatly benefit from mindmaps, so here’s an example of what I mean:

SSH Reference Mindmap

Why I Like Midmaps

  • it’s a great way to mentally place certain peices of knowledge to where they belong – so that you understand how certain topics relate to each other and this means you’ll remember them better
  • a mindmap is an awesome and very quick way to refresh your knowledge about something – even without specifics like port numbers and command lines you can still learn, remember and recall a lot
  • a mindmap is invaluable to highlighting gaps in knowledge – as you place broad topics into the midmap branch, you often realise that you need to learn more before that section is complete
  • it’s a great learning tool – I can just add questions about things I don’t know and come back later to update them with newly learned pieces of information

Let me know what you think!

pS: I’m preparing my Unix Tutorial Patreon page this month – so check it out and let me know how I can make Unix Tutorial better to help you learn and succeed. It will mean a lot if you decide to become a patron!

See Also




Basic Kubernetes Cluster with 2 VMs

I’m researching for my next Unix Tutorial Project, so today I’m spinning up two new Ubuntu 19.10 VMs and configuring them as Kubernetes Master and Kubernetes Node, accessible from my macOS desktop.

This is just a bunch of notes on the topic, the project will have the full procedure (and a YouTube video, if everything works out as I expect).

NOTE: I’m using install instructions supplied by Docker and Google for their packages install. Apparently, there’s a few more ways and packaing systems to get similar results specifically on Ubuntu.

Step 1: Spin Up the 2 VMs

I chose Ubuntu, but any Linux capable of running Docker should be fine.

The plan is to have one VM as Kubernetes Master (k8master) and another VM as Kubernetes Node (k8node1) – that’s where our containers will actually run.

I’m using Parallels on macOS, it has this express install which means you just point it at an ISO and it does unattended Ubuntu install. Really cool!

Step 2: Configure Host-Only Networking

Now, we need to shut down both VMs and then add host-only network adapter to each – this will be used for cluster communication and for remotely managing k8s.

IMPORTANT: this is an additional interface. The primary one is separate and used for Internet access (cause we need it to install software).

Step 3: Install Docker and Kubernetes on both VMs

Pretty standard procedure, following official install guides. This needs to be done on both Ubuntu 19.10 VMs.

The only thing is that Ubuntu 19.10 (code name Eoan in repo URLs) is not supported properly, so I ended up using previous distro codename (disco) for Docker URL:

$ echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu disco stable" | sudo tee -a /etc/apt/sources.list.d/docker.list
$ echo "deb https://apt.kubernetes.io/ kubernetes-eoan main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
$ sudo apt-get update

Install Docker

$ sudo apt-get install docker-ce
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
aufs-tools cgroupfs-mount containerd.io docker-ce-cli git git-man liberror-perl pigz
Suggested packages:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli git git-man liberror-perl pigz
0 upgraded, 9 newly installed, 0 to remove and 175 not upgraded.
Need to get 90.5 MB of archives.
After this operation, 418 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Install k8s (Kubernetes)

$ sudo apt-get install -y kubelet kubeadm kubectl
 Reading package lists… Done
 Building dependency tree
 Reading state information… Done
 The following additional packages will be installed:
   conntrack cri-tools ebtables ethtool kubernetes-cni socat
 Suggested packages:
   nftables
 The following NEW packages will be installed:
   conntrack cri-tools ebtables ethtool kubeadm kubectl kubelet kubernetes-cni socat
 0 upgraded, 9 newly installed, 0 to remove and 175 not upgraded.
 Need to get 51.8 MB of archives.
 After this operation, 273 MB of additional disk space will be used.

Step 4: Setup Kubernetes Cluster

This means starting a master node:

greys@k8master:~$ sudo kubeadm init --pod-network-cidr=10.37.0.0/16 --apiserver-advertise-address=10.37.129.3

and then using the command from the output in previous step, join the Kubernetes node 1 to the cluster:

root@k8node1:/# kubeadm join 10.37.129.3:6443 --token 2cqf5d.ykwwsripsqe0s530     --discovery-token-ca-cert-hash sha256:418c2ef3a98d73cddaea8b3470d7b710c384f1644b87785e7e907e8ef44a2193

This is how we’d verify status:

greys@k8master:~$ kubectl get pods –all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-6955765f44-r567t 0/1 Pending 0 6m38s
kube-system coredns-6955765f44-wj4vw 0/1 Pending 0 6m38s
kube-system etcd-k8master 1/1 Running 0 6m50s
kube-system kube-apiserver-k8master 1/1 Running 0 6m50s
kube-system kube-controller-manager-k8master 1/1 Running 0 6m50s
kube-system kube-proxy-g5ntg 1/1 Running 0 5m4s
kube-system kube-proxy-m24gq 1/1 Running 0 6m38s
kube-system kube-scheduler-k8master 1/1 Running 0 6m50s

Confirm status of nodes:

greys@k8master:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8master NotReady master 12m v1.17.3
k8node1 NotReady 10m v1.17.3

Step 5: Connect to Kubernetes Master from my desktop

This step will need some consideration because I already have local Kubernetes setup on my desktop (via docker-desktop), which I’d like to keep. So I’ll need to add another configuration, I suspect.

That’s all for now!

See Also