Posts marked with "BASH" in tags

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]

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]

Variables in Bash ": command not found"

Bash is like the very complicated language, even a space can make a syntax error. But, when you get into it often, you will get a hang of it and it will be easy. This post is a solution to one of the most common problems that happen to a newbie in Bash and it’s about a single whitespace. Here is a sample Bash file : a = 50 echo $a and when you execute it, the error will be as follows :... [READ MORE]

Append Contents to Files in Bash

In Bash, we can add contents to file easily using the > character. Like this : echo "myContents" > ~/myfile.txt What if you want to append contents to the file without overwriting ? The easiest way to do this is change the “>” to “»”. Just by making this small change, appending will be done : echo "myContents" >> ~/myfile.txt Even if the file doesn’t exist, Bash will create one with the contents given to append.... [READ MORE]

if, else, elif Conditions in Bash

All programming languages have the if & else conditions and they’re different in syntax according to each programming languages. In Bash, it’s really different and even a small space can cause syntax errors. So, you have to be careful while writing Bash code. In this post, I’ll give you many examples on how to use if and else conditions in Bash. if, else a="AC" if [ $a = "AC" ]; then echo "... [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]

Revert back to normal resolution after running a fullscreen app in Wine

While running a fullscreen app in Wine such as games, you might not get the screen resolution back after you close the app. It’s because Linux won’t automatically change it’s resolution like Windows. But you could if you run a simple file in terminal. Here is how you could do it. Create a file named normal.sh in your Desktop with the following contents: #!/bin/bash xrandr -s 0 Save it on a place where you can open it easily.... [READ MORE]

Follow/Subscribe

Telegram 

Mastodon  Twitter

GitHub GitLab

Subdomains

Demos  Lab

Past

This blog was once on WordPress. Now a static site. See source code on

GitLab