CentOS实践(2)登录系统

发布 : 2018-04-25 分类 : Notes 浏览 :

1. 终端模式登录

通常我们安装Linux系统时不会安装对应的图形界面,所以系统会默认启动终端模式(又称为命令行模式或字符模式)。
此时我们会在屏幕上看见如下内容:

1
2
3
4
CentOS Linux 7 (Core) 
Kernel 3.10.0-229.el7.x86_64 on an x86_64

localhost login:

  • 第一行是发行版的名称(CentOS)和版本号(7)
  • 第二行是内核版本(3.10.0-229.el7),以及当前运行的硬件平台(x86_64)
  • 第三行是主机名(localhost)

login: 后面等待输入用户账号,这里我们输入管理员账号 root,并回车。接着会提示我们输入密码(输入密码时是看不见密码字符的),并回车。

如果密码输入错误,则提示

1
Login incorrect

登录成功则提示

1
2
Last login: Wed Apr 25 13:40:41 2018 from 192.168.27.1
[root@localhost ~]#

  • 第一行显示用户上次登录的时间和信息
  • 第二行显示登录成功后用户和主机名以及当前所在的目录
  • root 是当前登录的用户
  • localhost 是主机名
  • ~ 是用户home目录的简写
  • # 是一个提示符,说明目前的用户是有超级权限的root用户,而一般用户的提示符是 $

2. Linux 命令

在使用Linux系统时,大多使用命令行模式来进行管理。
注意:Linux下的命令是严格区分大小写

2.1 date 显示日期

1
2
[root@localhost ~]# date
2018年 04月 25日 星期三 13:46:45 CST

在命令后面可以加上一些参数来调整命令显示内容,如下:

1
2
[root@localhost ~]# date +%Y-%m-%d
2018-04-25

命令和参数之间需要使用一个或者多个空格隔开

2.2 ls 列出目录内容

1
2
[root@localhost ~]# ls
anaconda-ks.cfg

可以看到当前我们的home目录下只有一个内容 anaconda-ks.cfg
加上 -l 参数,详细显示当前目录下的所有文件:

1
2
3
[root@localhost ~]# ls -l
总用量 4
-rw-------. 1 root root 944 4月 25 13:38 anaconda-ks.cfg

2.3 cat 显示文件内容

现在我们希望查看 anaconda-ks.cfg 中的内容,使用 cat 命令:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@localhost ~]# cat anaconda-ks.cfg 
#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512

# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
... 省略更多内容...

2.4 man page 查看帮助

Linux下有太多的命令,每个命令的参数不同。有时我们不知道某个命令的使用方法,便可以查看该命令对应的说明文档(即man文件)。
比如查看命令 ls 的使用方法,输入 man ls命令,则会显示说明内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
LS(1)                  User Commands                LS(1)

NAME
ls - list directory contents

SYNOPSIS
ls [OPTION]... [FILE]...

DESCRIPTION
List information about the FILEs (the current directory by default). Sort
entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.

-a, --all
do not ignore entries starting with .

-A, --almost-all
do not list implied . and ..

--author
with -l, print the author of each file

-b, --escape

在查看man文件的时候,通过键盘 上下方向键,可以翻阅内容,也可以按 空格键 翻页。输入 /time ,按回车键,就可以搜索关键字 time。再按小写字母 n 向下查找,按大写的 N 向上查找,按小写字母 q 结束查看man文件。

本文作者 : 王海
原文链接 : https://blog.whai.me/2018/04/25/centos-2-login/
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
留下足迹