Skip to main content

Posts

Showing posts from February, 2018

Permanent Alias in Centos

Alias is a way to pair a command with a name of your choice. For example when you use ls , it is actually ls='ls --color=auto' it has and alias to ls and when you commit ls it executes ‘ls --color=auto’  . if you execute the command alias you will get something like this : alias cp='cp -i' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' If you want to set an alias for the current session just type # alias ll='ls -lah' If you want to remove an alias for the current session just type $unalias ll   Aliases in Centos You can add a permament alias in centos using the following simple steps: 1st step Create a file in /etc/profile.d/ directory create a file with filename relative to the command you want to make an alias (this is just a mnemonic hint) inside the directory: /etc/profile.d/ as is shown in the following ...

Setting Up ISCSI Target & Initiator

ISCSI stands for  Internet Small Computer Systems Interface, which is an IP-based storage,and works on top of internet protocol by carrying SCSI commands over IP network. iSCSI transports block-level data between an iSCSI initiator(on the Client machine) and an iSCSI target on a storage device (server). Before getting into the Configuration of an iscsi target and initiator, let’s talk a little bit about iscsi Terminology as your acquaintance with the definitions will light up the path for you to understand the subject profoundly. Iscsi Terminology iscsi Target : you already know about iscsi target , it is actually the server that share the block device and to which you log in . the disk is configured as an iscsi target through targetcli utility and becomes available to the clients. iscsi Initiator : the shared device is requested with initiator which resides on the client , the initiator itself is installed through iscsi-initiator-utils on the client machine. I...

Self-Monitoring Script with Python

Just last night, I faced a curious problem with one of my servers. It seemed to have the network interface up and running but I could not reach to the server with ssh, when I wanted to connect, the putty hanged on the username prompt , the server first closed port 80 and then the mysqld port and finally it closed ssh port that left me with no choice but to restart the server. We are not intending to address an optimization scenario, though the closure of httpd and mysqld port is related to an optimization issue which has haunted me several times.in this scenario, I am going to write and implement an internal monitoring and self-healing mechanism on my server with the help of python and crontab. Which port is closed? Netstat is the utility which comes in handy when we are to know about open/closed ports and we may pipe the output of the netstat to grep in order to filter the output, let’s see it in action # netstat -ntulp|grep ':::80' The command will look for port ...

Vim Editor

Vim is a powerful text editor used in CLI (command line interface). Linux uses a lot of configuration files, you'll often need to edit them and vim is a great tool to do so. The question that may be asked is : is there an easier way to edit text files in cli? Absolutely yes , there are many other editors like nano or joe, but the fact is that, in numerous utilities , the configuration files are merely based on vim. Some Linux Administrators prefer not to use vim because of numerous commands that are available In this short tutorial I am going to make it easy for you to work with vim. Modes in vim and how to Switch between them Vim has a particular working method, there are two main modes: the command mode and the insert mode. when you enter vim , the command mode is enabled and in order to switch to insert mode in which you can add text to your document, you have quite a few option: "i" (insert text where the cursor is) or "o" (insert text at the beginnin...