Posts tagged with "Linux"

Helpful Linux commands

So this is just going to be a bit of knowledge dump of things I’ve picked up lately / don’t want to forget.

Bang Cash !$

If you are intending on running a few commands with the last argument of the command being the same this can be really helpful. For example:

ping 127.0.0.1
netmap !$
traceroute !$

Alternatively you can also do !* to use all the arguments of the previous command.

sudo !!

This one is pretty simple sudo !! takes the last command and re-runs with sudo.

Screen

screen is a great feature that allows you to do any of the following; – Use multiple shells in a single SSH session. – Run a long running process without maintaining an active shell or worrying about network disruptions. – Disconnect and re-connect to a shell from multiple locations.

Using it is very simple, to start it you just use the command screen, from this point you are now inside of a window within screen.

Using screen requires remembering a few more commands (or noting them down in a blog post or something).

Start screen:

screen

To start a screen with a name, you can do the following screen -S 'name'

Create another window:

Ctrl-a c

Next window:

Ctrl-a n

Previous window:

Ctrl-a p

Detach window:

Ctrl-a d

This will detach your window and return you to your bash shell.

Re-attach screen:

screen -r If you have multiple screens, this will display a list of them and you will have to use the name of the screen as a third parameter to reattach to it.

Searching through previous commands

So as you may know you can use Control + R on Linux to search through previous commands you’ve entered in the terminal. You can with a few modifications of your ~/.profile or ~/.bash_profile improve what is stored in the ~/.bash_history file, making this feature even more useful for remembering previous commands.

Ignore certain commands:

HISTIGNORE="pwd:df:du:cd:ls"

Increase how many commands are stored:

HISTFILESIZE=10000 (the default on most systems is 500)

Don’t save duplicate commands:

HISTCONTROL=ignoredups


Posted on January 14, 2018

Free SSL Certificates with LetsEncrypt and Ajenti-v

This is a quick post on how to use LetsEncrypt SSL certificates on your Ajenti-v setup .

Ajenti-v will probably be supporting this natively at some point, there is an open issue on their Github here. But in the meantime you can just follow these steps to start using LetsEncrypt now.

You can click this link and head to ‘Getting Started’ or you can just run these commands to install LetsEncrypt in the folder of your choice:

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt

So now LetsEncrypt is installed, LetsEncrypt doesn’t yet support nGinx and since that’s what I’m using I’ll assume that’s what you’re using, the automatic function won’t work for us so we will have to use the ‘certonly’ option.

Run the following command and follow the steps.

service nginx stop
./letsencrypt-auto certonly

Now you should get a message like:

Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/yourdomain.com/fullchain.pem.

You can now restart nginx by running:

service nginx start

Now that we have the cert, it’s time to see how we fit this into Ajenti. Open up the websites tab of Ajenti and open whatever website you’ve decided to do this for, hit the SSL tab and you will get this window:

Ajenti Certs Window

So the first box gets filled in with what the wizard returned to us:

/etc/letsencrypt/live/yourdomain.com/fullchain.pem

The second box gets filled in with the certificates private key:

/etc/letsencrypt/live/yourdomain.com/privkey.pem

Now Ajenti knows what certificate to use, it is time to turn SSL on, lets get the Advanced configuration out of the way first:

ajenti-advanced-cert.png

The ‘Custom top level configuration’ you see will automatically redirect users accessing your website on http:// to the https:// domain.

Lastly we just need to change the website port from the default 80 to SSL’s 443:

ajenti-ssl-ports.png

Apply changes, and check to make sure your website is still redirecting.


Posted on March 21, 2016

The Perfect Web Server - Nginx, Ajenti, Ubuntu

ajenti-dashboard.png

I’ve done a lot of installing of web servers over the last while, some of which have been effortless, others a thorn in my side. I’ve decided to compile a guide for my latest server setup that I’ve fallen in love with;

First a breakdown of what we’ll be installing today;

Nginx : (pronounced Engine X) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Nginx doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly,predictable amounts of memory under load. Even if you don’t expect to handle thousands of simultaneous requests, you can still benefit from Nginx’s high-performance and small memory footprint. Nginx scales in all directions: from the smallest VPS all the way up to clusters of servers.

Ajenti : “The admin panel your servers deserve.” Easily extensible using Python. Plugin development is fast and pleasant with rich APIs. Includes lots of plugins for system and software configuration, monitoring and management.

Ajenti V : A plugin for Ajenti that makes website setup easy – including app servers, database, and routing.

Ubuntu : If you don’t know what Ubuntu is we’re in trouble.

Now I’m going to take a leap of faith and assume you can either install Ubuntu yourself or figure out how to get a server with it already. A DigitalOcean droplet works perfectly here. So lets log in as root and run all this:

#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
# Install Ajenti-v
apt-get install ajenti-v ajenti-v-nginx ajenti-v-mysql ajenti-v-php-fpm php5-mysql
# If you <3 Ruby
apt-get install ajenti-v-ruby-unicorn ajenti-v-ruby-puma
# If you need Python
apt-get install ajenti-v-python-gunicorn
# If you need nodeJS
apt-get install ajenti-v-nodejs
# If you want FTP
apt-get install ajenti-v-ftp-pureftpd
# If you want mail
apt-get install ajenti-v-mail
# If you want POP support (for gmail etc.)
apt-get install courier-pop
# Restart All Services
sudo service php5-fpm restart
sudo service nginx restart
sudo service ajenti restart

You should now be able to log in to your Ajenti control panel at https://yourserver.com:8000 with:

username: root
password: admin

Now that’s done you’ll notice if you open /etc/nginx/nginx.conf that files inside /etc/nginx/conf.d/ are loaded before any other .conf files, this is where you should put any additional configuration for Nginx. However if you are just configuring a specific domain or website you should just put the configuration in the Ajenti website configuration’s advanced section.


Posted on February 18, 2015

Being a PHP Developer in 2015

Generic coding image

This is just some thoughts on being a PHP developer in 2015.

A standard web project before used to just require you to setup a local web server, and then you’d upload to a standard web host with some worries about PHP versions perhaps but little to no thought required for the server side of things.Frameworks were a new thing, CodeIgniter was (to me at the time) the best thing to happen to PHP, introducing me to PHP MVC patterns, easily integrated vendor libraries (I never got into Zend Framework) and Twig .

Now a web project involves using programs such as Composer, Bower and Grunt just to manage project dependencies. Then you have PHP & JS frameworks like Symfony , Laravel, AngularJS that have really made life so much easier for us developers. Of course this all comes at a cost of having to put in time into learning all these new frameworks and tools, but the benefits of doing so are just amazing; development time goes way down and you create much better products. I wish I could further go into the benefits of each but they all require posts of their own to really get across their individual uses, I’ll attempt to get to that!

Working with UNIX servers is pretty standard for most web developers now, myself included. I’ve been using DigitalOcean for all my hosting, they really are a great host and I recommend them to anyone searching. Anyway a tool I found lately for server management which I guess is what has caused this post is Ajenti , before this I was using ISPConfig for the aim of being able to manage my servers easier than via ssh, however I found it’s interface pretty clunky and just overall slow, always ending up in ssh. After testing Ajenti in a fresh droplet I changed completely over to it on my other servers, so far it’s been amazing, I’m still using ssh here and there but overall Ajenti has really solved my problem so thanks guys. The install was amazingly simple too I recommend anyone looking for a GUI for their server to check it out.

So there seems to be a lot more to PHP web development now in 2015 than there was just a few years ago, though I personally feel all of it is for the better, making my life easier. It makes me wonder what it will be like in another few years though, whats next?


Posted on January 27, 2015

Saving Your Windows PC From Virus Infections with Linux

Often you get a friend or other times a client who has gotten themselves locked out of their system by a virus. I’m talking about the seriously nasty virus’s out there that will just corrupt every .dll file they can get their hands on so the minute you try to open any program, your reopening the virus.

When this is the case there isn’t much you can do in terms of anti-virus scans etc. your only option is to wipe the machine and go for a clean re-install of Windows.

But what about all my files?

Well we backup all of those files onto an external hard drive before wiping by loading up a “Live CD” of Ubuntu, simply navigating to the computers hard drive, selecting what we need and loading it onto the external hard drive.

The beauty of a “Live CD” is that the entire operating system runs of the CD (believe me you’ll hear it spinning around the place) so the virus has no chance to load since Windows never gets booted.

On top of that Linux systems are not vulnerable to Windows virus’s so you can be sure your not infecting your external hard drive as well.


Posted on October 30, 2010

Earcandy in Ubuntu Jaunty

EarCandy is a volume manager for PulseAudio that fades applications in and out based on your current activity. Meaning it can do handy things like muting your music playing when you decide to turn on a youtube video. EarCandy can sniff out applications to tell what kind of application they are

Screenshots:

earcandy.png

earcandy2.png

How to install Earcandy on Ubuntu Jaunty

You can do this by using the following command:

sudo kate /etc/apt/sources.list

Then add the following to the end of the file:

deb http://ppa.launchpad.net/earcandy-devel/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/earcandy-devel/ppa/ubuntu jaunty main
``
Then you can install earcandy by using the following command!
```bash
sudo apt-get install earcandy

Posted on September 28, 2009

Got kUbuntu 9.04 on disc!

As of 5th April 2011, ShipIt has ended. Source

Kubuntu_disc.jpg

My address has finally been sorted, there was some confusion with the post man and where I lived since moving into the newly built apartment, but today kubuntu 9.04 “Jaunty Jackalope” came through the door!

With its world-renowned Ubuntu core and the KDE 4.2 desktop, Kubuntu 9.04 gives users a well-rounded, feature-filled and elegant desktop.

Best of all these cd’s are free thanks to Shipit and ubuntu! Check it out here ! I recommend anyone that has to fix computers to get themselves one, live cd’s really can be a lifesaver!


Posted on September 25, 2009

Google Chrome on Ubuntu

If your using Ubuntu you can now start using Chrome, or Chromium at least, which is based on it. Daily builds of Chromium can be got from here.

You’ll need to add the following repositories to get Chromium:

Note: Substitute interpid with jaunty or hardy as needed!

deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu intrepid main
deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu intrepid main

Then you can then install it by opening a terminal and do the following command:

sudo apt-get install chromium-browser

Of course this is still in Pre-Alpha so make sure to keep another browser installed! ;)


Posted on September 22, 2009

The One-Page Linux Manual

This The One-Page Linux Manual has a summary of all useful commands in Linux. one-page.png


Posted on September 19, 2009

Autoinstalling .Debs on Firefox

I was trying to use a get .debs website the other day and with a lot of frustration of firefox saying Firefox does not have the correct protocol to open this file [.apt] I finally figured out that I did not have apt-url installed on kUbuntu.

This can be fixed by simply opening a terminal window and typing:

sudo apt-get install apturl

Then restart firefox. Go to download another .deb / .apt file and when it asks you what you would like to use to open the file browse to /usr/bin and pick whatever installs your programs.


Posted on September 17, 2009

Linux Comic

Saw this and got a laugh, so decided to share it, credit to original artist

mac-linux-comic.png


Posted on September 15, 2009

Ubuntu Cheat Sheets

Somehow I lost the original files of these, I’ve updated to use cheat sheets provided by Gary Woodfine.

Cheat sheets are handy, you ever get stuck you just look up at the wall where you have your cheat sheet right there providing you the answers you need! Moving to Ubuntu is a big step for alot of people, cheat sheets can make that so much easier! So in regards to that, here are two cheat sheets to make your life handier!

Download em, Print em and put em somewhere creative


Posted on September 12, 2009

MoBlock - Peerguardian for Linux

log1.png

MoBlock is now deprecated. It’s official successor is PeerGuardian Linux (pgl). It is highly recommended to use pgl instead of MoBlock. You can found out more on the official wiki of the peerguardian project.

With all the recent activity in Ireland with the MPAA you can’t be too safe anymore, you no longer know if someone from the MPAA is lurking in your computer watching everything you download and just waiting for the perfect time to send you that court summons.

Program’s can be installed to prevent people like this getting access to your computer, on Windows you have PeerGuardian, for Linux you have MoBlock. We can’t really tell how effective these peer blocking tools are but in this day and age it’s better to have some security rather than no security!

I’m going to just focus a little more on the power of MoBlock though, which is rumoured to soon be the official PeerGuardian for windows.

Installation is a breeze if your using Ubuntu Jaunty, for other .deb users read here.

First open up a terminal and edit your sources.list you can do this by typing the following:

sudo kate /etc/apt/sources.list

This opens “kate” for you using admin privilages. Add the following to the bottom of the file.

deb http://ppa.launchpad.net/jre-phoenix/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/jre-phoenix/ppa/ubuntu jaunty main

You will also have to enable the universe module, this should already be enabled just look for:

deb http://archive.ubuntu.com jaunty main universe

Next you’ll want to add the gpkg key of the program. To make it trusted, do this by typing the following into a terminal

gpg --keyserver keyserver.ubuntu.com --recv 9C0042C8
gpg --export --armor 9C0042C8 | sudo apt-key add -

Then it’s a walk in the park:

sudo aptitude update
sudo aptitude install moblock blockcontrol mobloquer

After it’s installed you will be guided through configuring moblock! Good luck! :D


Posted on August 26, 2009

Eyetoy as a Webcam on Ubuntu

EyeToy.png

People say using linux is complicated. That just isn’t true anymore. Back when I first started using Ubuntu there was not much support for using the Eyetoy as a webcam. Now however using the eyetoy as a webcam is a walk in the park!

Just open up a terminal window and copy the following into it:

sudo apt-get update
sudo apt-get install ov51x-jpeg-source module-assistant
module-assistant a-i ov51x-jpeg

And as easy as that, your webcam is working!


Posted on August 21, 2009