• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • How to give an alias entry in Linux

    Alias entry in Linux is something where you assign a alias or supplementary name for a particular command. This can be done to save your time. You must be wondering how so let me explain my self with some examples below:

    I have used these commands in RHEL and CentOS so I am not aware of the same in other distributions of Linux.

    For example it happens that there is some command which I use very frequently like
    # netstat -ntlp
    So every time in the above command I need to add the switch along with the command so to save my time I can make an alias entry where the next time if I want to use the same command with the same switches I will use some shortcut command.

    From the terminal
    # alias netstat='netstat -ntlp'

    So once I type this command and hit enter, next time I only need to type netstat and I would get the output for "netstat -ntlp". It is not mandatory for you to use the same command name in the alias entry as it depends on the user. In the above case I could have given "deepak" as an alias entry for "netstat -ntlp" but it would be difficult to memorize the name for the command if there are multiple such entries.

    Now, to check all the system default alias entry in your machine
    # alias
    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'
    alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

    NOTE: The method which I explained you above will be session dependent so the next time you change your session or terminal again you will have to make an entry for alias. To get rid of this hectic situation you can make your alias entry in .bash_profile located inside root
    # cd /root# vi .bash_profilealias
    netstat='netstat -ntlp'

    Now run the bash file
    # . .bash_profile

    Now every time you login to your machine the mentioned alias entry will be updated and can be used.

    To remove the alias entry of any command
    # unalias "alias name"
    # unalias netstat

    But again this command will be session dependent until and unless you make changes in .bash_profile.

    Related Articles
    How to set environment (PATH) variable permanently in Linux
    How to mount windows share on linux

    Follow the below links for more tutorials:

    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to configure Samba 4 Secondary Domain Controller
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
    15 tips to enhance security of your Linux machine
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?
    What is kernel-PAE in Linux?
    What is swappiness and how do we change its value?
    How to log iptables messages in different log file
    What are the s and k scripts in the etc rcx.d directories
    How to check all the currently running services in Linux
    How to auto start service after reboot in Linux
    What is virtual memory, paging and swap space?

    How to give an alias entry in Linux How to give an alias entry in Linux Reviewed by admin on Wednesday, September 05, 2012 Rating: 5

    No comments:

    Powered by Blogger.