Linux adds directories to environment variables and adds sublime to environment variables

Source: Internet
Author: User

Bo Master before this situation, is the ordinary user under the SU LS and other commands are still valid, can log into the root user after these commonly used commands have failed.

Like this
This is a simple question, but it's also tricky for those of you who don't know about the configuration of the environment variables, and I've accidentally deleted the root root directory because I'm not familiar with the environment variables. The path variable in the Bash_profile file is not the only problem that causes these commands to fail.

It is also easy to solve the problem, because Vi,vim and other commands are invalidated, so we can only use export (export is not a file
Export is an internal command of bash, interpreted by/bin/bash to execute)

export PATH=/bin:/usr/bin:$PATHvi ~/.bash_profile添加下面这一行:export PATH=/bin:/usr/bin:$PATH

The problem can be solved.

Permanently modified

Then if you want to add a new environment variable, you can add the path you need to add directly after the PATH variable. (different users, need to go to the user's home directory to modify hidden files bash_profile)
The specific commands are as follows:

cd 用户家目录vim .bash_profile

Then modify the path variable, where the modification of the file is permanently modified, because the profile is read at system startup and the export takes effect globally, so you need to restart the file to take effect.

Temporary modification
//:路径之间是以冒号分割的export PATH=XXXXXXXX:需要添加的路径

will be effective.

Add Sublime to environment variable

If: The current logged-on user is root,sublime installed in the/OPT directory

Method One:
//进入根目录cd ~vim .bash_profile//进入vim编辑文件,修改PATHPATH=/bin:/usr/bin:/opt/sublime_text:$PATH//进入底行模式,输入wq回车保存修改//重启系统

Note here that if you add a directory environment variable, you need to enter the full file name at the command line to start sublime quickly.

Method Two:

Add a soft connection to the directory that is already part of the environment variable. such as the/usr/bin directory

ln -s /opt/sublime_text/sublime_text /usr/bin/subl

You can also customize the name of a command by creating a soft-link method, both of which can be configured for quick start sublime

Configuration can be done in the terminal using the command through the sublime boot file to program ~


This is not used to the magic vim of the students, will be a lot of convenience.

Linux adds directories to environment variables and adds sublime to environment variables

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.