Skip to content

Add some useful commands to your console (Ubuntu)

Kubuntu comes with Bash scripting language

This is a list that will be updated (last updated 4 Oct 2020)

If you don’t know what is Bash please read here.

At some point, when I started to learn the Web Development the most used command by myself was the apache restart command. And i discovered the bash shortcuts/aliases

Usually, the command is sudo systemctl restart apache2 or sudo service apache2 restart. It is boring to type every time this.

If you want just to reload some setting without stopping the whole apache service and all running processes use: sudo service apache2 reload

Find and Edit your .bashrc file

In Kubuntu you can find your .bashrc in your Home folder

Open the text document, go to the last row of the document (use Ctrl + End hotkey) and add the next row

alias a2restart='sudo systemctl restart apache2'

Choose your own command for the alias. I choose a2restart to simplify my life because I use often some Apache Server commands. Like a2enmod or a2ensite (to enable virtual host files/sites)

You can add as many custom aliases you want if you follow the bash syntax. Alias + Custom command + “=” + “Linux command here ”

For a lot of Linux commands you will need root permissions, so run them with “sudo”.

At the end one more important thing

After you save the file these commands are not reloaded automatically to your opened consoles. You must run this command to reread the aliases.

source ~/.bashrc

My Favorite list:

  • alias a2restart='sudo service apache2 reload'
  • To fix some permissions problem with a www subfolder I use this (Be aware of using this command over folder/project with Git – you may have problems)
    alias sitefix='sudo chown -R adk:www-data /var/www/html/testsite/; 
    sudo chmod -R 0775 /var/www/html/testsite/client-assets/;
    echo "done"'
  • to refine my debugging. more…
    alias tailAdk='tail -f /var/log/apache2/error.log | grep --line-buffered <debug string here>'

 

More tricks here

Views: 22

Leave a Reply

Your email address will not be published. Required fields are marked *