Home » 2020 » November

Boolean Operators: Comparing Values in Python

Boolean Operators in python

Python is widely used for both scripting and automation on Linux, as well as building web and standalone applications. Python is designed to be easy to learn, easy to write, and easy to read. It’s a great multi-purpose programming language. Boolean Values This article covers how boolean operators work in Python. In programming, a boolean value is either TRUE or FALSE. When comparing values in Python, a boolean value is returned allowing you to store the result of the comparison, or take a certain action … Read more

Home » 2020 » November

How to Search in Vim Text Editor

How to Search in Vim

This article explains how to search for words and expressions using Vim. Vim is ubiquitous, some tips and tricks can help you in everyday work life. So! Let’s explore simple searching, with Vim. Find a string Starting in normal mode, press forward-slash (/). Type in the string you’re looking for, and press enter. Press n to find the next occurrence. Once you reach the bottom, Vim loops back to the top. Reverse Search If you want to find all previous occurrences of a word, use … Read more

Home » 2020 » November

Linux cd Command: Change Directory

Linux cd Command Change Directory

This tutorial explains how to use the cd command in Linux to change the directory you are currently in, within the shell. We’ve previously covered how to look around in directories with ls. But now you need to start navigating around the directories. We’ll do that easily with cd, change directory. Let’s start with something simple, how do we learn more about simple baked in utils like cd? If you try: man cd It’ll report, “No manual entry for cd”. Most likely. Instead for baked … Read more

Home » 2020 » November

Linux chmod Recursive: How to Change File Permissions Recursively

Linux chmod Recursive

With the Linux chmod command, we can recursively change file permissions on all files and directories. This guide explains how. It’s likely you’ve run into the following errors before: 111 [Permission Denied] “Linux-Screw” [Permission Denied] “Linux-Screw” [readonly] For any system files, using sudo is the preferred way of editing a file. This allows you to keep all the system context. For everyday use with user files, it’s best to change permissions. chmod can do that for us. It keeps us from needing to escalate permission … Read more

Home » 2020 » November

PHP in_array Function: Check Array Values Exist

PHP in_array Function

The PHP in_array() function allows you to check for the presence of a value in an array, and take an option based on this result. Syntax in_array ( $needle , $haystack [, $strict = FALSE ] ) Note That: $needle can be a variable of any type (string, number, date, etc) $haystack should be an array (see here, here, and here for more about arrays) $strict is optional, and will ensure that the type of values is also compared when checking whether $needle is present If $strict is FALSE (the default behavior), the number … Read more

Categories PHP

Home » 2020 » November

Vim: How to Find and Replace

vim find and replace

This tutorial explains how to find and replace words in Vim/Vi. Vim provides the substitute command, similar to sed, for replacing text. Let’s go through and look at your options for finding and replacing text in this popular Linux text editor. Vim Syntax #from :help substitute :[range][substitute]/[pattern/{string}/[flags][count] For each line in [range] replace a match of {pattern} with {string}. For the {pattern} see pattern “:help pattern”. For instance if you wanted to replace all instances of Nov & Dec with Jan. :%s/Nov\|Dec/Jan/G When [range] and … Read more

Home » 2020 » November

Linux Change User Password (passwd)

Linux Change User Password

This tutorial explains how to use the Linux passwd command to change a user password or disable an account. You’re assigned a ticket: A simple password reset, but it’s for a Linux machine. What do you need to know to reset a password on Linux? First the basics. For users, the passwd authentication token is store in the /etc/shadow file. For groups, it’s stored in the appropriately named /etc/gshadow file. passwd allows you to change passwords for either. The normal usage of passwd is: Reset … Read more

Home » 2020 » November

Using the PHP Array ‘implode’ Function, with Examples

php implode function

We’ve previously covered the explode() function in PHP – now it’s time for implode()! This tutorial will teach you how to merge values from an array into a single string using the PHP implode() function. Processing data for presentation to the end-user is one of the common PHP tasks. PHP is frequently used on Linux to display database query results to the user. If some of those values are stored in an array, you may want to merge them into a single string for ease of display or brevity … Read more

Categories PHP

Home » 2020 » November

PHP strpos Function: Check if a String Contains Another String

php strpos function

The PHP strpos() function checks whether a string is contained within another string – for example checking whether a certain word appears in a sentence, and what position it appears in.  It is a great companion to the PHP substr() and str_replace() functions for processing text data. Syntax strpos ( $haystack , $needle [, $offset = 0 ] ) Note that: $haystack is the string (text or series of characters) we want to search within $needle is the string search term we are looking for $offset Is optional … Read more

Categories PHP

Home » 2020 » November

Check Python Version (Windows, Linux & macOS)

Check Python Version (Windows, Linux & macOS)

This tutorial explains how to check the version of Python that is installed on your system. The commands work on Windows, Linux & macOS, and with Python2 or Python3. Python is an incredibly popular and powerful programming language worldwide for everything from website development, content aggregation tools, link shortening, and writing scripts, to data analysis, virtual assistants, and machine learning. There are various versions available with different release dates, so how do you know which version is running on your machine? Here’s a quick guide … Read more