Linux Cheat Sheet

Kill all processes named ‘java’:

killall -9 java

List LISTENING ports and their processes:

sudo lsof -i -P -n | grep LISTEN

Docker Cheat Sheet

Bash into a Running Container

docker exec -it <container_name> /bin/bash 

Manage Docker as a non-root user

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user.

If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

Add the docker group if it doesn’t already exist:

sudo groupadd docker

Add the connected user “$USER” to the docker group. Change the user name to match your preferred user if you do not want to use your current user:

sudo gpasswd -a $USER docker

Either do a:

newgrp docker

or log out/in to activate the changes to groups.


Installing a Package from AUR (Archlinux User Repository)

According to the Building Packages page from the Arch Linux, you need to:

  • Install the build essentials. These are needed to compile packages on Arch Linux.
$ sudo pacman -S kernel26-headers file base-devel abs
  • Obtain the PKGBUILD. You need to download the tarball that you want. You can find the tarballs for programs in the Archlinux User Repository (AUR).
  • Make the packages. Next you need to run makepkg in order to generate a package that pacman can install.
$ makepkg -Acs

The -A option ignores the target Arch architecture. The -c option cleans up the directory after makepkg is done, and -s installs the needed dependencies.

It is advised that you do NOT run makepkg as root as it can cause permanent damage to your system. If you really need to run it as root though, use the –asroot option.

  • Install the package. makepkg should have create a file in the directory with the filetype .pkg.tar.xz. You should install this package by using the -U option with pacman.
$ sudo pacman -U x.pkg.tar.xz

Make sure you replace x.pkg.tar.xz with the actual package name.

WebSphere Clear Old EJB Timer Tasks

In some cases old timer task might become orphaned in the EJB timer database, due to application name changes or other circumstances. You’ll see these kind of errors in the logs:
[31-5-16 15:45:46:648 CEST] 00000024 SchedulerDaem W SCHD0103W: The Scheduler WebSphere_EJB_Timer_Service (WebSphere_EJB_Timer_Service) was unable to run task 204 because the application or module is unavailable: my-app#my-ejb-1.0.0-SNAPSHOT.jar#MyEJB.

There is no ability to remove timers from the admin console, but you can use the WAS_HOME/bin/cancelEJBTimers command to remove them. You can view them first using the findEJBTimers command.

Linux (or Unix) Self-Extracting Archive using Makeself

Tried out Makeself out at work today, it works really well. We used it to automatically run database scripts on a database host.

An example:

./ --compress ./directory_containing_my_files ./ "A description or label for your archive" ./

To run:

./ <args_to_pass_to_script>

Unit docker-nnn.scope already exists.

Sometimes when starting a stopped docker container on CoreOS, an error is thrown:

Error response from daemon: Cannot start container sane: [8] System error: Unit docker-166be344aa25c9c1abc17daa2a14bb3d02cf10adc88e3ec795480a60c11a8e78.scope already exists.

It is usually caused by ‘.scope’ files that are not cleaned up by ‘systemd’. To fix the problem run this command, replacing the scope filename with yours:

sudo systemctl stop docker-166be344aa25c9c1abc17daa2a14bb3d02cf10adc88e3ec795480a60c11a8e78.scope

How I Installed CoreOS (Bare Metal)

1. Find an empty bare metal server. I’m using an MSI Windbox.
2. Build a Debian live bootable flash-drive.
3. Boot system in Debian, and login (user/live)
4. Run command:


5. Run command (Note: This will partition the HDD/SSD and install CoreOS, all data will be lost!):

sudo ./coreos-install -d /dev/sda -C stable

6. Create a file called ‘cloud-config.yml’ and the following minimum configuration:

 - name: core
   passwd: <your_hashed_password>

(Note: Passwd should be hashed, use one of the following tools):

1. mkpasswd --method=SHA-512 --rounds=4096
2. openssl passwd -1

7. Mount coreos filesystem and copy ‘cloud-config.yml’ file:

sudo mount /dev/sda6 /mnt
sudo cp -f cloud-config.yml /mnt/
sudo umount /mnt

8. Reboot!

Websphere Liberty Profile JMX Service URL

The localhost JMX service URL for a liberty profile Websphere instance can be found in the following file once the server is started:


It’ll contain the URL to connect to the JMX server:

service:jmx:rmi:// (omitted)

It can be used directly in a JMXServiceURL(); on your java code, but beware the URL will change each time the server is restarted.

How to Open Portable Heap Dump Files in Memory Analyzer Tool

To open IBM portable heap dump files (.phd) in Memory Analyzer Tool (MAT), you need to install the IBM Diagnostic Tool Framework for Java plugin:

  1. Help -> Install New Software
  2. Add site:
  3. Install IBM DTFJ plugin.

Now MAT should recognize the PHD files format.