Add and manage custom commands in linux

Source: Internet
Author: User
Linux add and manage custom commands Method 1: Simple commands use alias to start alias www.2cto.com to edit the shell configuration file used, such as bash. bashrc, zsh. zshrc, such as adding: aliasws & quot; cd ~ /Workspace & quot; reload the configuration file to make...
Linux add and manage custom commands Method 1: Simple commands use alias to start alias www.2cto.com to edit the shell configuration file used, such as bash. bashrc, zsh. zshrc, for example, alias ws = "cd ~ /Workspace "reload the configuration file to make the change take effect, such as source. bashrc. Enter ws at any location to cd to the workspace directory. If www.2cto.com has many alias commands, you can define a separate file storage. For more information, see. description in bashrc: # Alias definitions. # You may want to put all your additions into a separate file like #~ /. Bash_aliases, instead of adding them here directly. # See/usr/share/doc/bash-doc/examples in the bash-doc package. if [-f ~ /. Bash_aliases]; then .~ /. Bash_aliasesfi if multiple shells exist, this method is more convenient to manage. you only need to add this file to various shell configuration files. Method 2: Add the executable file directory to PATH1 and create a directory for storing custom commands, such as my_cmd 2. add the directory to the path to edit the shell configuration file, such as bash. bashrc, zsh. zshrc, add PATH = $ PATH :~ /My_cmd can also add the command to a custom command created separately in method 1 to store the file. 3. reload the configuration file to make the change take effect, such as source. bashrc 4. put the custom executable program into my_cmd, and then execute the executable program in shell ~ Mkdir ~ /My_cmd restart ~ Vi. bashrc restart ~ Source. bashrc restart ~ Region ~ Vi. zshrc restart ~ Source. zshrc restart ~ Method 3: Use the preceding methods to manage custom commands. 1. edit the shell configuration files used, such as bash. bashrc and zsh. zshrc. Add: if [-f ~ /Shellrc]; then .~ /Shellrcfi2. create shellrc and add modifications to the shell configuration file, for example, PATH = $ PATH :~ /My_cmd alias ws = "cd ~ /Workspace "simple commands such as alias are put into shellrc. Put the executable file in my_cmd. Source: http://www.cnblogs.com/congbo/archive/2012/11/04/2753416.html
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.