Tag: Linux

  • NCDU – Find what’s using all your disk space on linux based system

    NCDU – Find what’s using all your disk space on linux based system

    NCDU is a text-based user interface, it allows you to visually see how and where disk space is being used via an easy-to-use interface. Simple run the command in the current directory to see a directory tree of folders & files and their space usage.

    I use this tool mainly for analysing why a server is running out of disk space, determine the reason why and if it’s simply expanded the disk space or is there unused files / massive logs which can be purged.

    Install

    Run the required command for your linux OS version.

    sudo apt install ncdu

    sudo yum install ndcu

    How to use

    Simple navigate to a directory you want to check and run the command:

    ncdu

    If you want to scan the whole system go to the root directory:

    cd /
    ncdu

    You can also specify a directory if you don’t want to change directory:

    ncdu /home

    Windows Server / PC

    For windows-based machines I use a bit of software called TreeSize, it does the same thing as NCDU, allowing you to see how your disk space is being used on a windows based OS.

    TreeSize on windows PC showing disk space usage
    TreeSize on windows PC showing disk space usage

     

    This is provided as it and may require changes to work for your needs.

     

  • Using NANO with crontab for CentOS

    I dont like or know how to use VI correctly and by default CentOS likes to open everything in VI, I prefer nano and find when trying to edit the crontab CentOS always wants to use VI.

    Below command solves this issue and allows the use of nano for editing crontab. You will need to try either of the solutions below, I have found some servers both work, some only one or the other works.

  • Control windows docker with Windows 10 Ubuntu Linux subsystem

    Windows 10 Linux subsystems are a very powerful feature and expand the capabilities for Windows based developers greatly, without the need to use VMs or dual booting. One of these is controlling your windows based docker host via your Linux subsystem.

    Why?

    Linux command line is much more powerful that windows standard cmd line, you can combine a number of tools using piping to perform complex operations all via cli. Many of the tutorials, guides and normal operating commands used by docker and other tools are written using Linux based command line.

    1. Setup Linux Subsystem

    First you need to have your linux subsystem all setup and running. here is a guide I previous wrote to do just that.

    All commands below will be via your linux subsystem.

    Windows 10 Subsystem for Linux Ubuntu

    2. Updates and packages

    3. Add Docker’s official GPG key

    4. Add repository

    5. Install docker client

    6. Add docker host to bash profile

    This is so that you dont have to keep telling docker client how to access the docker service.

    7. Enable exposed daemon with docker

    We are almost done, now we just need to go back to our windows system and enabled exposed daemon via the docker settings.

    Right click the docker icon within your task area and choose settings.

    The general tab should have a “Expose daemon on tcp://localhost:2375 without TLS”, enable this option.

    You should now be able to control your Windows docker service via your Linux subsystem.

    Note

    There is a more secure way to establish a connect between your subsystem and docker client, have a look at the following guide.

    [Cross Post] WSL Interoperability with Docker

  • Windows 10 Subsystem for Linux Ubuntu

    I have always been more of a Windows based developer and used Linux based systems for server technologies, I have tried in the past to move to Linux but I am to fixed in my way and prefer the tools I have on windows! Is that a bad thing, I dont no? however with Windows 10 comes Subsystems which allows you to run a Linux based Ubuntu as part of a subsystem working jointly with your windows 10 operating system.

    Im not talking about a VM or dual booting, I am talking about the ability to go to windows command line and type “ubuntu” and a full fledged ubuntu system from the command line starts up and allows you to run various tools, applications and services all within Ubuntu within Windows 10!

    Microsoft site has a simple guide to follow to install the linux subsystem here.

     

    1. Enabled windows subsystems for Linux

     

    2. Install Ubuntu via Windows Store

    Open Microsoft Store and search for Ubuntu and click install
     

    3. Initialise Setup

    Open command line and type ubuntu to start the ubuntu instance, it will take you throught a initialisation stage

     

    What next? have play around with Ubuntu on windows. For development purposes I am going to be using it with Docker! allowing me to control my Windows Docker environment from the Ubuntu Linux, as it allows me to use all the Linux based command structures and pipes making the experience even smoother and more powerful.

  • Linux: Killall command

    It is your responsibility to ensure safe usage of these commands, improper usage could cause damage to services and file systems. We will not be held responsible.

    There is a number way of killing processes on a Linux based OS, killall is one of these methods. It’s always good to be ready to kill an unwanted process or a rogue process which is eating resources.

    Usage

    Kill all instances of the “httpd” process

    Kill all proccesses running under the user “postfix”

    Kill a specific process but its full path

    Command not found?

    It does not always come pre-installed, it’s simple to install.

    Ubuntu / Debian

    RHEL – Red hat / Fedora / CentOS

    This package also contains the following useful programs:

    • fuser – identifies what processes are using files.
    • killall – kills a process by its name, similar to a pkill Unices.
    • pstree – Shows currently running processes in a tree format.
    • peekfd – Peek at file descriptors of running processes.
  • What is a server

    What is a server

    A server is a computer designed for a specific task such as running a website, a server tends to be powered up more often compared to a regular computer with most servers running 24/7. Servers are a major part of our everyday live, the internet is a collection of hundreds of thousands of servers all working together performing various tasks. (more…)

  • Creating an SSH connection using password authentication

    Creating an SSH connection using password authentication

    SSH is a secure shell command line technology allowing a user to connect to a second computer and perform many tasks securely. I have written a post which is found here which tells out all about the SSH technology. In this post I am showing you how to connect to a SSH server in Windows and Linux operating systems using password authentication, if you are using public/private key authentication please read this post. I would recommend everyone to use public/private key authentication because it increases security dramatically, a SSH client can on connect to the server if they have the correct private key and a private key can be encrypted using a password increasing security even further. (more…)

  • What is SSH (secure shell)?

    What is SSH (secure shell)?

    SSH short for secure shell is a network protocol allowing communications between two computers, it is natively found on Linux based operating systems and used to remotely control computers and server via a command line interface. SSH was created to replace older insecure software such as telnet, telnet lacked encryption allowing anyone to intercept the data transfer. For example it was possible someone could steal the username and password used which would give them remote access to the system. (more…)

  • Why a VPS (virtual private server)?

    Why a VPS (virtual private server)?

    VPS are a cheap and efficient way of owning a server without having to maintain the physical hardware, infrastructure and costs involved when renting server space. You can purchase a new VPS from most providers and within 15 minutes you can be installing your software and services. A VPS is just like owning a physical server you can install and do what you want with it. (more…)

  • What is a VM (virtual machine) or VPS (virtual private server)

    What is a VM (virtual machine) or VPS (virtual private server)

    I’m going to talk about virtual machines (VM) before I go onto virtual private servers (vps), to understand what a vps is you need to understand what a vm is as they are very similar (practically the same thing). A VM is a virtualized (virtual) operating system running inside a master operating system, for example we have a physical computer running windows XP this is known as the master, we install virtualization software which allows us to create virtual computers inside the master, multiple virtual machines can be installed on a single master. (more…)