Recognition

Posts

38 Posts
  • Published Question

    How to remove/delete an exported environment variable?

    Hi all, I was working with a remote API and I exported my API key so that I could have it available as an environment variable for my current shell session, as follows: bash,command export API_KEY=<^>MY_API_KEY_HERE<^...
    Accepted Answer: Hello, What I usually do is to use the unset command. All that you need to do is to run the following: command,shell unset API_KEY If you are writing a script, for example, to check if this is working you could have ...
    1 By bitmap Linux Basics Linux Commands Ubuntu CentOS
  • Published Question

    How to find where Docker images are stored on the host server?

    Hello, My server is running low on disk space and I think it is it is because of some Docker images. How can I find the directory where the Docker images are stored at on the host/server itself? Thanks!
    Accepted Answer: Hi there, By default they will be stored in the /var/lib/docker/<^>driver_name<^> directory. The <^>driver_name<^> directory would depend on the driver that you are using. What I usually would do is to always use the ...
    1 By bitmap Docker Linux Basics Linux Commands Container
  • Published Question

    How to convert a string to lower case or upper case in Bash?

    Hi all, I am writing a script that would take some user input but I want to make sure that the string provided by the user is consistent. Is there a way to transform a string in bash to all lower case or all upper cas...
    Accepted Answer: Hi there, There are multiple ways of doing it, but what I personally use is the following syntax: Transform all letters to lower case: bash echo "${user_input_variable,,}" Transform only the first letters to lower ca...
    1 By bitmap Linux Basics Linux Commands Ubuntu
  • Published Question

    How to Enable kubectl Autocompletion in Bash?

    Hi all, I am just getting started with Kubernetes and the kubectl command specifically. As there are so many flags and arguments, is there a way to enable autocompletion just like in git? So for example when I type ku...
    Accepted Answer: Hi there, Yes, this is doable. What you would need to do is to first to make sure that you have the bash-completion package installed. If not, you could install it with the following command: sudo apt-get install -y ...
    1 By bitmap Kubernetes Linux Basics Linux Commands
  • 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...
    Accepted Answer: Hello, It really depends on your needs and what you've gotten used to. My personal favorite is bash. I love the syntax, the autocompletion and it is installed by default on almost all servers that I have to work with...
    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