ShellHacks
42 subscribers
167 links
www.ShellHacks.com | Command-Line Tips & Tricks
Download Telegram
🌐 Kubectl: Force Delete Namespace Stuck In Terminating

Sometimes a deletion of a Namespace in Kubernetes gets hung up and the kubectl delete namespace command never completes.

Such Namespaces get stuck in a Terminating state but can be manually deleted using a Kubernetes API.

This note shows how to force delete the Terminating Namespaces in Kubernetes using the kubectl command.

πŸ“– Continue Reading
🌐 Kubectl: Run Pod With Command & Exec Into

Unless for very specific reasons, you should never run a Pod with a long-running application on its own, but use a Deployment for this.

Nevertheless, if you want to quickly run some container image on Kubernetes resources, you can use a kubectl run command.

For example, i often need to run the Pod on a Kubernetes cluster that starts a container from a wbitt/network-multitool image for container/network testing and troubleshooting.

This note shows how to run the Pod with the kubectl run command and how to log into the running Pod and start an interactive bash or sh session using the kubectl exec command.

πŸ“– Continue Reading
🌐 Restart X Server – Ubuntu Linux

While working on a Linux systems like Ubuntu, Linux Mint, etc., through a graphical user interface (GUI) it may happen that some application will hang the GUI and freeze a system.

To unfreeze the system without rebooting a machine we can restart an X server (also known as X11, or just X) that is the default GUI environment on most Linux distributions.

This note shows how to restart the X server from a command line and unfreeze the system.

πŸ“– Continue Reading
🌐 Helm Upgrade: Update Chart Values – Example

When you upgrade a Helm chart in a Kubernetes cluster you can also customize parameters of the chart to configure a release.

The Helm chart parameters customization is carried out by updating сhart values.

This note shows how to update a Helm chart with new values using a helm upgrade command.

πŸ“– Continue Reading
🌐 Helm: Dry Run & Template Debug

Helm uses a packaging format called charts (a collection of Kubernetes resource files).

This note shows how to --dry-run and --debug Helm chart templates with examples.

It also shows how to lint and render Helm chart YAMLs locally (without sending them to a Kubernetes API server).

πŸ“– Continue Reading
🌐 Vi/Vim: Dark Background – Change Color Scheme

If you use vi/vim text editor in a terminal with a dark background it may be hard to read some text due to improperly configured color scheme.

For example, dark-blue comments on a black background in vi/vim make them almost unreadable.

By default, vi/vim is configured to work with a light background, i.e. has a set background=light setting.

If you use the dark background in your terminal, you need to change the background setting in vi/vim, that will lead to adjustment of a color scheme to the dark background and make the text readable.

This short note shows how to fix colors on the dark background in vi/vim.

πŸ“– Continue Reading
🌐 Kubectl: Get Events & Sort By Time

Kubernetes events are automatically created when resources have state changes, errors or other messages that should be broadcasted to the system.

These events (logs) are very helpful for debugging issues in a Kubernetes cluster.

Unfortunately, a kubectl get events command, by default, returns an unsorted list of the events that is not easy to search through.

This note shows how to get the events using the kubectl command and sort them by time.

πŸ“– Continue Reading
🌐 OOM Killer Doesn’t Work Properly [SOLVED]

An out-of-memory (OOM) killer is a mechanism of the Linux kernel that is supposed to terminate (kill) high memory consuming processes if a system is critically low on memory.

Unfortunately, the OOM killer doesn't always work properly.

It often starts too late, when the system is already out of memory, so it doesn't have enough memory for itself, that leads to the frozen system.

This note shows how to call the OOM killer earlier, before the system gets into an unresponsive state.

πŸ“– Continue Reading
🌐 VLC: Change Preferred Audio Language Order

VLC Media Player can play video files with multiple audio tracks.

The audio track can be selected in "Audio" → "Audio Track" menu.

If you watch some series with a default language that doesn't suit you, you would have to manually change the audio track for each episode, that may be a bit annoying.

Luckily, in VLC we can change the default audio language order to a preferred one and in this short note i will show how to do this.

πŸ“– Continue Reading
🌐 Raspberry Pi: Wake from Sleep – Command

While using a Raspberry Pi (RPi) connected to a monitor or TV over HDMI, you may notice that the screen will be automatically put to sleep after a certain amount of time of inactivity.

To wake the RPi up it is usually enough just to move a mouse or press some key button.

But this can be more challenging if you can't use the mouse or keyboard to unblank the screen, e.g. you are connected remotely over SSH and it seem the only thing you can do is to reboot the RPi.

Lucky there is a way to wake the RPi and unblank the screen from a terminal by changing display power management and screen saver settings.

πŸ“– Continue Reading
🌐 MikroTik: Default IP, Login & Password

To get access to any of MikroTik routers you need to know an IP address of the router and credentials, i.e. a username and password.

All the MikroTik routers are pre-configured with the default IP address as well as with the the default username and password.

πŸ“– Continue Reading
🌐 Kubectl: Get Pod Containers

According to best practices you should always try to have one container per Pod, and this is the most common Kubernetes use case.

However, a Pod can contain multiple containers and the primary reason for this is to support helper applications that assist a primary application.

Typical examples of helper applications are data pullers, data pushers and proxies.

This short note shows how to get Pod containers using a kubectl command, and also how to get logs and log into the particular container running inside the Pod.

πŸ“– Continue Reading
🌐 Copy as Path: Get Full Path of File on Windows

An absolute path, also known as a full path, on Windows systems represents the complete details needed to locate a file or folder, starting from a drive letter (e.g. C:\), including all sub-folders and ending with the file or folder name.

Once you have located the desired file or folder in a File Explorer, there is a simple way to get the full path and copy it to a clipboard.

This short note shows how to unlock a "Copy as path" Windows feature to get the full path to the file or folder quickly and easily.

πŸ“– Continue Reading
🌐 Windows: Uninstalled Programs History

In Windows you can easily get a list of installed apps with the installation dates through a "Programs and Features" (press ⊞ Win + R to start the "Run" dialog and type in appwiz.cpl and click "OK").

To get a history of uninstalled programs is a bit more challenging, but is still possible using an "Event Viewer".

In the "Event Viewer" we can list the changes made by an MsiInstaller - the tool that Windows uses for any installations and uninstallations of applications.

Additionally, we can filter out that list by the event ID 1034, that exactly corresponds to the program uninstallation events.

Below you will find how to check the uninstalled programs history in Windows and how to find out who has uninstalled a program and when.

πŸ“– Continue Reading
🌐 Reset MikroTik Router

A MikroTik router reset, hard reset, factory reset and configuration reset are all synonyms for resetting the device to its original defaults.

If you reset your MikroTik router, you'll clear its configuration and return it to the original state it was in when you purchased it.

For example, if you forget a password to the MikroTik router, you might reset it to factory settings so it returns to the default password it originally came with.

Below you will find a short instructions of how to reset your MikroTik router.

πŸ“– Continue Reading
🌐 Connect To MikroTik Router For a First Time

MikroTik routers are very powerful, flexible and are widely used in all kinds of environments from a simple home to a large enterprise network.

For ones who are not familiar with networking and with the MikroTik routers particularly, it might be a bit challenging to connect to the new MikroTik router for the first time and access its management interface for the initial configuration.

From this article you will find out how to connect to the new MikroTik router for the first time using a direct connection via an Ethernet cable, connection over WiFi or through an ISP's (internet service provider) router.

πŸ“– Continue Reading
🌐 [SOLVED] The Container Name Is Already In Use By Container

While starting a Docker container, you may sometimes receive "the container name is already in use by container" error.

The complete error looks like as follows:

ERROR: for <containerName> Cannot create container for service <serviceName>: Conflict. The container name "<containerName>" is already in use by container "<containerID>". You have to remove (or rename) that container to be able to reuse that name.

This short note shows how to fix "the container name is already in use by container" error.

πŸ“– Continue Reading
πŸ‘1
🌐 MikroTik: Clear Terminal Screen

When you're working in a command line interface you may sometimes have a desire to empty a terminal screen from messages and keyboard input.

Depending on an operating system there should be a command that can erase the contents of your terminal and display a prompt only (for example a clear command in Linux or a cls command in Windows).

Although a MikroTik RouterOS is based on Linux, there is no a command to clear the screen.

Nevertheless the terminal screen in the MikroTik RouterOS can be cleared using a keyboard shortcut.

πŸ“– Continue Reading
🌐 Kustomize: Change Image, Tag or Registry

Kustomize is a tool for customizing Kubernetes configurations.

Like for secrets, in Kustomize, there is a custom directive that allows to easily override names, tags and change registries (repositories) of container images (e.g. Docker images).

This short note shows how to change the image name, tag or registry using Kustomize.

πŸ“– Continue Reading
🌐 Kubectl: Dry Run – Client | Server – Command Examples

A kubectl command can be used to create, delete or updated resources on a Kubernetes cluster.

With the --dry-run=(client|server) flag, the kubectl command can be used to only preview an object, without really submitting it to the Kubernetes cluster.

The dry-run mode is useful to see what will the kubectl command do without actually changing anything.

This short note shows different examples of how to run the kubectl command in the dry-run mode.

πŸ“– Continue Reading