π Python: Download File from URL & Save
A Python can be used to download a text or a binary data from a URL by reading the response of a urllib.request.urlopen.
The downloaded data can be stored as a variable and/or saved to a local drive as a file.
Below you will find the examples of the Python code snippets for downloading the different types of files from URLs and storing them as variables or saving locally.
π Continue Reading
A Python can be used to download a text or a binary data from a URL by reading the response of a urllib.request.urlopen.
The downloaded data can be stored as a variable and/or saved to a local drive as a file.
Below you will find the examples of the Python code snippets for downloading the different types of files from URLs and storing them as variables or saving locally.
π Continue Reading
ShellHacks
Python: Download File from URL & Save
A Python can be used to download a text or a binary data from a URL by reading the response of a urllib.request.urlopen. The downloaded data can be stored as a variable and/or saved to a local drive as a file. Below you will find the examples of the Pythonβ¦
π Python: Sleep Random Time β Web Scraping
Some websites can block access to prevent web scraping, that can be easily detected if your Python script is sending multiple requests in a short period of time.
To not get banned you can try to add random delays between queries.
For this you can use the Python's
π Continue Reading
Some websites can block access to prevent web scraping, that can be easily detected if your Python script is sending multiple requests in a short period of time.
To not get banned you can try to add random delays between queries.
For this you can use the Python's
sleep()
function that suspends (waits) execution of the current thread for a given number of seconds with the randint()
function that returns a random integer. π Continue Reading
ShellHacks
Python: Sleep Random Time - Web Scraping
How to sleep (wait) a random number of seconds between queries using the Python's `sleep()` and `randint()` functions.
π Git Bash: Clear History
The
If you try to clear the commands history in the Git Bash using this command, it won't work - you will still see the history of the executed commands after the application restart.
To completely erase the Git Bash history you need to locate and delete the
π Continue Reading
The
history -cw
command is used to clear a Bash history on Linux, but for some reason it doesn't work for a Git Bash on Windows.If you try to clear the commands history in the Git Bash using this command, it won't work - you will still see the history of the executed commands after the application restart.
To completely erase the Git Bash history you need to locate and delete the
.bash_history
file and then run the history -c
command. π Continue Reading
ShellHacks
Git Bash: Clear History - ShellHacks
How to clear Bash history (commands history) in Git Bash on Windows. After running these commands the Bash history will be completely erased.
π Kubernetes: Deployment Is Not Creating Pods
Imagine the situation, when you are starting a Deployment of some application on a Kubernetes cluster by running, for example, the
Then you execute the
Below i will show you how to start troubleshooting when the Deployment is not creating the Pods on a Kubernetes cluster.
π Continue Reading
Imagine the situation, when you are starting a Deployment of some application on a Kubernetes cluster by running, for example, the
kubectl create deployment
command.Then you execute the
kubectl get pods
command to list the Pods, but it returns "No resource found", that means the Deployment hasn't created any Pods.Below i will show you how to start troubleshooting when the Deployment is not creating the Pods on a Kubernetes cluster.
π Continue Reading
ShellHacks
Kubernetes: Deployment Is Not Creating Pods - ShellHacks
How to troubleshoot when a Deployment is not ready and is not creating Pods on a Kubernetes cluster.
π Change Computer Name β Windows CMD & PowerShell
To show a computer's name in Windows, simply execute the
There may be multiple reasons to rename the computer.
In this article, i will show you how to change your computer's name in Windows using the
π Continue Reading
To show a computer's name in Windows, simply execute the
hostname
command from a Windows command prompt (CMD
) or PowerShell.There may be multiple reasons to rename the computer.
In this article, i will show you how to change your computer's name in Windows using the
CMD
and PowerShell. π Continue Reading
ShellHacks
Change Computer Name - Windows CMD & PowerShell - ShellHacks
How to rename a computer in Windows (change a `hostname`) from a Windows command prompt (CMD) and PowerShell.
π Windows: Migrate Domain User Profile To Local
If you are leaving a company and keep your corporate laptop, that is in a company's AD domain (e.g. AzureAD), with you, you may wonder how to keep your user's profile settings and data before removing it from the domain.
Unfortunately, by the moment, Microsoft doesn't propose any official tool to migrate the domain user profile to the local one (at least i couldn't find one).
Nevertheless, there is a tool called "User Profile Wizard", created by ForensiT's, that can be used to copy the domain user profile to the local one and in this article I will show you how to do this.
π Continue Reading
If you are leaving a company and keep your corporate laptop, that is in a company's AD domain (e.g. AzureAD), with you, you may wonder how to keep your user's profile settings and data before removing it from the domain.
Unfortunately, by the moment, Microsoft doesn't propose any official tool to migrate the domain user profile to the local one (at least i couldn't find one).
Nevertheless, there is a tool called "User Profile Wizard", created by ForensiT's, that can be used to copy the domain user profile to the local one and in this article I will show you how to do this.
π Continue Reading
ShellHacks
Windows: Migrate Domain User Profile To Local - ShellHacks
How to copy/migrate a domain user profile (e.g. Azure AD) to a local user profile.
π Windows: Get a Userβs SID β CMD & PowerShell
Any user, group or computer in Windows has a unique SID (security identifier) assigned.
The SIDs are used to control access to various Windows resources like files, registry keys, network shares, etc.
Below i will show you how to get the user's SID and how to do the reverse SID lookup (get the user name by SID) using the Windows command prompt or PowerShell.
π Continue Reading
Any user, group or computer in Windows has a unique SID (security identifier) assigned.
The SIDs are used to control access to various Windows resources like files, registry keys, network shares, etc.
Below i will show you how to get the user's SID and how to do the reverse SID lookup (get the user name by SID) using the Windows command prompt or PowerShell.
π Continue Reading
ShellHacks
Windows: Get a User's SID - CMD & PowerShell - ShellHacks
How to get the user's SID and how to do the reverse SID lookup (get the user name by SID) using the Windows CMD or PowerShell.
π Docker Compose: Pull Latest Image Version
The
So after a while you may find, that despite of the
Below i will show how to force the
π Continue Reading
The
docker-compose up
command doesn't check a registry for a newer version of an image if it finds the image:latest
among the locally cached images.So after a while you may find, that despite of the
:latest
tag of the image in a docker-compose.yml
file, the docker-compose up
command doesn't pull the latest version of this image even though it is available in the registry.Below i will show how to force the
docker-compose up
command to pull the latest version of the images. π Continue Reading
ShellHacks
Docker Compose: Pull Latest Image Version - ShellHacks
How to force a Docker Compose to pull the latest version of an image.
π Start Maximized | Minimized Program β CMD (Batch)
A
The new window can be started as maximized or minimized, that can be controlled using the
Below i will show how to start a program in the maximized or minimized window from the Windows command prompt (CMD) or a batch file.
π Continue Reading
A
START
command is used to run a program or command in a separate window from a Windows command prompt (CMD).The new window can be started as maximized or minimized, that can be controlled using the
/MAX
or /MIN
switches correspondingly.Below i will show how to start a program in the maximized or minimized window from the Windows command prompt (CMD) or a batch file.
π Continue Reading
ShellHacks
Start Maximized | Minimized Program - CMD (Batch) - ShellHacks
How to START a program in a maximized or minimized window from a Windows command prompt (CMD) or a batch file.
π Ansible Playbook βDry Runβ β Check Mode
An Ansible's "dry run" or check mode feature is just a simulation of the execution of the
When the
With the Ansible's "dry run" feature you can see if the target system is getting changed or not before actually applying the playbook and making any changes on the target host.
π Continue Reading
An Ansible's "dry run" or check mode feature is just a simulation of the execution of the
ansible-playbook
command.When the
ansible-playbook
command is executed in the check mode, it will not make any changes on a target system.With the Ansible's "dry run" feature you can see if the target system is getting changed or not before actually applying the playbook and making any changes on the target host.
π Continue Reading
ShellHacks
Ansible Playbook "Dry Run" - Check Mode - ShellHacks
How to run an Ansible playbook in a check mode ("dry run") without actually making any changes on the target system.
π SSHPass: SSH Login With Password β Command Line
A password-based authentication is often a default way to connect to a remote host over SSH.
But as it requires a user to enter a password manually, this creates some complicity if you need to automate the SSH login.
This note shows how to login over SSH by passing the password as a parameter on a command-line using the
π Continue Reading
A password-based authentication is often a default way to connect to a remote host over SSH.
But as it requires a user to enter a password manually, this creates some complicity if you need to automate the SSH login.
This note shows how to login over SSH by passing the password as a parameter on a command-line using the
sshpass
command. π Continue Reading
ShellHacks
SSHPass: SSH Login With Password - Command Line - ShellHacks
How to automate SSH login with a clear-text password passed as a parameter on the command-line using the `sshpass` command.
π Find Out Text File Line Endings β LF or CLRF
A newline (also known as a line ending, end of line (EOL) or line break) is a character used to represent the end of a line of text and the beginning of a new line.
Text files created on DOS/Windows machines have different line endings than files created on Unix/Linux.
This note shows how to find out the line endings in a text file and how to change them.
π Continue Reading
A newline (also known as a line ending, end of line (EOL) or line break) is a character used to represent the end of a line of text and the beginning of a new line.
Text files created on DOS/Windows machines have different line endings than files created on Unix/Linux.
This note shows how to find out the line endings in a text file and how to change them.
π Continue Reading
ShellHacks
Find Out Text File Line Endings - LF or CLRF - ShellHacks
How to find out the line endings in a text file and how to convert the Unix/Linux newline characters ("n" or "LF") to DOS/Windows ("rn" or "CRLF").
π What Active Directory Groups Am I In?
If your computer is running in a corporate environment, one day you may wonder which Active Directory (AD) groups your current user is a member of.
The easiest way to see what AD groups i am a member of is by executing the appropriate commands from a command prompt (CMD or PowerShell) and this short note shows how to do this.
π Continue Reading
If your computer is running in a corporate environment, one day you may wonder which Active Directory (AD) groups your current user is a member of.
The easiest way to see what AD groups i am a member of is by executing the appropriate commands from a command prompt (CMD or PowerShell) and this short note shows how to do this.
π Continue Reading
ShellHacks
What Active Directory Groups Am I In? - ShellHacks
How to find out which Active Directory (AD) groups I am a member of using a Windows command prompt (CMD) or PowerShell.
π Screen: Rename Session
A named screen session can be started by using the
If you start a simple screen session, by default, it will be named as something like
No matter how the screen session has been started, it can be easily renamed at any time.
This short note shows how to rename a GNU screen session in Linux.
π Continue Reading
A named screen session can be started by using the
screen -S <sessionName>
command.If you start a simple screen session, by default, it will be named as something like
55355.pts-0.hostname
.No matter how the screen session has been started, it can be easily renamed at any time.
This short note shows how to rename a GNU screen session in Linux.
π Continue Reading
ShellHacks
Screen: Rename Session - ShellHacks
How to rename a GNU screen session in Linux.
π Kubectl: Set Default Namespace β Kubernetes
Out of the box, there is a Namespace called 'default' in a Kubernetes cluster.
By default, the
In this note i will show how to set the default Namespace in Kubernetes.
π Continue Reading
Out of the box, there is a Namespace called 'default' in a Kubernetes cluster.
By default, the
kubectl
command interacts with this 'default' Namespace, but it can be changed to any other Namespace.In this note i will show how to set the default Namespace in Kubernetes.
π Continue Reading
ShellHacks
Kubectl: Set Default Namespace - Kubernetes - ShellHacks
How to set the default Namespace in Kubernetes using the `kubectl` command.
π Umount: Force β Target | Device is Busy
An
Sometimes, when you run the
Luckily, it is possible to run the
π Continue Reading
An
umount
command is used to unmount a device/partition by specifying the path to the directory where it has been mounted.Sometimes, when you run the
umount
command you may receive the "target is busy" or "device is busy" errors indicating that there is some process that is using the mounted filesystem or the remote file server is not responding for some reason.Luckily, it is possible to run the
umount
command forcefully and this short note shows how to do this safely. π Continue Reading
ShellHacks
Umount: Force - Target | Device is Busy - ShellHacks
How to `umount` a device/partition forcefully in case of the "target is busy" or "device is busy" errors.
π Jenkins: List All Jobs β Groovy Script
The easiest way to get a list of all Jenkins jobs is by executing an appropriate Groovy script using a Jenkins script console feature.
This note shows two examples of Groovy scripts for listing the Jenkins jobs.
The first script simply prints the list of all Jenkins jobs while the second one additionally lets you to identify how the last build of each job was triggered, e.g. manually by user, triggered by commit, by schedule etc.
π Continue Reading
The easiest way to get a list of all Jenkins jobs is by executing an appropriate Groovy script using a Jenkins script console feature.
This note shows two examples of Groovy scripts for listing the Jenkins jobs.
The first script simply prints the list of all Jenkins jobs while the second one additionally lets you to identify how the last build of each job was triggered, e.g. manually by user, triggered by commit, by schedule etc.
π Continue Reading
ShellHacks
Jenkins: List All Jobs - Groovy Script - ShellHacks
List all Jenkins jobs using a Groovy script. Identify how the last build of each job was triggered: manually by user, triggered by commit, by schedule etc.
π Linux: Find Files by Name & Grep Contents
The Linux
If you use the
This short note shows how to recursively find files by name and
π Continue Reading
The Linux
find
command can be used for searching files and directories and performing subsequent operations on them.If you use the
find
command to recursively search for some files and then pipe the result to the grep
command, by doing this you will actually parse the file paths/names but not their contents. This short note shows how to recursively find files by name and
grep
their contents for some word or pattern. π Continue Reading
ShellHacks
Linux: Find Files by Name & Grep Contents - ShellHacks
How to recursively search for files by name using the Linux `find` command and `grep` then their contents for some word or pattern.
π Kubectl: Get Pods on Node
A Pod is a group of one or more containers with shared storage, network and lifecycle and is the basic deployable unit in Kubernetes.
Each Pod is scheduled on the same Node, and remains there until termination or deletion.
In this note i will show how to get Pods running on a specific Node using the
π Continue Reading
A Pod is a group of one or more containers with shared storage, network and lifecycle and is the basic deployable unit in Kubernetes.
Each Pod is scheduled on the same Node, and remains there until termination or deletion.
In this note i will show how to get Pods running on a specific Node using the
kubectl
command. π Continue Reading
ShellHacks
Kubectl: Get Pods on Node - ShellHacks
How to get Pods running on a specific Node in Kubernetes using the `kubectl` command.
π Kubernetes: Get Node Events
Kubernetes events are automatically created when other 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.
In this note i will show how to get events from a specific Node in the Kubernetes cluster using the
π Continue Reading
Kubernetes events are automatically created when other 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.
In this note i will show how to get events from a specific Node in the Kubernetes cluster using the
kubectl
command. π Continue Reading
ShellHacks
Kubernetes: Get Node Events - ShellHacks
How to get events (logs) from specific Node in Kubernetes using the `kubectl` command.