Category: Linux Toggle Comment Threads | Keyboard Shortcuts

Over 80% is running on some form of Linux – so does your Mac and you iPhone. Sometimes we have to get our hands dirty on the command line – it makes you feel like a proper hacker.

Here are some pointers I picked up on my journey.

  • Jay Versluis 4:35 pm on July 24, 2015 Permalink | Reply
    Tags: ,   

    Categories: Linux ( 68 )

    How to install Parallels Tools via the Command Line in CentOS 

    I like setting up barebones CentOS and other flavoured VMs on my Mac via Parallels Desktop. Trouble is, for such things like time synchronisation to work properly, something called Parallels Tools needs to be installed on each VM.

    This is to make sure Parallels Desktop can speak to the VM and communicate with it properly. It’s more important for GUIs so that the screen resolution and mouse handling is more accurate.

    Thing is, when you have a VM with a GUI, installing Parallels Tolls is extremely easy and may even happen automatically as soon as you install the OS. But if you have a command line only interface, it just doesn’t happen, and it’s up to us to install those tools manually. Here’s how to do it in CentOS.

    First, boot up your barebones VM and wait for it to start. Now head over to the VM’s menu and choose Actions – Install Parallels Tools. If they’re already installed, this message will change to “Reinstall Parallels Tools”.

    Screen_Shot_2015-07-21_at_16_39_13

    If your VM has a graphical user interface, this process will kick off the actual installation, but on barebones machines, it will merely attach the ISO image that contains the tools to your VM. In an ideal world, this tool would even mount the image for us, but sadly it doesn’t work with CentOS. Therefore we have a bit more work to do until we get to the installation part.

    You’ll see the following message to confirm the attachment:

    Screen-Shot-2015-07-21-at-16.29.35

    Now let’s login to our VM as root using our favourite SSH client (or simply use Parallels Desktop). We’ll create a directory to which we can mount the image. As suggested in the Parallels documentation, we’ll use /media/cdrom:

    mkdir /media/cdrom

    With this directory in place, let’s mount the ISO image to it so we can address it:

    mount -o exec /dev/cdrom /media/cdrom
    mount: block device /dev/sr0 is write-protected, mounting read-only

    The message is fairly self-explanatory: no writing to that ISO image. No problem! To start the installation, enter the directory and call the install script like so:

    cd /media/cdrom
    ./install

    The script will greet us with a TUI and some steps we need to complete, one of which may be that some additional components (such as make and gcc) need to be installed. That’s not always the case on barebones systems. Lucky for us, the script will take care of this for us too:

    Screen Shot 2015-07-21 at 16.33.51

    And that’s it! The script will finish fairly quickly, and at that point, Parallels Tools is installed in your VM. Congratulations! There’s only one final step: reboot the VM. You can either do that from the VM’s menu under Actions – Restart, or by issuing the following command:

    reboot now
    
    Broadcast message from root@yourserver
    (/dev/pts/0) at 16:53 ...
    
    The system is going down for reboot NOW!

    As soon as the VM is back up and running you’re all set :-)

    Screen Shot 2015-07-21 at 16.38.48

     

    Further Reading:





     
  • Jay Versluis 9:55 am on May 3, 2015 Permalink | Reply
    Tags:   

    Categories: Linux, Plesk ( 68 )

    How to update Plesk via the Command Line 

    Plesk-LogoYou can update Plesk via the Web Interface (under Tools and Settings – Updates and Upgrades). However sometimes the interface times out, or browsers get confused – therefore it’s good to know that you can apply updates via the command line interface as well. In this article I’ll show you how (in Linux – I don’t know much about running Plesk on Windows I’m afraid).

    We need to download the standard installer script for this. It’s a powerful little tool which can also be used to add or remove components from the current Plesk installation, or to install Plesk on a barebones server.

    As of 2015 the link can be found here:

    Screen Shot 2015-05-03 at 09.39.40

    If you click the option “Download Plesk installer for Linux”, you’ll see the actual script open in a new browser tab. Not what we want, although you could copy and paste this into a new file on your Linux system. Instead, right-click on the link and choose “Copy Link” instead.

    Screen Shot 2015-05-03 at 09.41.27

    With that link in your clipboard, connect to your server via SSH and download the file with something like wget:

    wget http://autoinstall.plesk.com/plesk-installer?long-url-here
    

    This will result in a file called “plesk-installer” with some nasty parameters at the end, several hundred characters in total. Let’s rename it to something easier and tweak the execution permissions:

    mv plesk-installer* plesk-installer
    chmod +x plesk-installer
    

    Now we can run the script like so:

    ./plesk-installer
    
    Welcome to the Parallels Installation and Upgrade Wizard!
    ===============================================================================
    
    This wizard will guide you through the installation or upgrade process. Before
    installing or upgrading Parallels products, be sure to back up your data.
    
    To start the installation or upgrade, press N and then press Enter.
    To quit the installer, press Q and then press Enter.
    

    Follow the instructions to upgrade Plesk. You can also call the script with several options, for a full list of those call it with “–help”. To see all available versions of Plesk during the installation, use “–all-versions”, which will eventually lead you to a screen similar to this:

    Select the desired products and their versions
    ===============================================================================
    
    The following product versions are available:
    
    1. [*] Parallels Plesk
      2. ( ) Parallels Plesk Panel 12.1.21 (testing)
      3. ( ) Parallels Plesk Panel 12.1.20 (testing)
      4. ( ) Parallels Plesk Panel 12.1.19 (testing)
      5. ( ) Parallels Plesk Panel 12.1.18 (testing)
      6. ( ) Parallels Plesk Panel 12.1.17 (testing)
      7. ( ) Parallels Plesk Panel 12.1.16 (testing)
      8. ( ) Parallels Plesk Panel 12.1.15 (testing)
      9. ( ) Parallels Plesk Panel 12.1.14 (testing)
      10. ( ) Parallels Plesk Panel 12.1.13 (testing)
      11. ( ) Parallels Plesk Panel 12.1.12 (testing)
      12. ( ) Parallels Plesk Panel 12.1.11 (testing)
      13. ( ) Parallels Plesk Panel 12.1.10 (testing)
      14. ( ) Parallels Plesk Panel 12.1.9 (testing)
      15. ( ) Parallels Plesk Panel 12.1.8 (testing)
      16. ( ) Parallels Plesk Panel 12.1.7 (testing)
      17. ( ) Parallels Plesk Panel 12.1.6 (testing)
      18. (*) Parallels Plesk 12.0.18 (Stable) (currently installed)
    
    N) Go to the next page; P) Go to the previous page; Q) Cancel installing
    To select a version, type the respective number;
    Select an action [N]: 
    

    If you call the script without any parameters, only micro updates and additional components are applied. Micro updates are usually applied automatically if this feature is enabled (it is by default).





     
  • Jay Versluis 4:05 pm on April 23, 2015 Permalink | Reply
    Tags: , ,   

    Categories: Linux, Plesk ( 68 )

    How to open SMTP port 587 to send emails in Plesk 

    Plesk-LogoBy default Plesk on Linux uses Postfix for outgoing email, and by default listens on port 25 for outgoing SMTP mail. Some service providers do not allow to send emails on that port, and tragedy occurs: clients can’t send email with their Plesk servers. Not good.

    Other SMTP ports will usually work, such as the other favourite 587 – but by default, Postfix is not listening on this port for email submissions – at least not in Plesk 12.0.8 on CentOS 7.

    Here’s how to enable port 587 for such ventures:

    Open the Postfix configuration file at /etc/postfix/master.cf and find the following line. It’s commented out. All we have to do is to remove the hash in front of it, and email can be sent via port 587:

    submission inet n       -       n       -       -       smtpd
    

    Restart Postfix for the changes to take effect. In CentOS 5 and 6:

    service postfix restart
    

    This will also work in CentOS 7, but to be more precise:

    systemctl restart postfix.service
    

    Happiness!

    Note that port 587 needs to be open in your firewall. If the Plesk Firewall Extension is enabled, it’ll take care of it for you automagically.

     





     
  • Jay Versluis 6:03 pm on April 22, 2015 Permalink | Reply
    Tags:   

    Categories: Linux, Plesk ( 68 )

    How to turn off all Plesk Health Monitor alert emails 

    Plesk-LogoI have previously described how to adjust the values that the Plesk Health Monitor uses to determine when an email should be sent out.

    There is also a way to switch these emails off entirely. Here’s how:

    To turn off the daemon that is responsible for sending these emails, issue this:

    /etc/init.d/psa-health-monitor-notificationd stop
    

    No more emails until you restart the server, when the daemon will be resumed. If you don’t want that, switch it off at boot time using

    chkconfig psa-health-monitor-notificationd off
    

    To remove the Health Monitor altogether, head over to Tools and Settings – Updates and Upgrades and uninstall the component.





     
  • Jay Versluis 10:01 am on April 13, 2015 Permalink | Reply  
    Categories: Announcements, Linux ( 7 )

    LAMP Stack for Humans – now available on Amazon 

    Lampstack-SoftcoverMy new book LAMP Stack for Humans is now available on Amazon. It this 284 page guide I’ll walk you through the process of turning an old laptop into an always-on server. You can use it to run web applications in the comfort of your own home or office – no “cloud” required.

    Together we will configure the entire server: you will learn how to install CentOS, Apache, PHP and MySQL (or MariaDB) and WordPress. I will show you how you can reach your server from other computers on the network and how to create regular backups.

    Perfect for the Linux newbie and those who want to get started with web applications without spending money “in the cloud” (in my opinion THE WORST expression for describing remote computers).

    If you’re an avid reader of this site and have always wished that some instructions would be presented in a more cohesive form rather than in snippets, then LAMP Stack for Humans is perfect for you.

     

    Grab your free sample today, or read the entire book for free via Kindle Unlimited!

     





     
  • Jay Versluis 4:27 pm on April 9, 2015 Permalink | Reply
    Tags: ,   

    Categories: Linux ( 68 )

    How to edit your network connection settings from the command line in CentOS 7 

    CentOS 7 has a very funky text-based user interface that allows editing several important network connection settings. It’s called nmtui.

    Type the command without any parameters to get started:

    nmtui

    Now use this handy interface:

    Screen Shot 2015-04-09 at 16.22.13

    Screen Shot 2015-04-09 at 16.22.59

    Screen Shot 2015-04-09 at 16.22.33

    Your system may require a full restart for all settings to take affect.





     
  • Jay Versluis 12:36 am on March 25, 2015 Permalink | Reply  
    Categories: Linux ( 68 )

    How to find the UUID of a disk drive in Linux 

    There are two ways I know of which will print the UUID of all disk drives attached to the current system:

    blkid
    
    /dev/sr0: UUID="2014-12-02-19-30-23-00" LABEL="CDROM" TYPE="iso9660" 
    /dev/sda1: UUID="ae55a647-3c57-4ab5-9651-1389703fe6fe" TYPE="ext4" 
    /dev/sda2: UUID="bMtCfO-zpDU-7U1t-DcHg-Fe9p-Cy1K-Se0e1I" TYPE="LVM2_member" 
    /dev/sdb1: UUID="0982ce66-537a-497b-baaf-99136594f3e8" TYPE="ext4" 
    /dev/mapper/VolGroup-lv_swap: UUID="8f0652a8-d79b-453f-aa2d-0ff0b5d0ae7b" TYPE="swap" 
    /dev/mapper/VolGroup-lv_root: UUID="5afc1b25-e6cd-45b2-ad20-69f0fed323b9" TYPE="ext4" 
    /dev/mapper/VolGroup-lv_home: UUID="94e15e98-1cff-49a9-b76a-a8f3a948e2ea" TYPE="ext4" 
    

    or

    ls -la /dev/disk/by-uuid
    
    total 0
    drwxr-xr-x. 2 root root 160 Mar 25 00:24 .
    drwxr-xr-x. 5 root root 100 Mar 25 00:24 ..
    lrwxrwxrwx. 1 root root  10 Mar 25 00:24 0982ce66-537a-497b-baaf-99136594f3e8 -> ../../sdb1
    lrwxrwxrwx. 1 root root   9 Mar 25 00:24 2014-12-02-19-30-23-00 -> ../../sr0
    lrwxrwxrwx. 1 root root  10 Mar 25 00:24 5afc1b25-e6cd-45b2-ad20-69f0fed323b9 -> ../../dm-1
    lrwxrwxrwx. 1 root root  10 Mar 25 00:24 8f0652a8-d79b-453f-aa2d-0ff0b5d0ae7b -> ../../dm-0
    lrwxrwxrwx. 1 root root  10 Mar 25 00:24 94e15e98-1cff-49a9-b76a-a8f3a948e2ea -> ../../dm-2
    lrwxrwxrwx. 1 root root  10 Mar 25 00:24 ae55a647-3c57-4ab5-9651-1389703fe6fe -> ../../sda1
    

    The UUID is required to permanently mount specific disk drives in /etc/fstab.





     
  • Jay Versluis 8:45 am on March 7, 2015 Permalink | Reply
    Tags: ,   

    Categories: Linux ( 68 )

    How to specify FTP credentials in command line scripts 

    It’s easy to establish an FTP connection using the ftp command from the Linux Command Line. Sadly this command does not accept login credentials as parameters – which means that if we use it in a script, our script will pause and wait for us to type those credentials in manually. Not really suitable for automated backups.

    Thanks to a clever mechanism called netrc we can create a file in the home directory of the user who runs the script and provide credentials there. Let me show you how this works.

    First we create a file called .netrc. It’s a hidden file and it needs to reside in the home directory of the user who will connect via FTP. I’m going to use root for this:

    vi ~/.netrc
    
    # machine  login  password 
    machine ftp.domain.com login yourusername password yourpassword
    

    The first line is just a comment to you can remember how to add parameters here. The second line is an example of a host you want to connect to. Add as many other servers as you like, all following the same pattern.

    Be aware that you need to connect to the server as it is specified in the .netrc file. In the above example, if you would connect to domain.com instead, you would be asked for credentials as netrc cannot find a match.

    The .netrc file needs to be readable only by this one user, otherwise connections may fail. We do this by changing the file permissions to 600:

    chmod 600 ~/.netrc
    

    That should do it! Try to connect with

    ftp ftp.domain.com
    

    and the connection will be established without the prompt for credentials.

    If netrc isn’t working for you, or you choose not to use it, note that you can also provide FTP credentials with a here script. I find that approach a bit clunky, but the following link has details on how to do that:





     
  • Jay Versluis 7:48 pm on March 5, 2015 Permalink | Reply
    Tags: , Jekyll   

    Categories: Linux ( 68 )

    Getting started with Jekyll on CentOS 7 

    jekyll-iconIt’s not quite as easy to get up and running with Jekyll as the Quick Start Guide makes it sound. But it’s not super difficult either – if explained from one human to another.

    Here’s how I got Jekyll working on a vanilla CentOS 7 instance.

    Installing some necessary packages

    Before we can install Jekyll using Rubygems, we need a few packages which aren’t with us by default. One comes from the Fedora EPEL repository, so let’s enable that first:

    yum install epel-release
    

    I love how easy this has become since CentOS 7! Next, some packages. We’ll need Ruby and the developer extensions. We also need a web server, so I’ll choose Apache – but I understand that others work just as well.

    The installation guide doesn’t mention it, but it is actually mandatory to have a JavaScript runtime present, as mentioned in this project (which I guess Jekyll relies upon): https://github.com/sstephenson/execjs. Let’s choose NodeJS as its available from EPEL.

    What this boils down to are the following packages:

    yum install ruby ruby-devel nodejs httpd
    

    Great! Now that Ruby is working, let’s install Jekyll via Rubygems:

    gem install jekyll
    

    This could take a moment, be patient. When it’s finished, let’s put Jekyll to work.

    Creating and previewing a test site

    Let’s call our new test site “test”. I’m assuming you’re in your home directory from which usually no web files shall ever be served – but thanks to Jekyll we can make that happen for local testing purposes. The following command will create a brand new site in the current directory:

    jekyll new test
    
    New jekyll site installed in /root/test.
    

    Excellent! But how do we get to see it? Well Jekyll has created a directory called “test” for us. Let’s enter it and preview the site:

    cd test
    jekyll serve
    
    Configuration file: /root/test/_config.yml
    Source: /root/test
    Destination: /root/test/_site
    Generating…
    done.
    Auto-regeneration: enabled for ‘/root/test’
    Configuration file: /root/test/_config.yml
    Server address: http://127.0.0.1:4000/
    Server running… press ctrl-c to stop.
    

    What Jekyll is trying to say is that IF we are building this on a system with a desktop environment, we could open a web browser and enter http://localhost:4000 now to preview the site. Jekyll spawns a web server on port 4000 so that we can see any changes we’ve made since last time without affecting a live site.

    Sadly this approach doesn’t work on remote servers though, at least not for me: port 4000 on a remote server simply did not respond. Regardless, on the local sever it was working just fine, and we should see a picture like this:

    Screen Shot 2015-03-05 at 19.40.06

    That’s a good start – let’s put the site live so that our web server can show it to the world!

    Building the site

    Press CTRL-C to stop the preview serving procedure and ask Jekyll to create this site in our default web directory. In CentOS that’s /var/www/html. Mine is empty so I’ll create the site there using

    jekyll build --destination /var/www/html
    
    Configuration file: /root/test/_config.yml
    Source: /root/test
    Destination: /var/www/html
    Generating…
    done.
    Auto-regeneration: disabled. Use –watch to enable.
    

    Nicely done! Now let’s surf to http://localhost (without the 4000 at the end), and the local machine should see this content served up fresh just like any other website. Remote computers should use either the IP address or a domain resolving to it (say http://12.34.56.78).

    Now that you know how it works, enjoy using Jekyll!





     
  • Jay Versluis 11:48 am on March 5, 2015 Permalink | Reply
    Tags: Android, Nook   

    Categories: Linux ( 68 )

    How to mount EXT4 partitions on Android Jelly Bean 

    Jelly-Bean-LogoI was racking my brains over how to mount an SD card formatted with anything other than FAT32 on my Android device. Jelly Bean and Kit Kat automatically mount FAT32 partitions, but they seem to ignore native Linux file systems – which Android clearly understands.

    Apparently there’s a $1.54 app on the Play Store that can auto-mount cards (called EzyMount), but there is a way to do this for free: namely the old fashioned manual way.

    All we need is root access to the device and a Terminal Emulator (available from the Play Store).

    In this example I’m using /sdcard as my mount point, but you can of course mount that card anywhere you like. On my Nook Tablet, the standard mount point for the SD card is /storage/sdcard1, but this differs from device to device of course.

    To mount the card, we’ll use the mount command:

    mount -t ext4 /dev/block/mmcblk1p1 /sdcard
    

    We need to specify the partition format with -t (for example, ext4, ext3, ext2), followed by the partition we want to mount, followed by the mount point. On my Nook Tablet for example, the SD card device itself is /dev/block/mmcblk1, and the first partition in it is mmcblk1p1.

    To figure out what a device is called can use

    ls /dev/block
    

    Run this command before and after inserting your storage device. Watch what changes: the added device will be your SD card or USB stick.

    Why do you need EXT4? Why not just use FAT32?

    I need my files to be larger than the 4GB maximum file size imposed by FAT32. I’m using Anton Skshidlevsky’s amazing Linux Deploy to install fully fledged versions of various Linux distributions on my device. These don’t replace Android, but instead run side by side with Android in a chrooted environment.

    Linux Deploy creates ISO images on the SD card which represent a full Linux installation (for example, Debian, Fedora, Ubuntu – anything that runs on your architecture). To be able to use the full size of an SD card, and to make the self-contained file system access more data, those ISO files can be as large as the SD card – even larger: Linux Deploy uses self-expanding ISO images, but you can only define partition sizes larger than 4GB if you have an EXT type file system on the card.

    In a nutshell: Bigger is better.





     
    • DJIntel 10:45 am on June 6, 2015 Permalink | Reply

      Not working :/ mount: Invalid argument :/ i try:
      mount -t ext4 /dev/block/mmcblk1p2 /data/sdext2
      mount -w -t ext4 /dev/block/mmcblk1p2 /data/sdext2
      mount -w -o remount -t ext4 /dev/block/mmcblk1p2 /data/sdext2
      it’s not working please help
      all foler and files exist

    • Tom 1:49 am on July 27, 2015 Permalink | Reply

      DJIntel… Did you ever get a solution? I have the same issue!

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel