Linux基本命令的实验报告

  • 格式:doc
  • 大小:33.00 KB
  • 文档页数:5

实验二 Linux基本命令

1 实验目的:

掌握Linux环境下的基本操作命令。

2 实验内容:

掌握Linux的基本操作命令

3 实验步骤:

3.1 登录和退出

<1> 登录服务器系统:

注:远程用户可使用telnet或ssh

telnet 远程主机IP地址,或

ssh 用户名@ssh服务器IP地址

Red Hat Enterprise Linux Server release 5.2 (Tikanga)

Kernel 2.6.18-92.el5 on an i686

login:

<2> 在login:后输入用户帐号:如user。

Red Hat Enterprise Linux Server release 5.2 (Tikanga)

Kernel 2.6.18-92.el5 on an i686

login: ml2010

Password:

<3> 在password:后输入密码:如果登录失败,说明该帐号已为他人使用,请换帐号重来登录。

Red Hat Enterprise Linux Server release 5.2 (Tikanga)

Kernel 2.6.18-92.el5 on an i686

login: ml2010

Password:

Last login: Sat Mar 17 09:45:03 from 218.192.121.139

[ml2010@tan ~]$

<4> 登录后,输入passwd命令来修改密码。根据提示输入当前密码,再输入两次新的密码。

[ml2010@tan ~]$ passwd

Changing password for user ml2010.

Changing password for ml2010

(current) UNIX password:

New UNIX password:

Retype new UNIX password: passwd: all authentication tokens updated successfully.

[ml2010@tan ~]$

<5> 输入logout命令退出系统。

失去了跟主机的连接。

C:\Documents and Settings\Administrator>

3.2 获取帮助信息

命令man提供了系统操作命令的在线帮助。例如,输入man passwd 可以获取命令passwd的帮助说明。按空格键,翻页浏览。按<:>,再按q退出帮助。

PASSWD(1) User utilities PASSWD(1)

NAME

passwd - update a user's authentication tokens(s)

SYNOPSIS

passwd [-k] [-l] [-u [-f]] [-d] [-n mindays] [-x maxdays] [-w warndays]

[-i inactivedays] [-S] [--stdin] [username]

DESCRIPTION

Passwd is used to update a user's authentication token(s).

Passwd is configured to work through the Linux-PAM API. Essentially,

it initializes itself as a "passwd" service with Linux-PAM and utilizes

configured password modules to authenticate and then update a user's

password.

A simple entry in the Linux-PAM configuration file for this service

would be:

……

3.3 基本操作命令

〈1〉 运行pwd命令,确定你当前的工作目录。

Red Hat Linux Aug 23 2004 PASSWD(1)

[ml2010@tan ~]$ pwd

/home/ml2010

[ml2010@tan ~]$

〈2〉 利用以下命令显示当前工作目录的内容:

<3> 运行ls –l /bin命令显示目录的内容。

[ml2010@tan ~]$ ls -l /bin

total 7640

-rwxr-xr-x 1 root root 6268 Jan 28 2008 alsacard

-rwxr-xr-x 1 root root 18772 Jan 28 2008 alsaunmute

(中间省略部分内容……)

-rwxr-xr-x 3 root root 62104 Jan 15 2008 zcat

-rwxr-xr-x 1 root root 514672 Sep 12 2006 zsh

[ml2010@tan ~]$

<4> 利用ls –l /bin |more命令行分屏显示/bin目录的内容。

[ml2010@tan ~]$ ls -l /bin |more

total 7640

-rwxr-xr-x 1 root root 6268 Jan 28 2008 alsacard

-rwxr-xr-x 1 root root 18772 Jan 28 2008 alsaunmute

(中间省略部分内容……)

-rwxr-xr-x 3 root root 62104 Jan 15 2008 zcat

-rwxr-xr-x 1 root root 514672 Sep 12 2006 zsh

[ml2010@tan ~]$

〈5〉 使用mkdir命令建立一个子目录subdir

[ml2010@tan ~]$ mkdir subdir

[ml2010@tan ~]$

〈6〉 使用cd subdir命令,进入子目录subdir

[ml2010@tan ~]$ mkdir subdir

[ml2010@tan ~]$ cd subdir

[ml2010@tan subdir]$

〈7〉 将工作目录改到你的子目录subdir,然后运行命令:

date > file1

将当前日期和时间存放到新建文件file1中。

[ml2010@tan subdir]$ date

Sat Mar 17 21:24:59 CST 2012

[ml2010@tan subdir]$ date >file1

[ml2010@tan subdir]$

〈8〉 使用cat或more命令查看file1文件的内容。

[ml2010@tan subdir]$ cat file1

Sat Mar 17 21:25:14 CST 2012

[ml2010@tan subdir]$

〈9〉 将date命令的用法附加到文件file1的后面: man date >> file1

[ml2010@tan subdir]$ man date >>file1

[ml2010@tan subdir]$

〈10〉 利用more命令显示文件file1的内容。

[ml2010@tan subdir]$ more file1

Sat Mar 17 21:25:14 CST 2012

DATE(1) User Commands DATE(1)

NAME

date - print or set the system date and time

(中间省略部分内容……)

date 5.97 May 2006 DATE(1)

[ml2010@tan subdir]$

〈11〉 利用ls -l file1命令列出文件file1的较详细的信息。

[ml2010@tan subdir]$ ls -l file1

-rw-rw-r-- 1 ml2010 ml2010 5690 Mar 17 21:28 file1

[ml2010@tan subdir]$

〈12〉 利用cp file1 fa命令生成文件file1的副本。然后利用ls -l命令查看工作目录的内容。

[ml2010@tan subdir]$ cp file1 fa

[ml2010@tan subdir]$ ls -l

total 24

-rw-rw-r-- 1 ml2010 ml2010 5690 Mar 17 21:32 fa

-rw-rw-r-- 1 ml2010 ml2010 5690 Mar 17 21:28 file1

[ml2010@tan subdir]$

〈13〉 利用rm fa命令将文件fa删除。再利用ls -l命令查看工作目录内容。

[ml2010@tan subdir]$ rm fa

[ml2010@tan subdir]$ ls -l

total 12