Skip to main content

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 example:
vi /etc/profile.d/whoIsTheboss.sh
In this example I need to create an alias for the command whoIsTheBoss, so I name my file whoIsTheboss.sh

2nd step Define the alias in the file

Insert in the alias’s definition file something like the following:

alias whoIstheBoss="echo Mr.Hossein Davoodi"

this command is full of smugness,isn’t it? J
I am not smug , it is just for fun
J

3rd step Give the right permissions to the file

You have to run the following command, where ldapsearch.sh is an example
chmod 755 /etc/profile.d/whoIsTheboss.sh

4th step Restart your session Or Source the file you created

Now you have to either restart your session, by exiting the terminal, and open a new one, or use the following command:
source /etc/profile.d/whoIsTheboss.sh

now the bash knows about your command(alias), and whenever you type it , it will respond to you easily.you can add long commands to a file like the one I have just made and execute it in a øyneblink(Scandinavian equivalent for eye blink).

Comments

Popular posts from this blog

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 ...

Configuring Multipath on Centos7

Device Mapper Multipathing (DM-Multipath) is a native multipathing in Linux, Device Mapper Multipathing (DM-Multipath) can be used for Redundancy and to Improve the Performance. It aggregates or combines the multiple I/O paths between Servers and Storage, so it creates a single device at the OS Level. Typically, the storage area network (SAN) topology is set up in a redundant way. That means that the connection your server has to the storage will survive a failure of a controller, disk, network connection, or anything on the SAN. It also means that if you’re connecting to the SAN over multiple connections, the logical unit numbers (LUNs) on the SAN will be presented multiple times. If there are four different paths to your LUNs, on the connected node, you’ll see /dev/sda, /dev/sdb, and /dev/sdc, as well as /dev/sdd, all referring to the same device. As all of the /dev/sd devices are bound to a specific path, you shouldn’t connect to either of them. If the specific path you’re ...

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...