How To Cache GPG Passphrase In Ubuntu

I got into Debian packaging and one of the most brutal part was to type in the GPG secret key’s password every time I sign a package. I wasted a lot of time typing my long password. I searched a lot to cache my password for some time after I type it once. All of them said to edit gpg-agent.conf, but none of them worked for my fresh installation of Xubuntu 16.

[READ MORE]

Draw Animated Christmas Tree In Bash

It’s Christmas again and you’ll be receiving all kinds of greetings. How about greeting them back with a fancy way ? Show off your nerdiness with this super cool Christmas Tree in Bash. All you need is a Linux/Unix terminal with bash installed. Most systems come with bash. So, you don’t have to install anything for this ! Here’s how it looks :Christmas Tree in Bash First of all open a terminal and copy this script to your computer :

[READ MORE]

How To Install & Run Composer Binaries Globally

Take PHPUnit as an example. You can install it using Composer doing this : composer require phpunit/phpunit This will install a phpunit shortcut in vendor/bin directory. This obviously means you can run it. But, you would have to point to the exact location of the phpunit file to run : /home/username/mysite/vendor/bin/phpunit phpunit.xml But, that’s long and uncomfortable. And you would have to install PHPUnit separately for each projects. I’m gonna tell you how to install binaries globally as well as running it simply.

[READ MORE]

Resuming Download In Wget, cURL & aria2c

We all download stuffs and we want it to be perfect. No lagging, just download the fastest way, right ? I don’t download via browsers these days, because it is too slow (< 5 KB/s). Google Chrome downloads are the worst. So, I download via command line now. Not all downloading is easy. Sometimes it will break up. So, we must resume it. Only some servers allow to resume downloads.

[READ MORE]

Creating a File with Contents in Bash

It’s really easy to create a file in Bash with cat and > : cat "/home/simsu/file.txt" > "/home/simsu/file.txt" But, what if you want to add contents to file too ? In this case, we can use cat and echo. Here’s how we do it in echo : echo "My File, My Choice" > "/home/simsu/file.txt" But, there’s a problem with doing like this. Since there is an option to limit the characters of a Terminal command, adding large contents is not possible.

[READ MORE]

Check if Bash Script is ran by Root User

Root users have the privilege to do administrative stuff in Linux and if you’re creating a Bash script to install something or change something in the system, you need root. So, checking whether the script was ran by root is very important. if [ "$EUID" -ne 0 ] then echo "Please run as root" exit fi There is no else condition. You can add the code which will does stuff in root after the above.

[READ MORE]

Accessing /var/log Files in PHP

If you have tried to access a log file in /var/log using PHP in Linux, you will see the “Permission denied” error. This is because, Apache doesn’t have read permission on the log file. Let’s look at the user groups that have permission to access the log files : it’s root and the program which created the file. Suppose, let’s say the log file is “/var/log/squid/access.log”. That file’s group and owner will be “proxy” and others won’t even have the read permission on it except root ofcourse.

[READ MORE]

Install Softwares With Dependencies Without Internet

Debian Systems like Ubuntu and others’ software packages has the extension .deb. With the file, you can install softwares on your system. While you click the “Install” button on Ubuntu Software Center or on Synaptic Package Manger, what the system actually do is downloading the .deb file from the server and installing it. These .deb files are installed using the dpkg software. It’s not necessarily required for you to have internet to install softwares, but if you don’t have the dependencies of the software, internet is required for the software to download and install it.

[READ MORE]

Create a localhost Website in Ubuntu 11.04 & Up

In a post, I told how to create a localhost website using Apache server in Ubuntu. It worked on all versions up to Ubuntu’s 10.10th version. But on Ubuntu versions 11.04 and the versions released after it, there were some changes to the Apache server. So, by this post I’m going to update the way to create a localhost hosted website in Ubuntu versions 11.04 and the versions that came after 11.

[READ MORE]

Identify Remote OS By IP Address In PHP

In the recent post, I gave the default TTL value of different devices. As you can see, when you ping a host you can roughly identify the operating system the remote server’s running. I saw a question on Stack Overflow about this. Sadly it was down voted and was removed later. I tested if it is possible and I found that it is possible. In this post, I will give a function that automatically pings the remote host and find out the possible Operating Systems the remote server is running.

[READ MORE]