一、虚拟机控制


1、开启虚拟机:

[kiosk@foundation0 Desktop]$ rht-vmctl start desktop       ###开启desktop虚拟机


2、显示虚拟机:

[kiosk@foundation0 Desktop]$ rht-vmctl view  desktop       ###显示desktop


3、关闭虚拟机:

[kiosk@foundation0 Desktop]$ rht-vmctl poweroff desktop     ###关闭dekstop

Powering off desktop..


4、特殊问题:

Error: unable to view desktop - not currently running.   ###虚拟机没开启无法显示

[kiosk@foundation0 Desktop]$ rht-vmctl reset desktop     ###当虚拟机出现故障,reset表示重置

Are you sure you want to reset desktop? (y/n) y          ###询问是否重置y表示yes

Resetting desktop.                                       ##正在重置

Powering off desktop..


注意:当你不小心删除重要文件导致系统崩溃好或者出现故障时,reset重置。建议初学者用虚拟机进行练习,这样练习时要是出现什么问题不会威胁到你本身的电脑,也能随时重置虚拟机,方便你们大胆练习。


二、语言调整


在使用虚拟机时调整输入语言:

Applications    ----->system tools---->settings ----->Region & language --->language 


  三、第一单元 


1、行提示符

我们刚打开一个shell时出现的界面:

linux运维基础1_liunx


root                            ##打开shell的用户  root为管理员

@                               ##分隔符

localhost                       ##主机名称

Desktop                         ##工作目录名称

#                               ##身份提示符,#表示超级用户,$表示普通用户


注意:命令要在行提示符之后输入才能执行


2、切换用户

命令:su - username

高级用户切换到低级用户不需要密码,低级用户切换到高级或者平级用户的切换需要密码

linux运维基础1_liunx_02

第一步是从root切换到student,不需要输入密码;第二步是从student切换到root,提示需要输入密码;第三步是从root用户退出,回到上一次登陆身份student;第四步是从student用户退出,回到上一次登陆身份root. 

su - :切换到上一次登录的用户身份。

多次切换用户后记得用exit命令退出登录!


3、虚拟控制台

命令:

        Ctrl+Alt+F(1|7)            进入图形

        Ctrl+Alt+F(2~6)            进入虚拟控制台


Red hat Enterprise Linux Server 7.0 (Maipo)            ##系统版本

Kernel 3.10.0-123.el7.x86_64 on an x86_64              ##内核版本,系统位数


desktop0 login:root              ##登陆用户名称输入

Password:                        ##密码输入无回显


4、命令的执行

(1)命令必须在行提示符之后输入

(2)命令格式

[kiosk@foundation0 Desktop]$ 命令 参数 目标

linux运维基础1_liunx_03

(3)ctrl +c        ##撤销命名的执行

    [root@localhost Desktop]# aaaaa^C

(4)命令参数

-参数        ##单词缩写    -h 

--参数       ##单词的全拼    --help



5、命令的帮助

(1)查看命令的功能:  whatis 命令

[root@localhost Desktop]# whatis ls

ls                   (1)  - list directory contents

ls                   (1p)  - list directory contents

(2)查看命令的帮助:  命令 --help

linux运维基础1_liunx_04

[]              ##选择加入的内容,可加可不加

...             ##加入的内容个数任意

<>              ##内容在命令执行过程当中必须要加


    man 命令

linux运维基础1_liunx_05  q:退出帮助界面


man和--help都是查看命令帮助

.. --help查找到的比较简单实用;man查找到的比较全面;

.. --help只能用鼠标翻页;man可以用上下键或者空格键来翻页;


6、系统的使用基础方法

1)系统登陆

图形登陆方式

文本登陆方式

gnome-session-quit --force    ###注销用户 --force强制注销,不询问


2)工作界面转换

ctrl+alt+上|下


3)开始bash

1.Applications>Utilities>Terminal

2.鼠标右键----->open in terminal

3.gnome-terminal

4.ctrl+shift+n        ##在新窗口中打开shell

  ctrl+shift+t        ##同一个窗口中打开新的tab

5.退出:exit | ctrl+d



4)系统关机,重启

重启

reboot | init 6 |shutdown -r now

关机

poweroff | init 0 | shutdown -h now


5)锁屏

ctrl + alt +L        ##在rhel7.0

win键 + L            ##在rhel7.2


7、简单的系统命令

1) date  : 显示当前时间

  date [OPTION]...[+FORMAT]...: 显示

              FORMAT:格式符号

                     %D

                     %F

                     %T

  date[MMDDhhmm[[cc]YY][.ss]];设置

              MM:月份

              DD:几号

              hh:小时

              mm:分钟

              YY:两位年份

              CCYY:四位年份

              .ss:秒钟

XXXXXXX

[root@localhost Desktop]# date

Mon Sep 25 03:24:42 PDT 2017

不加参数表示显示当前系统时间。

[root@localhost Desktop]# date 11181115

Sat Nov 18 11:15:00 PST 2017

[root@localhost Desktop]# date 111811152016.55

Fri Nov 18 11:15:55 PST 2016


watch -n 1 date     ###让date命令每秒执行一次
ctrl +c 退出监控模式

-d +xday /-xday    ##查看x天前或者后的时间

[root@localhost Desktop]# date

Fri Nov 18 11:19:11 PST 2016

[root@localhost Desktop]# date -d +5days          查看五天后的时间

Wed Nov 23 11:19:13 PST 2016

+%....        ##设定date的输出格式


2)passwd

1.passwd 修改用户密码

[root@foundation0 ~]# passwd


Changing password for user root               ##改变超级用户密码

New password:                                 ##输入密码

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:                          ##确认密码

passwd: all authentication tokens updated successfully.



[kiosk@foundation0 Desktop]$ passwd

Changing password for user kiosk.        ##改变普通用户密码

Changing password for kiosk.

(current) UNIX password:                 ##输入当前密码

New password:

BAD PASSWORD: The password is the same as the old one##和原始密码不能相似

New password: 

BAD PASSWORD: The password fails the dictionary check - it is too simplistic/systematic ##密码必须是无序数字+字母

New password: 

BAD PASSWORD: The password is shorter than 8 characters##密码必须>8位


passwd参数用户名称

-Sstudent            ##用户密码信息

--status student。。。。。。

-l student            ##锁定帐号

-u student            ##解锁

-n 1student            ##设定密码最短有效期

-x 30student        ##设定密码最长有效期

-w 3student        ##警告期

-i 2student        ##设定用户非活跃天数

-dstudent        ##清除用户密码

监控passwd密码信息

watch -n 1 passwd -S student

linux运维基础1_liunx_06


3)file

file 文件名字       ##查看文件类型

linux运维基础1_liunx_07


文件的类型是由内容决定的,不是由后缀决定

linux运维基础1_liunx_08


4)文件的查看

cat filename           ##查看文件的全部内容    靠后显示

  -b  显示行数(不算空行)

  -n  显示行数(算空行)

注意:cat查看文件没反应,说明该文件为空;

less file          ##分页浏览,按“q”退出 从第一行显示文件内容 可以搜索关键字

head filename      ##显示一个文件的前几行  默认显示前十行

head -n 5 filename  ##前五行

[root@localhost Desktop]# head -5 westos

wodimama

s1

2

3

4

tail filename          ##显示文件后几行        默认显示后十行

tail -n 5 filename     ##显示一个文件的后5行

[root@localhost Desktop]# tail -5 westos

26

27

28

29

30


5)wc:统计文件容量信息    默认显示:行数 单词数 字节  


wc -l     行数

   -w     单词数

   -c     字节数

   -m     字符数


[root@localhost Desktop]# cat file

hello world!

nice to meet you!

[root@localhost Desktop]# wc westos

33 31 92 westos

[root@localhost Desktop]# wc file

 2  6 31 file

[root@localhost Desktop]# wc -l file

2 file

[root@localhost Desktop]# wc -w file

6 file

[root@localhost Desktop]# wc -c file

31 file

[root@localhost Desktop]# wc -m file

31 file


另外:一个中文占三个字符,a是一个字符数据,内存分配给字符数据默认是两个字节(B)。



8、tab键

在系统中table键可以自动补齐存在的命令,文件名称和某些命令的参数


a+TAB x2  显示系统中所有a开有的命令

[root@localhost Desktop]# cat westos

westos       westos.jpg   westos.mp3   westos.png   westos.txt~  

westos~      westos.jpg~  westos.mp3~  westos.txt  


hostory -c              ##清除当前环境当中的历史命令

!数字                  ##执行第多少行命令

!字母                  ##执行最近一条以这个字母开头的命令

ctrl +R +关键字         ##执行最近一条含有这个关键字的命令

上下键                  ##逐行调用命令

[root@localhost Desktop]# history    显示当前环境当中的历史命令

    1  history

    2  wc -l file

    3  wc -w file

    4  wc -m file

    5  history

[root@localhost Desktop]# !2      执行第2条命令

wc -l file

2 file





9、linux中的快捷键

左右                    ##一个字符一个字符移动

ctrl +左右              ##一个字一个字移动

ctrl    + a             ##光标移动到行首

        + e             ##光标移动到行尾

        + u             ##光标所在位置删除到行首

        + k             ##光标所在位置删除到行尾

        + r+关键字        ##调出最近一条含有关键字的命令

        + c             ##撤销以输入的命令

        + d             ##关闭当前环境

        + L            ##清空屏幕

        + shift + c        ##复制

        + shift + v        ##粘贴

        + shift + t     ##在现有shell中重新打开一个table        

        + shift + n    ##在shell中打开一个新的shell

        + shift + pageup|pagedown ##切换table

        + alt + l          ## 锁屏

        + alt +上|下        ##切换工作界面

        + alt + f1|f7       ##进入图形界面

        + alt + f2-f6       ##进入虚拟控制台