您的位置:首页 > 运维架构 > Shell

UNIX实验项目二:UNIX基础知识实践

2006-06-29 11:31 411 查看
实  验   报   告


学号

03093245

姓名

代严

课堂号

09078051-0

实验日期

2006/4/4

实验名称

实验项目二:UNIX基础知识实践

实验用时

4

一、实验目的和要求

(1)、了解UNIX环境下不同的身份及相应的权限和操作方法。

(2)、掌握UNIX常用命令的使用。
(3)、熟悉UNIX系统命令行方式和图形界面方式的使用,掌握全屏幕编辑工具vi的基本操作。理解正则表达式。

二、实验内容、实验过程

(1)、使用自己的账户登录unix系统,查看系统提示符确定使用的shell程序类型。使用cat命令查看/etc/passwd文件确定使用的shell。
第一步:使用Windows的 Telnet登陆Unix服务器,如图1所示:
运行:telnet www.cyberspace.org

用户名:daiyanxg

图1

第二步:使用“E”退出MENU菜单,进入Shell环境,如图2所示:

 

图2

第三步:由提示符“%”判断shell程序类型为c shell,下面察看文件/etc/passwd验证,结果如下:

% cat /etc/passwd | grep daiyanxg

daiyanxg:*:90630:1002:daiyan:/c/d/a/daiyanxg:/bin/csh

如图3所示:

图3

(2)、修改个人口令后重新登录。
第一步:修改口令:
% passwd

Every day the Grex staff receives several requests to reset lost passwords.
Even if you are sure you will remember your new password, please
 

                        WRITE IT DOWN!!!
 

Also, please put an alternate e-mail address somewhere in your account.  Your
.plan file is a good place for this, or, if you like, it can be a file that
only you can read.  That way, if your password needs to be reset, the staff
has a definite way to reach you.  If you lose your password and there is no
alternate e-mail address in your account, it may be impossible to restore
your account to you.
 

Tip: Want suggestions for good passwords?  Run the 'genpass' program.
 

                                                        Thanks,
                                                        The Grex staff
 

>>> Please WRITE DOWN Your New Password NOW! <<<
 

-----------
 

Changing local password for daiyanxg.
Old password:
New password:
Retype new password:
Mismatch; try again, EOF to quit.
New password:
Please don't use an all-lower case password.
Please use a different password. Unusual capitalization,
control characters, or digits are suggested.
New password:
Retype new password:
修改口令成功,过程图示省略,重新登陆过程同第一次登陆。
(3)、用who命令查阅当前登录在系统中的用户列表、用户总数、系统启动时间等信息。
% who

tysonr   ttyp0    Apr 10 10:22   (x101-244-178.ej1146.umn.edu)
erikb    ttyp1    Apr 10 10:39   (a82-93-113-143.adsl.xs4all.nl)
s2       ttyp3    Apr 10 10:22   (merlin2.provinz.bz.it)
debi     ttyp4    Apr 10 10:23   (tbgconsulting.net)
lulo     ttyp5    Apr 10 10:25   (203.177.36.83)
him2u2   ttyp6    Apr 10 10:25   (62.150.87.82)
garycy19 ttyp7    Apr 10 10:33   (217.67.141.98)
daiyanxg ttyp8    Apr 10 10:32   (61.183.248.30)
haimo025 ttyp9    Apr 10 10:45   (221.232.82.29)
him2u2   ttypb    Apr 10 10:42   (62.150.87.82)
micklpkl ttypc    Apr 10 10:40   (pound.dreamhost.com)
mdana    ttypd    Apr 10 10:41   (blueice4n1.de.ibm.com)
 

% who -q

tysonr   erikb    s2       debi     lulo     him2u2   garycy19 daiyanxg
haimo025 him2u2   micklpkl mdana    entr0py
# users=13
 

% who -H

USER     LINE     WHEN           FROM
tysonr   ttyp0    Apr 10 10:22   (x101-244-178.ej1146.umn.edu)
erikb    ttyp1    Apr 10 10:39   (a82-93-113-143.adsl.xs4all.nl)
absolut  ttyp2    Apr 10 10:48   (mail.universalensco.com)
s2       ttyp3    Apr 10 10:22   (merlin2.provinz.bz.it)
debi     ttyp4    Apr 10 10:23   (tbgconsulting.net)
lulo     ttyp5    Apr 10 10:25   (203.177.36.83)
him2u2   ttyp6    Apr 10 10:25   (62.150.87.82)
garycy19 ttyp7    Apr 10 10:33   (217.67.141.98)
daiyanxg ttyp8    Apr 10 10:32   (61.183.248.30)
haimo025 ttyp9    Apr 10 10:45   (221.232.82.29)
davem    ttypa    Apr 10 10:49   (67.40.18.249)
him2u2   ttypb    Apr 10 10:42   (62.150.87.82)
micklpkl ttypc    Apr 10 10:40   (pound.dreamhost.com)
mdana    ttypd    Apr 10 10:41   (blueice4n1.de.ibm.com)
entr0py  ttype    Apr 10 10:47   (87.219.127.104)
如图4所示:

图4
(4)、查阅当前用户的标志符及当前进程的状态。
% id

uid=90630(daiyanxg) gid=1002(people) groups=1002(people)
% id daiyanxg

uid=90630(daiyanxg) gid=1002(people) groups=1002(people)
(5)、在unix系统下查看自己的生日是星期几。

% cal 12 1985

   December 1985
Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7
 8  9 10  11 12 13 14

15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
//结果显示,我的生日是星期六,如图5所示:

图5
(6)、使用mail进行电子邮件的传递与查阅。
% mail daiyanxg

 

Subject: I am daiyanxg
How can I sent this messages?
EOT
% mail

 

Mail version 8.1.2 01/15/2001.  Type ? for help.
"/var/mail/daiyanxg": 1 message 1 new
>N  1 daiyanxg@cyberspa  Tue Apr 11 07:30   15/542   I am daiyanxg

& 1

Message 1:
From daiyanxg@cyberspace.org Tue Apr 11 07:30:16 2006
Envelope-to: daiyanxg@cyberspace.org
Delivery-date: Tue, 11 Apr 2006 07:30:16 -0400
To: daiyanxg@cyberspace.org
Subject: I am daiyanxg        //邮件标题
From: daiyan <daiyanxg@cyberspace.org>
Date: Tue, 11 Apr 2006 07:30:15 -0400
 

How can I sent this messages?  //我的邮件正文
 

& q

Held 1 message in /var/mail/daiyanxg
%

 

(8)、练习允许与拒绝其他用户向自己的终端上发送信息。
% mesg

mesg is y
% mesg n

% mesg

mesg is n      //结果达到目的
(9)、使用vi建立文件file1, 添加文本内容,保存并退出。练习vi编辑器的多种工作方式的转换及常用命令。用ls命令查阅文件file1的基本属性。设置文件的访问权限为:文件属主可读可写可执行,与文件属主同组的用户可读可写,其它用户可读可写。创建文件的硬链接文件file2,符号链接file3。查看文件file2,file3的基本信息。删除文件file1,再次查看文件file2,file3的基本信息。
% mkdir file1

% mkdir file2

mkdir: file2: File exists
% ls -l

total 8
drwxr-xr-x  2 daiyanxg  people  512 Apr 11 07:39 file1
drwxr-xr-x  4 daiyanxg  people  512 Apr 10 12:53 file2
% vi test1

aKt1: new file: line 1
This is the test1
 

est1: new file: 4 lines, 42 characters
% 0;1H
% ls -l

total 12
drwxr-xr-x  2 daiyanxg  people  512 Apr 11 07:39 file1
drwxr-xr-x  4 daiyanxg  people  512 Apr 10 12:53 file2
-rw-r--r--  1 daiyanxg  people   42 Apr 11 07:42 test1
% cat test1

a
This is the test1
~
--daiyanxg 2006/4/11
%
% pwd >test1        //输出重定向
% cat test1          //验证结果
/c/d/a/daiyanxg       //结果正确
% ls -l

total 12
drwxr-xr-x  2 daiyanxg  people  512 Apr 11 07:39 file1
drwxr-xr-x  4 daiyanxg  people  512 Apr 10 12:53 file2
-rw-r--r--  1 daiyanxg  people   16 Apr 11 07:47 test1
% ln test1 test2       //建立文件链接
% cat test2          //验证结果
/c/d/a/daiyanxg       //结果正确
% ln -f test1 test3

% cat test3

/c/d/a/daiyanxg
% rm test1

% cat test2

/c/d/a/daiyanxg
% cat test3

/c/d/a/daiyanxg
% ls –l               //查询结将用于下面操作对比验证实验结果

total 16
drwxr-xr-x  2 daiyanxg  people  512 Apr 11 07:39 file1
drwxr-xr-x  4 daiyanxg  people  512 Apr 10 12:53 file2
-rw-r--r--  2 daiyanxg  people   16 Apr 11 07:47 test2
-rw-r--r--  2 daiyanxg  people   16 Apr 11 07:47 test3
% chmod u+x test2      //改变test2访问权限
% chmod g+w test2

% chmod o+wr test2

% ls –l                 //验证结果
total 16
drwxr-xr-x  2 daiyanxg  people  512 Apr 11 07:39 file1
drwxr-xr-x  4 daiyanxg  people  512 Apr 10 12:53 file2
-rwxrwxrw-  2 daiyanxg  people   16 Apr 11 07:47 test2       //结果正确
-rwxrwxrw-  2 daiyanxg  people   16 Apr 11 07:47 test3
//由于test3是由test2的链接文件,所以test3的访问权限自动和test2一致。
%

改变test2权限过程如图6所示:


图6

说明:实验过程中部分过程没有提供屏幕拷贝图像资料。
 

三、试验结论

   本实验所有内容均正确我完成,试验结果详见上第二部分。
 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息