Create Your Own Bash Command

You may want to have a quick command for personal use, on your Linux machine. Say you want a quick custom converter between currencies, or a quick calculation of time, or anything that you do regularly in your head that you would love to have a terminal command for.

The steps to create a command are simple:

  1. In any folder of your own, create a file with the name of the command.

    cd myfolder
    touch mycommand

  2. Open the file with any text editor and write a simple script that does what you need and outputs your result.

    For example, a simple multiplier for quick conversions:

    #!/bin/bash

    if [ $# -eq 0 ]
    then
    echo “No arguments supplied”
    exit
    fi

    rate=60
    converted=$(($1*rate))
    echo
    echo $1 hours = $converted minutes
    echo

  3. Copy the finished script to your local bin (which is usually part of your PATH already).

    sudo cp mycommand /usr/local/bin/

 

Now you can execute your command just by opening terminal and typing the command name along with the arguments.
eg. mycommand 10

Advertisements

Running DiskSim 4.0 On 64-Bit Ubuntu

DiskSim is a disk simulation software used for I/O analysis research. It is used as a research tool instead of a commercial tool, and hence requires some tweaking to run on your system.

This is a guide to installing and running DiskSim 4.0 on 64-bit Ubuntu machines. 64-bit machines require a patch, as DiskSim is originally intended for 32-bit machines. Also, some changes need to be made to certain Makefiles. Without making the changes, the compilation of the DiskSim code fails.

Firstly, download the 64-bit patched code for DiskSim 4.0 as a zip file from the following GitHub repository: DiskSim 4.0

Unzip the contents into any directory. For convenience, use the user home folder (as has been done in the following example for the rest of this post).

Now, cd into the directory disksim-4-0-x64-master from the terminal. When you run ls, you should see a list of folders such as diskmodel, doc, etc.

The libddbg, libparam, and diskmodel directories require no changes to be compiled correctly. However, memsmodel and src directories will require a few modifications to work correctly. So, run the following commands in sequence:

Continue reading

Recompiling Your Linux Kernel

This is a brief guide on how to recompile your Linux kernel, based on Ubuntu.

Please note, this post only deals with recompiling your kernel (especially for first-timers) with no configuration changes and no upgrades to a different version. This is not aimed at more advanced users, rather, this is only a guide for people who are planning to give their first shot at recompiling the kernel.

To get the current kernel version on your Ubuntu, type the command:

uname -r

Recompiling the kernel will require some features to be installed (if you don’t have them already), so run:

sudo apt-get install build-essential

For making configuration changes with menuconfig, Ncurses needs to be installed, but it is not required in this particular guide.

Now, login as root user by typing:

sudo su (for Ubuntu)

The following commands for recompilation must be executed as root.

Change your current working directory to /usr/src:

cd /usr/src

Before proceeding, see the list of folders that are already there in /usr/src by running ls. This is because later, a new folder will get added to this directory, and you must be able to identify it.

Continue reading