Linux environment variables

Source: Internet
Author: User
Tags gtk syslog

Linux environment variable Learning

First, set alias alias to Global Runtime environment

Terminal A operation:

[[email protected] ~]# which LS//view ls position alias ls= ' ls--color=auto '/usr/bin/ls
[[email protected] ~]# alias//view system 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 '
[[email protected] ~]# alias a= ' ls -a '   //defines ls -a alias for a  applicable to the current environment [[ email protected] ~]# a.                 .bashrc.swp  .gconfd              .local             templates:                .cache        .gnome2              .nautilus          Video \                 .config      . gtk-bookmarks      .pulse              Photo Anaconda-ks.cfg  .cshrc       .gvfs                .pulse-cookie      documentation. Bash_ history    .dbus        . iceauthority       .ssh                Download .bash_logout     .dmrc         .imsettings.log     .tcshrc             Music .bash_profile    .esd_auth     install.log         .xsession-errors   Desktop .bashrc           .gconf        install.log.syslog   Public Terminal B operation: [[Email protected] ~]# a             //cannot find the a command-bash:  A: command not found the settings for Terminal Aalias alias a only apply to terminal A's current operating environment
 Terminal a operation: define LS -A alias as a  applicable Global environment [[email protected] ~]#  vi .bashrc    //edit. bashrc file # .bashrc# user specific aliases  And functionsalias rm= ' rm -i ' alias cp= ' cp -i ' alias mv= ' mv -i ' alias a= ' Ls -a '                //add alias  a= ' Ls -a ' # source global definitionsif [ -f /etc/bashrc ];  then        . /etc/bashrcfialias s= ' Ls -alt ' press esc  :wq  Exit Save 
Open Terminal C operation: [[email protected] ~]# a        //a Command Execution .                 .bashrc.swp   .gconfd             .local              templates:                .cache        .gnome2              .nautilus          Video \                 .config      . gtk-bookmarks      .pulse              Photo ANACONDA-KS.CFG  .CSHRC   &Nbsp;   .gvfs                .pulse-cookie      Document .bash_history    .dbus         . iceauthority       .ssh                Download .bash_logout     .dmrc         .imsettings.log     .tcshrc             Music .bash_profile    .esd_auth     install.log         .xsession-errors   Desktop .bashrc           .gconf        install.log.syslog   Public Description Global Run environment setting succeeded

Second, set the file to the global operating environment (similar to the operation of cmd command in Windows)

Example: Install.log

[[email protected] ~]# echo $PATH//show current PATH environment variable/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/ Usr/sbin:/usr/bin:/root/bin
[[email protected] ~]# CP install.log/usr/bin//copy Install.log to/usr/bin folder [[email protected] ~]# chmod +x/usr/bi N/install.log//Add Install.log run permissions [[email protected] ~]# Install.log//Successful execution/usr/bin/install.log:line 1 : Install: Command not found/usr/bin/install.log:line 2:warning:: Command not found/usr/bin/install.log:line 3: Install: Command Not found/usr/bin/install.log:line 4: Install: Command not found

Third, change the file location, and set the global environment normal operation

Example: LS

Terminal A operation:

[[email protected] ~]# which ls                  //View ls file location alias ls= ' Ls --color=auto '           /usr/bin/ls                          //ls file location is/usr/ bin/[[email protected] ~]# mv /usr/bin/ls /tmp/ls   //moving LS to/tmp/[[ email protected] ~]# ls                        //can't find the command-bash: ls: command not  found[[email protected] ~]# which ls                  alias ls= ' Ls --color=auto '                                              // Unable to find ls[[email protected] ~]# path= $PATH:/tmp/        // Specify PATH variable Paths [[email protected] ~]# which ls                 alias ls= ' Ls --color=auto '          /tmp/ls                             //ls file location is/tmp/[[ email protected] ~]# ls                       //Command Execution Success     \                 install.log           public    Video    documentation    Music anaconda-ks.cfg  install.log.syslog    Templates      pictures    Downloads    desktop

Terminal B Operation:

[[email protected] ~]# LS//Cannot find Ls-bash:/usr/bin/ls: No file or directory

Indicates that the position of the above LS is changed after execution is limited to the current operating environment of terminal A

Terminal A operation:

Set LS to run as a global environment

[[Email protected] ~]# vi /etc/profile# by default, we want umask  to get set. This sets it for login shell# Current  Threshold for system reserved uid/gids is 200# you could check  uidgid reservation validity in# /usr/share/doc/setup-*/uidgid fileif [   $UID  -gt 199 ] && [  "' Id -gn '"  =  "' Id -un '"  ]; then    umask 002else    umask 022fifor i  in /etc/profile.d/*.sh ; do    if [ -r  "$i"  ];  then        if [  "${-#*i}"  !=  "$-"  ];  then            .  "$i"          else            .  "$i"  >/dev/null  2>&1        fi    fidoneunset  Iunset -f pathmungepath= $PATH:/tmp/          //Add/ tmp/Path Press esc  :wq  to exit save

Open Terminal C operation:

[[email protected] ~]# LS//execute success \ Install.log Public video document music anaconda-ks.cfg instal L.log.syslog template Picture Download desktop Description ls runs as a global environment.


This article is from the "Future Star" blog, please make sure to keep this source http://abel123.blog.51cto.com/10686821/1763537

Linux environment variables

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.