Recognition

Posts

34 Posts
  • Published Question

    How to check the remote origin URL of a local Git repository?

    Hi all, Does anyone have a command on hand which could show the remote URL of a specific local git repository? I usually use the cat command to check the content of the .git/config and look for the remote origin secti...
    Accepted Answer: Hi there, Yes, checking the .git/config file is a good way to go, but here are a couple of other commands that you could use as well: You could use the git config command to get a specific value from your Git config f...
    1 By bitmap Git Linux Basics Linux Commands
  • Published Question

    How to change the color of the output in Linux Bash?

    Hello, I am working on a Bash script and I wanted to change the color of some of the output to emphasize on some specific words. For example, I want to be able to print the text in green when the script is successful ...
    Accepted Answer: Hi there, Yes, you can do that with the ANSI escape characters. You can find a list of those characters here (https://en.wikipedia.org/wiki/ANSI_escape_code). For example, if you wanted to print green text, you could ...
    1 By bitmap Linux Basics Linux Commands Ubuntu CentOS
  • Published Question

    How to add and commit an empty directory in my Git repository?

    Hi all, I need to commit an empty directory to my Git project, but when I create a new directory with: command,bash mkdir <^>my_dir<^> And then check the status with: command,bash git status Git says that there is n...
    Accepted Answer: Hi there, Yes, indeed, by design, you can not commit empty directories, containing no files, to a Git repository. What I usually do in such cases is to create a .gitkeep or a .gitignore file inside that directory: Fir...
    1 By bitmap Git Linux Basics Linux Commands
  • Published Question

    How to Redirect to Another Website with JavaScript?

    Hello, What is the best way of redirecting a user to another website or page using pure JavaScript? Thank you!
    Accepted Answer: Hey there, One way to do that would be to use the location.href. Here's an example: javascript window.location.href = "<^>https://digitalocean.com<^>"; Here is a quick demo: Redirect user to another page using JavaSc...
    1 By bitmap JavaScript
  • Published Question

    How to delete old remote git branches via git cli or a bash script?

    Hi git gurus! I am supporting a few projects on GitHub, I'm at a point where I have hundreds of branches across all projects and deleting the branches manually is not really an option. Does anyone have a script on han...
    Accepted Answer: Hi there @bitmap, I had a similar case recently. Here are a couple of Bash scripts that might help you. Delete remote inactive git branches since a specific date The following script as it is can be used to delete old...
    2 By bitmap Git Linux Basics Linux Commands Server Optimization
  • Published Question

    Nginx not starting: Address already in use (nginx: bind to 0.0.0.0:80 failed)

    Hi all, I just installed Nginx but when I try to start it it fails with the following error: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) If I check the status I get the following output: ``...
    Accepted Answer: Hi there @bitmap, It would usually mean that you have another service running on the same port. And note that you can not have multiple services listening on the same port. The service which is already listening on po...
    1 By bitmap Nginx Linux Basics Linux Commands Ubuntu
  • Published Question

    How to Trim String in bash?

    Hi all, Is there an easy way to trim a string in bash? For example if I wanted to trim a string with JS, I could simply do string.trim();. However as far as I can see there is no such command in bash: command trim Th...
    Accepted Answer: Hello, There are multiple ways to do this depending on what exactly you would like to achieve. One of the most straight forward ways to trim a string in bash is to use the xargs command. Here's a quick example: bash e...
    1 By bitmap Linux Basics Linux Commands
  • Published Question

    How to Tweak MySQL/MariaDB Configuration for Increased Performance and Stability?

    Hi all, Do you have any suggestions on how to make sure that MySQL/MariaDB is configured properly for optimal performance and stability? Thanks!
    Accepted Answer: Hello, What you could do is use the MySQLTuner script (https://github.com/major/MySQLTuner-perl). The MySQLTuner is a script written in Perl and allows you to quickly test your MySQL configuration and it gives you sug...
    2 By bitmap MySQL MariaDB Linux Basics
  • Published Question

    What is your favorite shell and why?

    Hi all, I'm just getting started with Linux and I've been experimenting with different shells like bash, sh and fish. So far I quite like fish because it is quite friendly and interactive shell. What is your favourite...
    4 By bitmap Linux Basics Linux Commands
  • Published Question

    How to Installing Siege Stress Tester on a CentOS Server?

    Hi all, I want to do some stress testing for my application. I read this article here on the introduction to load testing: https://www.digitalocean.com/community/tutorials/an-introduction-to-load-testing But I was not...
    Accepted Answer: Hello, First, you need to get the Siege source files. Here's a link to the current siege repo: http://download.joedog.org/siege/ As an example here would go with siege-3.1.4: cd /opt wget http://download.joedog.org/s...
    1 By bitmap Linux Basics Linux Commands
  • Published Question

    How to install Drush without root access on a shared cPanel server?

    Hi, I have a shared cPanel Linux server and I don't have root access to install drush. Can you please provide me with a step by step instructions guide on how to do that? Thanks!
    Accepted Answer: Hello, In order to do that you would need SSH access. Then SSH to your server: ssh your_user@yourserver.com Then check if you have composer installed: which composer If you don't get any output install composer: ...
    1 By bitmap Linux Basics Drupal
  • Published Question

    Problem with /dev/null - Permission denied

    Hi all, I think that I've messed up the /dev/null on my droplet. When I login with my non-root user I get the following error: -bash: /dev/null: Permission denied The permissions of the file are: -rwxr-xr-x 1 root...
    Accepted Answer: Hello, The permissions do not really look correct. What you could do in this case is just recreate the /dev/null. You can do that with the following commands: Login as root to your droplet, and then run: rm /dev/null...
    1 By bitmap Linux Basics
  • Published Question

    How to free up swap if there is free RAM?

    Hi all, Does anyone know an easy way on how to free up my swap? I can see that there's enough RAM available: ``` free -m total used free shared buff/cache available Mem: 983 ...
    Accepted Answer: Hello, I would usually use the following command: swapoff -a && swapon -a & The & sign at the end would start the process in the background, then I would run the following to watch how the data is being copied from ...
    1 By bitmap Linux Basics
  • Published Question

    How to recursively copy files from one server to another via FTP from the command line?

    Hi all, I have a website hosted on another server and I want to transfer the content over to my droplet. The problem is that I only have FTP access to the old server and I don't want to download all of the files local...
    Accepted Answer: Hello, The last time I had to do that I used wget. First you need to SSH to your droplet, cd to the directory that you would like to store the files at and use wget with the following arguments: wget -mbr --user="<^>...
    1 By bitmap Linux Basics Linux Commands Ubuntu
  • Published Question

    DNS lookup for a list of domains

    Hi all, I have a list of domains (about 100 or so) in a text file called domains.txt, I want to find out the A records of all of those domains but I don't want to do it manually for each single domain. Is there a comm...
    Accepted Answer: Hello, Yes, you could use this command to do a quick DNS lookup for all of the domains in the domains.txt file: cat domains.txt |xargs -I % echo "echo % ; dig +short %" | sh Hope that this helps! Regards, Bobby
    1 By bitmap Linux Basics Linux Commands DNS
  • Published Question

    How to Automatically Generate Sitemap with Laravel?

    Hi all, I'm almost done with building a small website using Laravel. I'm now working on the SEO side of things and I want to be able to automatically generate the sitemap.xml file on let's say daily basis. Has anyone ...
    Accepted Answer: Hello, I usually use the following package for all of my sites to generate the sitemap.xml file automatically: https://github.com/spatie/laravel-sitemap The setup goes something like this: First install the package vi...
    3 By bitmap PHP Frameworks Linux Basics
  • Published Question

    How to Attach DigitalOcean Block Storage to Docker container?

    Hi all, Does anyone know if it is possible to mount a DigitalOcean block storage to a docker container and if so what is the best way to do so? Thanks!
    Accepted Answer: Hello, The last time I had to do that I used the REX-Ray storage plugin. It officially comes with DigitalOcean Block Storage support. I'll try to walk you through the whole process here: Prerequisites: You need a Digi...
    1 By bitmap Docker Block Storage Linux Basics
  • Published Question

    How do I create a simple Artisan command in Laravel?

    Hi all, I'm quite new to Laravel and so far I really like it, especially the artisan commands. Has anyone created a custom artisan command? If so can you please share the steps that I would have to take in order to do...
    Accepted Answer: Hello, Yes, artisan is great, you could use it to automate a lot of tasks. I'll try to walk you through the process of creating a simple "Hello World!" artisan command. Prerequisites: You need to have Laravel installe...
    2 By bitmap PHP Frameworks PHP
  • Published Question

    How to secure WordPress without a security plugin?

    Hi all, I have a simple site based on Wordpress with Apache webserver. I've tried using Wordfence which is a security plugin, but it slows my site quite a bit and I was wondering if any one has any basic tops on how t...
    Accepted Answer: Hello, I will try to focus purely on the Wordpress side of things, but of course, having a secure server is also extremely important. Here are some of the things that I could suggest: The basics: Always update WordPr...
    1 By bitmap LAMP Stack WordPress Apache
  • Published Question

    How do I Change the timezone on a CentOS Server?

    Hi all! I'm quite new to Linux in general so sorry for the basic question. I want to change the timezone of my CentOS server but so far I've not been able to do so. I had a look at a few tutorials but so far without a...
    Accepted Answer: Hello, Here's how to do that with just a few easy steps: Choose the zone that you would like to use at: ls -l /usr/share/zoneinfo/ Then backup your current timezone file: mv /etc/localtime /etc/localtime.bak Now c...
    1 By bitmap Linux Basics Linux Commands