当前位置:
  1. 魔豆IT网
  2. 系统教程
  3. Un
  4. 正文

我列出了几项基本指令。大部分的指令都有若干选项,这些选项使得这些指令功能更加强大。你可以在Unix在线指南中找到具体的用法。

ls -列出某个子目录中的文件。

语法: ls [选项] [名称]

显示结果应该如同下面的例子:

sutro.hotwired.com[~]% ls

airwolf.au goo.html unixclass

apanel.parameters graphics

在这个例子中,我的用户子目录中有两个文件(airwolf.au和goo.html)和3个下级子目录 (unixclass, apanel.parameters, and graphics) 。

cd - 改变子目录

语法:cd [dir]

例:

sutro.hotwired.com[~]% cd unixclass

sutro.hotwired.com[~/unixclass]% ls

one one.html two two.html

sutro.hotwired.com[~/unixclass]%

在本例中,我从用户子目录改变到unixclass 子目录,在该子目录中有两个文件和一个下级子目录(如果你想返回原来的子目录,则使用% cd ../).

mv - 移动或重命名一个文件或子目录

语法:mv [选项] 源文件/子目录 目标

sutro.hotwired.com[~/unixclass]% mv one/ two/

sutro.hotwired.com[~/unixclass]% ls

one.html two two.html

sutro.hotwired.com[~/unixclass]% ls two/

one

sutro.hotwired.com[~/unixclass]%

我将子目录one移到了子目录two。

如果你用mv重命名一个文件或子目录,则:

sutro.hotwired.com[~/unixclass]% mv two/ somethingdifferent

sutro.hotwired.com[~/unixclass]% ls

one.html somethingdifferent two.html

在本例中我将子目录two重命名为somethingdifferent。

rm - 删除一个文件

语法:rm [选项] [文件]

例:

sutro.hotwired.com[~/unixclass]% rm one.html

sutro.hotwired.com[~/unixclass]% ls

somethingdifferent two.html

我删除了子目录unixclass下的文件。

rm -ir - 删除一个子目录

例:

sutro.hotwired.com[~/unixclass]% rm -ir somethingdifferent/

Directory somethingdifferent/. Remove ? (yes/no)[no] : yes

Directory somethingdifferent//one. Remove ? (yes/no)[no] : yes

sutro.hotwired.com[~/unixclass]% ls

two.html

在本例中,我用rm -ir 指令删除子目录 somethingdifferent。在删除该子目录之前,我必须确认我要删除该子目录。一旦我确认删除之后,子目录 somethingdifferent将不复存在。所以使用 rm时一定要谨慎,因为,一旦执行该命令,该文件或子目录将----覆水难收 ...

mkdir - 建立新子目录

语法:mkdir [选项] 新子目录名

例:

sutro.hotwired.com[~/unixclass]% mkdir waga

sutro.hotwired.com[~/unixclass]% ls

two.html waga

我用mkdir建立了新子目录waga。

more - 分屏过滤或者叫分屏显示(more)一个文件,当你只是想阅读一个文件而不编辑它时。

less - less的功能和more类似,但它还允许你在一个文件内执行查询功能。

exit - 从登录的主机退出

date - 显示当前日期和时间cal 1997 - prints the 1997 calendar

whoami - 显示当前登录到你的终端的用户

mail - 调出一个简单的邮件编辑器

pwd - 告诉你当前你所在的位置,它显示当前子目录的完整路径名。

Unix在线指南

如果你项了解各个指令的细节,你可以查询Unix的在线指南man。例如如果你想了解ls,键入

sutro.hotwired.com[~/unixclass]% man ls

你就会看到:

ls(1)

NAME

ls - list contents of directory

SYNOPSIS

ls [-RadLCxmlnogrtucpFbqisf1AM] [names]

DESCRIPTION

For each directory argument, ls lists the contents of the directory; for

each file argument, ls repeats its name and any other information

requested. The output is sorted alphabetically by default.

返回

相关阅读

  • 暂无推荐

《》由网友“”推荐。

转载请注明: