Blog

How to fix “can’t log into YouTube from Safari” on macOS

Posted by on 7:39 pm in Knowledge Base | Comments Off on How to fix “can’t log into YouTube from Safari” on macOS

Something rather strange happened to me today: Safari 10 on macOS Sierra refused to let me login to YouTube. All it did was constantly refresh the page in an endless loop, or just display the front page of YouTube. I cleared the caches, reset the history, but no trick seemed to solve the problem. When I dug deeper into the Preferences, I found something under Privacy that finally fixed it. Let me share with you what worked on my system. head over to Safari – Preferences select the Privacy tab you’ll see a window like this one:...

read more

How to rename a batch of files in Linux

Posted by on 7:11 pm in Knowledge Base | Comments Off on How to rename a batch of files in Linux

Bulk renaming files can be done with the rename command. It shares many similarities with cp and mv, but its simplicity can be so staggering that its difficult to figure out how to use it. If we just type “rename” at the command prompt, all we get is the message rename call: rename from to files... While technically correct, what on earth does it mean? How do we use rename? Let’s do a little exercise. Imagine we had a batch of files, perhaps something like “Title 101.mp4” to “Title 110.mp4”....

read more

How to exit VI with or without saving

Posted by on 4:01 pm in Knowledge Base | Comments Off on How to exit VI with or without saving

Although many alternatives exist, I like using vi for all my command line editing needs. To save changes, I usually use SHIFT + Z + Z, exiting vi under most circumstances. But sometimes, this trick doesn’t work because of write permission problems. In such cases, vi doesn’t close with the above command. Instead, we must either stash our changes in another file, or quit the session without saving. Here’s how to do that. Quit vi without saving: :q! Save current file under a different name: :w newfile...

read more

How to read command line parameters in BASH Scripts

Posted by on 8:36 pm in Knowledge Base | Comments Off on How to read command line parameters in BASH Scripts

Shell Scripts (BASH Scripts) can access command line parameters using the the variables $1, $2, $2 and so forth, up to $9. In fact, more parameters can be accessed by using curly brackets, like ${10}, ${187} and so forth. Here’s an example: #!/bin/bash if [[ $1 == "x" ]]; then echo "Statement is true" else echo "Statement is false" fi If we run the script with like this script.sh x it will tell us the statement is true. Otherwise, it’ll tell us the opposite. Note the whitespace around the evaluation:...

read more

How to read command line parameters in PHP Shell Scripts

Posted by on 7:10 pm in Knowledge Base | Comments Off on How to read command line parameters in PHP Shell Scripts

We can access parameters passed via the command line in our PHP shell scripts. Those are stored as an array in the variable $argv. Consider this: #!/usr/bin/php <?php echo var_dump($argv); echo "\n"; if ($argv[1] == 'x') { echo "The parameter is x."; } else { echo "The parameter was something else."; } The first part of the script prints out all parameters that have been given, while the second part checks if the parameter was “x” or not. Note that the first item in the array ($argv[0])...

read more

How to extract files from a bz2 archive in Linux

Posted by on 3:29 pm in Knowledge Base | Comments Off on How to extract files from a bz2 archive in Linux

If you’ve ever tried to decompress a file that ends in tar.bz2 using the tar command, you’ll have noticed that it doesn’t work. That’s because the tar command does not understand the binzip codec used in these archives. Instead, we can use the bzip2 command like so: bzip2 -d yourfile.tar.bz2 The -d switch stands for “decompress”. Notice that this will extract all files and delete the original .bz2 file by default. Very convenient indeed! If you’d like to keep it, just pass the -k switch (for...

read more

How to start a Windows app with arguments from a shortcut

Posted by on 12:47 pm in Knowledge Base | Comments Off on How to start a Windows app with arguments from a shortcut

create a shortcut for your app somewhere right-click on the shortcut and head over to the Shortcut tab under Target, add your argument(s) after the closing quote hit OK, then double-click the shortcut...

read more

How to remove duplicate packages with yum

Posted by on 1:11 pm in Knowledge Base | Comments Off on How to remove duplicate packages with yum

I’m working on a handful of servers that all have the same problem: when running yum, an error message appears that tells me a package called ntpupdate needs to be upgraded, but somehow this doesn’t work and the package is being skipped. Then follows a huge list of duplicate packages that are installed on those systems (probably installed by the automatic package updater within Plesk). Let’s see how we can fix such issues. The Problem Here’s the output: yum update Loaded plugins: fastestmirror Loading mirror speeds...

read more

How to mount and unmount drives in macOS and OS X from the command line

Posted by on 10:10 pm in Knowledge Base | Comments Off on How to mount and unmount drives in macOS and OS X from the command line

Unmounting external drives on a Mac is usually done quick and simple by either dragging drive icon to the trash, or by using the eject symbol in a Finder window. Mounting usually happens automatically when a new drive is inserted into a USB port or SD card slot. However, there is a way to do this via the command line, of which I am a big fan. Fire up a Terminal session and see how to do it. Listing available drives To see what’s currently attached to your Mac, let’s use the diskutil command, followed by the word list. You’ll...

read more

Format a Linux system drive on Windows

Posted by on 10:02 pm in Knowledge Base | Comments Off on Format a Linux system drive on Windows

The other day I tried to format a USB drive for use with Windows. I had previously tried this on my Mac to no avail. But now even Windows was telling me that it too could not format my drive. I was stumped! I had in fact never seen anything like it before. Was that USB drive broken? Had I turned stupid overnight? Well perhaps… but more importantly, it dawned on me what I had used this USB drive prior to this formatting nightmare: it was a Linux installation that could run directly from the stick. This is important, because as part of...

read more