ShellHacks
42 subscribers
167 links
www.ShellHacks.com | Command-Line Tips & Tricks
Download Telegram
🌐 Sublime Text: Enable Spell Check

A Sublime Text can check spelling out of the box and uses Hunspell spell checker for this, that is also used by LibreOffice, OpenOffice.org, Mozilla Firefox, Thunderbird, Google Chrome etc.

By default, the spell checking feature in the Sublime Text it is disabled.

This short note shows how to enable the spell checking in the Sublime Text.

πŸ“– Continue Reading
🌐 Kubectl: Delete Pods – Wildcard

When you deploy an application in a Kubernetes cluster, you usually set some labels on the Pods e.g. app=my-app.

These labels can be used as a wildcard for selecting a group of Pods for deletion.

This short note shows how to perform a wildcard deletion of Pods in Kubernetes.

πŸ“– Continue Reading
🌐 Kubernetes: Node β€˜NotReady’ [SOLVED]

When a Node in a Kubernetes cluster crashes or shuts down, it enters the 'NotReady' state in which it can't be used to run Pods and all stateful Pods running on it become unavailable.

Common reasons of the 'NotReady' error include a lack of resources on the Node, connectivity issue between the Node and the Control Plane, or an error related to a kube-proxy or kubelet.

This note shows how to troubleshoot the Kubernetes Node 'NotReady' state.

πŸ“– Continue Reading
🌐 Python: Login to Website – Selenium

Selenium is an open source tool that automates web browsers and is widely used for automated testing of web applications.

With Python and Selenium you can easily create a script that automates login to a website, that is very useful, for example, for web scraping.

This note shows how to create a Python script to login to a website automatically using Selenium on the example of Instagram.

πŸ“– Continue Reading
🌐 Python: Check Package Version

While working with Python you may wonder what is the version of a certain Python package (library) that you are using.

There are several ways of how to get the version of a package or module in Python.

This note describes how to check the version of Python packages from a Python shell, from a command-line (terminal) or using a pip command.

πŸ“– Continue Reading
🌐 Kubernetes: Get ServiceAccount Permissions/Roles

A Service Account in Kubernetes is a special type of non-human privileged account that provides an identity for processes that run in a Pod.

When you create a Pod, if you do not specify a Service Account, it is automatically assigned the default Service Account in the same Namespace.

This note shows how to list the Service Accounts in a Kubernetes cluster and how to get the Roles and permissions associated with a Service Account.

πŸ“– Continue Reading
🌐 You Need Permission to Perform This Action [FIXED]

While trying to delete, copy, move or rename some files or folders in Windows you may get the error: "You need permission to perform this action" followed by "You require permission from the computer's administrator to make changes to this file or folder".

This "Access Denied" error means that you are not authorized to make any changes to that file or folder, thought it may occur even if you are administrator.

In this note i will show how to fix the permissions on a file or folder and get rid of the "You need permission to perform this action" error in Windows.

πŸ“– Continue Reading
🌐 Disable Startup Programs in Windows

It is quite annoying when some apps are not expected to, but they are automatically opening on startup in Windows.

And it raises a perfectly logical question, how to stop such apps from running at startup.

In this note i will show the easiest and the most efficient way of how to find ALL startup programs in Windows and how to change their startup settings to stop them from automatically running at Windows startup.

πŸ“– Continue Reading
🌐 Change User Name of Local Account in Windows

There may be different reasons for changing a local user account name in Windows.

For example, you may want to change the name on the sign-in screen to your actual name instead of the nickname or vice versa.

This short note describes the easiest way of changing a user name of the local account in Windows.

πŸ“– Continue Reading
🌐 PasswordNeverExpires: Disable Password Expiration

A password expiration is a feature in Windows that forces users to change their passwords after a certain number of days.

When it is time to change your password, Windows will send you a "Consider changing your password" notification.

In this note i will show several ways of how to disable the password expiration of a local user account in Windows.

πŸ“– Continue Reading
🌐 Rename User Folder in Windows

User profiles in Windows on the most of computers are usually located in the folder C:\users\.

By default, the user folder name is the same as you user name.

But if you change your user name, the old name of your user folder will remain and you may want to rename it as well.

The renaming of the user folder in Windows is not so straightforward, but i will show how to do this in a quick, safe and easy way.

πŸ“– Continue Reading
🌐 Ansible: Skip Parameter If Variable Not Defined

In Ansible, if you run a task that has some module's parameter with a variable that is not set you will get "The task includes an option with an undefined variable" error.

If for some reason you can't or don't want to define this variable, you can make it optional.

In this case Ansible will ignore the parameter with the optional variable if it is not defined.

This note shows how to skip a module's parameter in Ansible if a variable is not defined.

πŸ“– Continue Reading
🌐 Python Script Not Showing Output [SOLVED]

It may happen that you execute a Python script and nothing happenes, i.e. it seems that it "hangs" without showing any output.

Even if you explicitly include some print() statements to debug the issue, it may still not print anything to a terminal.

One of the reasons of why your Python script does not show any output is because it buffers stdout and stderr steams instead of printing them.

This also can happen if you execute the Python script from a CI/CD pipeline (e.g. using Jenkins, Gitlab-CI, TeamCity, etc.) or if you run it using a Dockerfile.

This short note shows how to solve the issue when the Python script "hangs" and doesn't show any output.

πŸ“– Continue Reading
🌐 Linux Mint: Lock Screen on Lid Close – Enable/Disable

When a laptop lid is getting closed, different scenarios are possible: do nothing, blank screen, suspend or shutdown.

In Linux Mint, the system behavior on closing the lid is controlled by the "Power Management" and "Screensaver" settings.

This note shows how to enable or disable screen locking when closing the lid in Linux Mint.

πŸ“– Continue Reading
🌐 Click Button by Text – Python & Selenium

Selenium is an open source tool that automates web browsers and is widely used for automated testing of web applications.

With Python and Selenium you can easily create a script that searches a web-page for a button containing a particular text and clicks on it.

This note shows an example of how to find a button by text and click on it using Selenium and Python.

πŸ“– Continue Reading
🌐 Run Selenium Headless – Chrome | Firefox (Python)

Selenium is an open source tool for web browsers automation that is widely used in tandem with Python to test web applications.

As these tests are often automated and run on dedicated nodes, there is a sense to run Selenium in a headless mode, i.e. without opening a browser.

This note shows how to run headless Selenium in Python on the example of Chrome and Firefox browsers controlled by a ChromeDriver and GeckoDriver correspondingly.

πŸ“– Continue Reading
🌐 Python: Write to File | Read from File – Best Practice

To write something to a file or to read the content of a file in Python it is required to open() and close() the file properly.

The best practice in Python is to read/write to a file by using the with statement - the replacement for commonly used try...finally error-handling statements.

The with statement ensures that the file is closed when the block inside it is exited.

This note shows the best practice Python examples of how to write to a file or read the file's content and save it to a variable.

πŸ“– Continue Reading
🌐 Python: Send Message to Telegram

To send a message to a Telegram channel using Python, first of all it is required to create a Telegram bot.

While creating the Telegram bot you will get an apiToken and a chatID that will be used in a Python script to access the Telegram API and send the message.

In this note you will find the examples of the Python scripts for sending messages, images, etc. to Telegram through the API.

πŸ“– Continue Reading
🌐 Sublime Text: Remove Empty Lines

If you try to figure out how to remove the blank lines in a document, i.e. the lines that contain only spaces, tabs or the newline characters, you should know that in almost any IDE, like a Sublime Text, this can de done really simple.

The Sublime Text, like the other IDEs, has the ability to delete empty lines in the "Replace" operation by using the "Regular expression".

This short note shows how to remove empty lines in the Sublime Text.

πŸ“– Continue Reading
🌐 Kubectl: Get ConfigMap – Kubernetes

In programming, we use .env or separate config files to store settings, configurations or variables separately from the application code.

This permits to run the application in different environments.

A ConfigMap in a Kubernetes is used to achieve the same functionality - it allows to make applications portable by decoupling environment-specific configurations from the containers.

The ConfigMap is a dictionary of configuration settings that consists of key-value pairs.

This note shows how to get the ConfigMap using the kubectl command.

πŸ“– Continue Reading