菓是什么意思| 凝血功能障碍是什么病| 乐子是什么意思| 猪脆肠是什么器官| 草木灰是什么| 塑料五行属什么| 被舔下面什么感觉| 每天都做梦是什么原因| 医学ns是什么意思| 南瓜什么颜色| 梦见动物是什么意思| 两边白头发多是什么原因造成的| 如你所愿是什么意思| 肌酐测定是查什么| 化疗为什么要剃光头| 木圣念什么| 豆绿色配什么颜色好看| 生产是什么意思| 什么药可以流产| 筋皮是什么肉| 毒龙钻是什么意思| 咖啡因是什么东西| 大麦茶是什么做的| 舒张压偏高是什么原因造成的| 林俊杰什么时候出道的| 腰疼是什么原因引起的| 可乐不能和什么一起吃| 为什么医院不开金刚藤| 什么时间入伏| 2022年五行属什么| 吴亦凡为什么叫牛| 无间是什么意思| 2039年是什么年| 双子是什么意思| 唇珠是什么| 孕妇脚抽筋是什么原因| 眷顾是什么意思| 口加大是什么字| 睡不着觉挂什么科| 割包皮挂什么科| 扁平苔藓有什么症状| 尿酸过高是什么原因| 处女座后面是什么星座| 挛是什么意思| 什么叫道德绑架| 领衔是什么意思| 蓝脸的窦尔敦盗御马是什么歌| 咏柳的咏是什么意思| 什么补钾最快| 心仪的人是什么意思| 雀舌是什么茶| 仙鹤代表什么生肖| 什么叫肾阴虚| 痰湿瘀阻是什么症状| 颈椎钙化是什么意思| 十二指肠球部溃疡吃什么药| 身体发麻是什么原因| 什么叫有氧运动和无氧运动| 酸菜鱼什么鱼最好| 辅酶q10是什么东西| 立夏节吃什么| 相敬如宾是什么意思| 肿瘤病人不能吃什么| 空调用什么插座| 减肥用什么好| 痛风能喝什么饮料| 一九三九年属什么生肖| 女人吃猪肝有什么好处| 维生素b什么时候吃效果最好| 上午十点到十一点是什么时辰| 楚乔传2什么时候上映| 胃病吃什么药最好| 杏仁有什么作用和功效| mlb是什么档次| 预防脑出血吃什么药| 甲减是一种什么病| 也字五行属什么| 碱性磷酸酶偏高吃什么能降下来呢| 一叶知秋是什么生肖| 女无是什么字| 吃什么促进消化| 两个月没有来月经了是什么原因| 乳腺结节3类什么意思| 亲热是什么意思| 成王败寇什么意思| 脱轨是什么意思| angelababy英文什么意思| 指甲发黑是什么原因| 重度脂肪肝吃什么药| 右额头上有痣代表什么| 拐枣泡酒有什么功效| 霉菌性炎症用什么药效果最好| 羲什么意思| 海豹油有什么功效| gms是什么意思| 平板电脑是什么| 喝什么排湿气| 尿特别黄是什么原因| 仲夏是什么时候| 龙井茶什么季节喝最好| 双侧腋窝淋巴结可见什么意思| 日本豆腐是什么材料| 中国在什么半球| zs是什么意思| 做胃镜之前需要做什么准备| 好记性不如烂笔头是什么意思| 坯子是什么意思| 银耳汤有什么功效| cet是什么意思| 向日葵花语是什么| 锡兵是什么意思| 缓释是什么意思| 獠牙是什么意思| 土鳖吃什么| 牛仔蓝配什么颜色好看| 长沙有什么玩的| 老蒯是什么意思| 蜜饯是什么意思| 什么鸡| 武则天属什么生肖| 玉是什么结构| 什么能让男人变大变长| 喝酒脸红是什么原因| mrsa医学上是什么意思| 尿酸看什么科| 搪塞是什么意思| 为什么会上火| 男士私处用什么清洗| 什么是宫颈息肉| 什么长而什么| 甲亢平时要注意什么| 冬虫夏草是什么东西| 供奉观音菩萨有什么讲究| 牛肉和什么炒最好吃| 脚底板痛什么原因| 痔疮吃什么消炎药好得快| 以什么乱什么| 富士康是做什么的| 什么月披星| 前列腺增生吃什么药效果最好| 什么是用神| 品相是什么意思| 测尿酸挂什么科| 前庭功能减退是什么原因| c罗全名叫什么| 淋巴细胞降低说明什么| 理想血压是什么意思| 卡点是什么意思| 低钾是什么原因引起的| 生理年龄是什么意思| 胸部胀疼是什么原因| 乳腺结节摸着什么感觉| 1月21是什么星座| 什么是小男人| 振水音阳性提示什么| 差异是什么意思| 女性分泌物发黄是什么原因| 回声欠均匀是什么意思| 金贵肾气丸治什么病| 一树梨花压海棠什么意思| 手指有痣代表什么意思| nec是什么牌子| 脂蛋白a是什么| 高压高低压正常是什么原因| 怕冷的女人是什么原因| ono是什么意思| 气场强大是什么意思| 微波炉加热用什么容器| 男人到了什么年龄就性功能下降| 自律性是什么意思| 银耳汤有什么功效| mfr是什么意思| 3月17日是什么星座的| 失温是什么意思| 什么水果有助于减肥| 1973年是什么命| 花生有什么营养| 调剂生是什么意思| 肺火吃什么中成药| 包二奶是什么意思| 灯红酒绿是什么意思| 立是什么生肖| 咳嗽可以吃什么食物| 治便秘什么药最好| 总胆固醇什么意思| 人为什么会磨牙| 香椿是什么| 祠堂是什么意思| 12月20是什么星座| 什么茶属于绿茶| 吕布属什么生肖| 什么是宾格| 藤原拓海开的什么车| 木危读什么| 减肥喝什么| 连奕名为什么娶杨若兮| 什么是红斑狼疮| 脾胃寒湿吃什么中成药| 学五行属什么| 忧郁症挂什么科| 疱疹用什么药最好| 什么东西能吃不能碰| 检查血脂挂什么科| 请示是什么意思| 刺激性干咳是什么症状| 骨折喝酒有什么影响吗| 超敏c反应蛋白高说明什么| 妈妈吃什么帮宝宝排气| 双的反义词是什么| 大象什么颜色| 女人吃猪肝有什么好处| 为什么一喝牛奶就拉肚子| 同型半胱氨酸高吃什么| 职业暴露是什么意思| 12年是什么婚| 降血压吃什么| 顶到子宫是什么感觉| 减脂早餐吃什么| 制服是什么意思| 小分子肽有什么作用| 5月6号是什么星座| 十月二十九是什么星座| 个人solo什么意思| 舌苔厚腻发白是什么原因| 寒热错杂吃什么中成药| 天地银行是什么意思| 什么是扦插| 不安腿是什么症状| 舌头烧灼感是什么原因| 眉毛稀少是什么原因| 2月15日是什么星座| 五月二十六是什么星座| 李耳为什么叫老子| 更年期什么时候| 肾疼是什么症状| 莲字五行属什么| 牛皮癣是什么样的| 口臭是什么原因造成的| 企业hr是什么意思| 芋头是什么| 大水冲了龙王庙什么意思| 生精补精吃什么药最快| 孕酮低是什么意思| 6月2日什么星座| 冬至是什么时候| 为什么医院开的钙都是碳酸钙| 眼轴是什么意思| 孕晚期高血压对胎儿有什么影响| 父母都是o型血孩子是什么血型| 献血有什么要求| 墨菲定律是什么| 月经不来又没怀孕是什么原因| 备孕挂什么科| 蒟蒻是什么东西| 子宫内膜什么时候脱落| 棘手是什么意思| 颈肩综合症有什么症状| 身上起火疖子什么原因| 光子嫩肤是什么| o型血的孩子父母是什么血型| 身份证借给别人有什么危害性| 一闪一闪的星星像什么| 一毛不拔是什么生肖| as是什么| 百度

教育部:严厉打击自主招生中论文买卖和造假等

[article index] [] [@mattmight] [+mattmight] [rss]
百度 徐明介绍,截止目前,投服中心累计提起8起中小投资者诉讼维权案件,分别为匹凸匹、康达新材、安硕信息、鞍重股份、ST大控、猛犸资产基金、海利生物、和上海绿新。

Unix plays a supporting role in all of the classes I teach, but it is essential in my Scripting Language Design and Implementation course.

Unix is an operating ecosystem for executing and composing scripts.

It ranks high on my list of what every CS major should know.

Unfortunately, students no longer arrive familiar with Unix-style computing, and most are not willing to learn it on their own.

Some even see it as a baroque regression.

I wrote a brief survival guide to Unix to help students, and this post is a follow-up on taking the next steps: choosing, configuring and customizing your shell, your text editor and your environment.

Please feel free to forward this to anyone that needs a summary of the basic options and pointers to advanced ones (like programmable tab completion).

Future posts in this series will cover software development under Unix; shell scripting; choosing and customizing a window manager; and recipes and strategies for Unix system administration.

Interactive shells

Your interactive shell determines the command-line dialect you will use to interact with your machine.

There are two dominant families of interactive shells: Bourne-shell-compatible and C-shell-compatible.

By default, you've probably been provided with bash, the most popular of the Bourne-shell compatibles.

You can use echo $SHELL to figure out which shell you're using:


  $ echo $SHELL
  /bin/bash

  $ _

Tip: The default Bourne-shell-compatible prompts end with $ while the default C-shell-compatible prompts end with % or >. (zsh is an exception to this.) Root (super-user) prompts often end with # by default. Of course, this behavior is configurable.

It's a near certainty that a bash interpreter will be available on a Unix system; bash has become the JVM of the Unix world.

For interactive purposes, Bourne-shell-compatible and C-shell-compatible are roughly the same, but they differ substantially for scripting.

Many users (including myself) prefer the Bourne-shell-compatible zsh for interactive purposes.

The modern version of the C shell is tcsh.

You can change your default shell with the command chsh:


  $ chsh -s /bin/zsh 
  Password for user name:

  $ _

You can also switch to another shell by typing name-of-shell:


  $ tcsh 

  > exit
  
  $ _

Tip: Hitting control-d (which sends "end-of-file") in a shell will often terminate it as well.

Glob matching

Shells support glob matching on filenames.

A glob pattern uses the multicharacter wildcard * to match any number of characters (including no characters). For example, foo* would match foo, foobar or foobaz. but not fo

A glob pattern uses the one-character wildcard ? to match exactly one unknown character. For example, ?at would match cat and hat, but not ccat.

A glob pattern uses set pattern [characters] to match any of the specificied characters. For example, [cfh]at would match cat, fat and hat, but not mat.

Shells expand glob patterns into lists of filenames.

For example, to list all of the files in the current directory starting with f or a and ending with z, you can use [fa]*z:


  $ ls
  axb axyz fsz baz

  $ echo [fa]*z
  axyz fsz

  $ _

On most systems, the shells live in /bin. You can use ls with a glob match to see which shells are available:


  $ ls /bin/*sh
  /bin/bash /bin/csh /bin/ksh /bin/sh /bin/tcsh 
  /bin/zsh

  $ _

There are many shell-specific extensions to glob-matching.

For instance, in zsh you can qualify a glob match to restrict it. For example, the qualifier (@) would list only the symbol links in a directory:


  $ echo *
  file1 file2 link-to-file1

  $ echo *(@)
  link-to-file1

  $ _

Tab completion

Most shells support tab completion.

When you have partially typed a command, filename or shell variable, press tab to have it autocomplete the remainder.

Where there is more than one completion, the shell will list the possibilities.

In some interactive shells, like bash and zsh, tab completion behavior is programmable.

Shell scripting

Shell languages are actually full programming languages.

Shell scripts are programs written in the syntax of an interactive shell.

Shell scripts are useful for automating repetitive or complex tasks.

Common applications of shell scripts include:

  • data backup and restoration;
  • cleaning up a directory;
  • invoking a program with complex options;
  • running commands on remote systems; and
  • analyzing files.

You might also use shell scripts for one-time but complex tasks like finding and condensing all the duplicate mp3s spread across your hard drives.

For writing shell scripts, one can decide the shell on a per-script basis.

The top line of the file will contain the path to the shell, preceded by #!.

That is, you could use zsh as your interactive shell, but have shell scripts written in a mixture of tcsh and bash.

In fact, some shells, like Scheme shell are meant to be used solely as scripting shells rather than interactive shells.

To create and run a shell script:

  1. create a file with #!/path/to/shell at the top;
  2. chmod it executable, i.e, chmod u+x filename;
  3. and then run it with ./filename.

For example, the following creates and executes a simple bash shell script:


  $ cat > mycommand
  #!/bin/bash

  echo Hello world.
  control-d

  $ chmod u+x mycommand

  $ ./mycommand
  Hello world.

  $ _

Text editors

In the Unix tradition, everything is stored as text.

Manipulating text efficiently is what text editors in the Unix tradition do.

Most Unix users use either emacs (or xemacs) or vim.

Some (like myself) use both.

For new users, the editor pico is popular, since it displays its short-cut keys (like control-x for exit) at the bottom.

Unix users should master emacs, vim or both.

It will take about thirty minutes to complete the tutorial for either one.

Try each one out.

Emacs

Emacs is the kitchen-sink approach to text editors.

Emacs is really a Lisp interpreter inside of which a text editor and many other applications live.

For almost any task, there exists an emacs plug-in to do it.

Complex editing tasks in emacs are invoked through key combinations.

New users find some of these combinations complex at first. (Even exiting the program is control-x control-c.)

Emacs is heavily customizable through scripts written in emacs lisp, a dynamically scoped variant of the Lisp programming language.

The per-user configuration file for emacs is ~/.emacs.

To take the emacs tutorial, run emacs and press control-h and then hit t.

Vim

Vim (an improved version of the original vi editor) takes a different approach to editing text than most editors: typical user behavior is to toggle between an insertion mode and a command ("normal") mode.

There is also a "visual" mode, a "command-line" mode and an "ex" mode.

In insertion mode, you are directly editing text.

In command mode, every key press might perform an editing operation on the file. Complex changes take only a few keystrokes.

To switch from command mode to insertion mode, press i.

To switch from insertion mode to command mode, press escape (or control-c).

To quit without saving, hit :q! and enter.

Vim is customizable through vimscript.

The per-user configuration file for vim is ~/.vimrc.

To take the vim tutorial, run vim and then press :help tutor, or run vimtutor directly.

Dot files

Configuration files for individual users live in their home directory, and by convention, have a . in front of them.

By default, these files are not shown with commands like ls.

To see the hidden dot files in the home directory, use ls -a ~:


  $ ls -a ~
  .
  ..
  .bash_history
  .bash_profile
  .htaccess
  .emacs
  .ssh
  .vimrc
  .zprofile
  docs
  repos

  $ _

Modifying these files customizes the behavior of programs and the environment.

The site dotfiles.org is a collection of user-submitted configuration files. It's a great way to see how other people customize their Unix environment.

Customizing the shell

To customize bash, add commands to run every time you login to a bash shell in .bash_profile.

To customize zsh, the equivalent file is .zprofile.

For tcsh, it's .tcshrc.

It's common to place alias directives in these files.

An alias is an abbrevation for a command.

For instance, I have an alias set in my .zprofile for each account to which I frequently ssh:

 alias utah='ssh might@shell.cs.utah.edu'
 alias might='ssh matt@might.net'

The alias syntax is slightly different for C-shell-compatible shells:

 alias utah ssh might@shell.cs.utah.edu
 alias might ssh matt@might.net

For example, if I want to check the amount of free disk space on might.net, I can do it quickly with the command might df.

Environment variables

Much of the Unix environment is customized through environment variables. Many standard environment variables are set in the shell initialization files (.bash_profile, .zprofile, .tcshrc).

When writing shell scripts, environment variables also play the same roll as regular variables in ordinary programming languages.

To view the current values of environment variables, run the command env.

You can also access the contents of an environment variable in a shell by prefixing it with $:


  $ echo $PATH
  /usr/bin:/bin:/usr/sbin:/sbin
  
  $ _

In Bourne-compatible shells, the assignment operator = sets environment variables:


  $ foo=3

  $ echo $foo 
  3
  
  $ _

In C-shell-compatible shells, the set command sets environment variables:


  > set foo=3

  > echo $foo 
  3
  
  > _

Exported variables

When a one program invokes another program, the child program receives all of the exported environment variables of the parent.

By default, environment variables are not exported.

For example, in the following, the child bash process cannot see $foo from the parent:


  $ foo=3

  $ echo $foo
  3
  
  $ bash

  $ echo $foo

  $ exit

  $ echo $foo
  3

  $ _

To export a variable under Bourne-compatible shells, use export:


  $ export foo=3

  $ echo $foo
  3
  
  $ bash

  $ echo $foo
  3

  $ exit

  $ echo $foo
  3

  $ _

To export a variable on C-compatible shells, use setenv:


  > setenv foo 3

  > echo $foo
  3
  
  > tcsh

  > echo $foo
  3

  > exit

  > echo $foo
  3

  > _

Command path

The PATH variable is a colon-delimited list of directories to search for commands.

For instance, if PATH is /bin:/usr/bin:/sbin, then if the user types the command name, the shell will check for an executable file named /bin/name, then /usr/bin/name, then /sbin/name when completing the request.

Users often like to add custom scripts to their command path.

One way to accomplish this is to create a user-specific command directory, ~/bin, store scripts here, and then add it to the PATH variable.

Usually, the PATH variable is set and exported by the shell initialization file.

Prompts

To customize the prompt, the PS1 variable controls the look and feel under Bourne-compatible shells, while the prompt variables does the same for C-shell-compatible shells.

There are many shell-specific escapes one can add to make the prompt's behavior dynamic:

Every advanced Unix user has invested in prompt customization well past the point of diminishing returns.

It is a rite of passage.

My fancy zsh prompt looks like a smurf impaled on a Christmas tree.

It displays more information than I've ever needed or used.

But, damn, it looks cool.

Colors

Enabling color is shell- and even program-specific, but it helps a lot.

To control colors in ls set the LS_COLORS variable. You may need to then alias ls to ls --color or ls -G depending on your Unix flavor.

To enable color in grep, alias grep to grep --color, and then set GREP_COLOR.

To control colors in the prompt, there are shell-specific methods best learned by Google, trial and error.

Other common shell variables

Most shells have the following set:

variable description
DISPLAY tells X11 on which display to open windows
EDITOR default text editor; usually emacs or vim
HOME path to user's home directory; same as ~
PAGER default page-scroller to use; usually less
PWD current directory; same as output of pwd
SHELL path to the current shell
TERM current terminal type
USER account name of current user

What's next?

After settling into Unix, you ought to investigate software development under Unix; customizing a window manager for X; and the art of Unix systems administration.

Good books

Related posts


[article index] [] [@mattmight] [+mattmight] [rss]
茉莉花茶有什么功效 三十六计最后一计是什么 西门子洗衣机不脱水是什么原因 心脏病挂什么科 白血球低是什么原因
血癌是什么病 眼睛红是什么病的前兆 1908年中国发生了什么 lb是什么 壁挂式空调什么牌子好
昏睡是什么症状 免签是什么意思 超敏c反应蛋白高是什么意思 天热头疼吃什么药 私处长痘痘是什么原因
月经有血块是什么原因 负利率是什么意思 鸡胸是什么 龟头流脓吃什么药 福州立冬吃什么
办健康证需要带什么证件sscsqa.com castle是什么意思hcv9jop3ns2r.cn 肚脐眼上面是什么部位hcv9jop5ns9r.cn 丢是什么意思hcv8jop6ns4r.cn 胃胀打嗝吃什么药最好hcv9jop0ns3r.cn
什么书买不到hanqikai.com 灰指甲挂号挂什么科96micro.com 鱼香肉丝为什么叫鱼香肉丝hcv9jop4ns7r.cn 刀子嘴豆腐心是什么意思hcv7jop9ns3r.cn 疔是什么意思bysq.com
身体起水泡是什么病症hcv8jop6ns5r.cn 文爱是什么hcv9jop2ns7r.cn 医生五行属什么yanzhenzixun.com 荸荠的读音是什么hcv8jop0ns1r.cn 尿蛋白阴性是什么意思tiangongnft.com
别致是什么意思hcv9jop8ns2r.cn 九月底是什么星座hcv8jop0ns2r.cn 倩字五行属什么hcv8jop4ns7r.cn 肾结石有什么症状hcv9jop8ns2r.cn 不忘初心方得始终是什么意思hcv7jop5ns3r.cn
百度