发表于: 2016-09-25 22:32:12
4 2676
今天完成的事情:完成了java环境变量的配置。。。。。。。
明天计划的事情:完成计划的接口,借鉴别人的思路优化代码。
遇到的问题:
下面的内容全是我犯的错误,请不要被他们迷惑,我会总结下到底是怎么回事的
http://jadeluo.iteye.com/blog/940113
http://www.linuxdiyf.com/linux/21977.html
这两个帖子看了之后我才明白我有多傻。。。。。
请不要学我
http://www.360doc.com/content/12/0418/22/3446769_204767982.shtml
这是vi下的各种操作
总结:执行vi ~/.bashrc,屏幕上回出现五颜六色的文字,
开头:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
这就证明你执行成功了,不是什么报错什么的。
然后进入vi的编辑模式,使用[i]命令进入编辑模式
在最后面加入JAVA_HOME、JRE_HOME、CLASSPATH、PATH
然后esc退出编辑模式进入命令模式,接着:wq保存并退出,
执行source ~/.bashrc作用是让刚才的更改立刻生效,
source FileName
作用:在当前bash环境下读取并执行FileName中的命令。
注:该命令通常用命令“.”来替代。
如:source .bash_rc 与 . .bash_rc 是等效的。
我百度到的(虽然我还没有用到shell scripts):source命令与shell scripts的区别是,
source在当前bash环境下执行命令,而scripts是启动一个子shell来执行命令。
这样如果把设置环境变量(或alias等等)的
命令写进scripts中,就只会影响子shell,无法改变当前的BASH,所以通过文件
(命令列)设置环境变量时,要用source 命令
以下来自百度百科
在计算机科学中,Shell俗称壳(用来区别于核),是指“提供使用者使用界面”的软件(命令解析器)。它类似于DOS下的command和后来的cmd.exe。它接收用户命令,然后调用相应的应用程序。
bash
bash 是borne again shell的缩写,它是shell的一种,Linux上默认采用的是bash
当你在命令行中敲入bash命令时,相当于进入bash环境,如果本身就是bash环境,那么就是进入一个子bash环境(相当于开了一个子进程)。
执行完添加命令保存后显示
".bashrc" 118L,3792c written
执行source ~/.bashrc
结果
-bash /usr/lib/jvm/java/lib :is a directory
-bash /usr/lib/jvm/java/jre/lib :is a directory
-bash /usr/lib/jvm/java/bin :is a directory
看着 java version "1.8.0_101"我露出了欣慰的笑容。。。。。。
谁来拯救下我的英语。。。。。。
1.
vi ~/.bashrc
可能我第一次执行时出现问题强退了,导致系统生成了一个.bashrc.swp文件,
第二次运行vi ~/.bashrc的时候出现问题,
e325 atiention
found a swap file by the name "/.bashrc.swp"
找到了两个文件,所以记得先rm .bashrc.swp
再进行操作。。。。我一开始不知道就进行了下面的操作。。。。。。
我在~后面加上自己的用户名,意思是使用vi编辑某个用户文件夹下的.bashrc文件,
然后我执行成功之后打开的是一个内容为空的文件,(为空是因为新建了一个文件吧?。)
按i进入编辑模式添加后按esc键退出编辑模式
执行:wq保存退出命令,然后重启系统执行java -version命令
然后失败。。。
再使用vi 编辑ubuntu用户下的.bashrc文件发现里面啥都没有。。。。,
难道是我没保存?
2.
vi保存文件时遇到的问题:E212: Can't open file for writing
又涉及到权限问题
3.
vi ~/.bashrc
报错。。。。
executed by bash(1) for non-login shells
原来我认为的报错其实就是原文件内容。。。。
以下是我找到的原文内容
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}
\033[01;32m
\u@\h
\033[00m
:
\033[01;34m
\w
\033[00m
\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="
\e]0;$debianchroot:+($debianchroot)\u@\h:\w\a
$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i
"$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|
sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# 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_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
评论