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

Linux(一)--rht-vmctl命令/Linux中的帮助使用/Linux中如何执行命令/Linux系统结构/利用通配符批量管理文件

2017-07-20 17:06 776 查看

rht-vmctl命令

1.用途:rht-vmctl用来控制desktop或者sever这两台虚拟机。

2.运行格式

rht-vmctl       参数          虚拟机名称
start                   ##开启
poweroff                ##关闭
reset                   ##重置
view                    ##显示
status                  ##状态


3.例子

[kiosk@foundation2 ~]$ rht-vmctl start desktop        ##开启 运行desktop
Starting desktop.
[kiosk@foundation2 ~]$ rht-vmctl reset desktop        ##重置desktop
Are you sure you want to reset desktop? (y/n) y       ##确认重置
Powering off desktop.
Resetting desktop.
Creating virtual machine disk overlay for rh124-desktop-vda.qcow2
Creating virtual machine disk overlay for rh124-desktop-vdb.qcow2
Starting desktop.
[kiosk@foundation2 ~]$ rht-vmctl view desktop         ##显示desktop
[kiosk@foundation2 ~]$ rht-vmctl status desktop       ##查看desktop状态
desktop RUNNING
[kiosk@foundation2 ~]$ rht-vmctl poweroff desktop     ##关闭desktop
Powering off desktop..
[kiosk@foundation2 ~]$


4.出现的问题

[kiosk@foundation2 ~]$ hrt-vmctl start desktop
bash: hrt-vmctl: command not found...               ##命令录入错误


Linux中的帮助使用

1.whatis 命令 ##显示命令的基本用途

2.获取命令帮助

命令   --help
[]    ##选加内容
…    ##加入内容的个数任意
<>    ##内容必加


3.例子

This utility manages the Red Hat Training supplied VMs on the local
hypervisor.

Usage: rht-vmctl [-q|--quiet] VMCMD VMNAME [DATETIME]
rht-vmctl -h|--help

where VMCMD is one of:
view       - launches console viewer of VMNAME
start      - obtain and start up VMNAME
stop       - stop a running VMNAME
poweroff   - if running, force stop VMNAME
reset      - poweroff, return to saved or original state, start VMNAME
save       - stop, save image, start VMNAME (to DATETIME)
restore    - poweroff, restore to save (to DATETIME), start VMNAME
listsaves  - list the saves of VMNAME
status     - display libvirt status of VMNAME
get        - if not here, obtain VMNAME from server
remove     - remove VMNAME from system
fullreset  - poweroff, reobtain from server, start VMNAME (bad save/image)

[kiosk@foundation2 ~]$


4.例子

[kiosk@foundation2 ~]$ date
Wed Jul 19 13:25:23 CST 2017
[kiosk@foundation2 ~]$ date -d +40days
Mon Aug 28 13:26:31 CST 2017
[kiosk@foundation2 ~]$ date -d +40days +%Y-%m-%d
2017-08-28
[kiosk@foundation2 ~]$


5.例子

[kiosk@foundation2 ~]$ cal --help

Usage:
cal [options] [[[day] month] year]

Options:
-1, --one        show only current month (default)
-3, --three      show previous, current and next month
-s, --sunday     Sunday as first day of week
-m, --monday     Monday as first day of week
-j, --julian     output Julian dates
-y, --year       show whole current year
-V, --version    display version information and exit
-h, --help       display this help text and exit

[kiosk@foundation2 ~]$


6.例子(查看1984年11月18日是这一年的第几天)

[kiosk@foundation2 ~]$ cal 18 11 1984
November 1984
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            ##18号
25 26 27 28 29 30

[kiosk@foundation2 ~]$ cal 18 11 1984 -j
November 1984
Sun Mon Tue Wed Thu Fri Sat
306 307 308
309 310 311 312 313 314 315
316 317 318 319 320 321 322
323 324 325 326 327 328 329     ##结果显示为323
330 331 332 333 334 335


Linux中如何执行命令

1.命令要在行提示符之后输入

2.行提示符各个字符含义

[kiosk@foundation0 ~]$
kiosk       ##用户
foundation  ##主机短名称
~      ##在系统中的位置
$		##用户身份提示符,$表示普通用户,#表示超级用户


3.命令的格式

命令 + 空格 + 参数 + 空格 + 目标

参数中:

-a -b -c = -abc = -cba = -bca

4.例子

[kiosk@foundation2 ~]$ touch file     ##创建文件
[kiosk@foundation2 ~]$ mkdir test     ##创建目录
[kiosk@foundation2 ~]$ rm file            ##删除文件
[kiosk@foundation2 ~]$ rm -r -f test      ##删除目录
[kiosk@foundation2 ~]$ mkdir test
[kiosk@foundation2 ~]$ rm -f -r test      ## -r -f = -f -r删除文件
[kiosk@foundation2 ~]$ mkdir test
[kiosk@foundation2 ~]$ rm -rf test        ## -r -f = -fr删除文件
[kiosk@foundation2 ~]$


Linux系统结构

1.一切都是文件

2.linux系统是一个树型结构,最顶级目录叫做根“/”

3.“/”下二级目录分代表

/bin                ##系统常规命令
/boot               ##系统启动目录,系统在启动过程中要读取的文件都在这个目录中
/dev                ##设备的管理文件
/etc/               ##大多数的系统配置文件
/home/子目录           ##普通用户家目录
/root               ##超级用户家目录
/lib                ##32位的库
/lib64              ##64位的库
/mnt    /media      ##临时设备的手动挂载点
/run                ##临时设备的自动挂载点
/opt                ##第三方软件安装目录
/proc               ##系统的进程信息
/var    /srv        ##系统数据
/tmp                ##系统临时文件
/sys                ##内核级配置
/usr                ##用户相关文件目录


4.linux系统中文件的管理

新建文件

touch   file    ##新建文件,或者修改文件的时间戳


为什么用touch?

linux中,touch可以创建一个空文件,另外它还可以修改文件的时间戳。

新建目录

mkdir = make directory

mkdir directory ##新建目录
mkdir -p test/westos/linux  ##-p=parent 当建立目录的父级目录不存在时自动建立


删除

rm -f           ##删除文件 -f=force 表示强行删除不提示
rm -fr directory    ##删除目录 -r 表示递归


文件的编写

gedit   file    ##图形编辑器
vim file    ##文本界面下的文件编辑器


vim默认进文件是只可以浏览内容的

按“i”进入编辑模式

写完内容后按“ESC”退出编辑模式

按“:wq”退出

文件内容的查看

cat 文件名称    ##查看文件内容


cat 参数  文件
-b  ##加行号,忽略空行
-n  ##加行号,不忽略空行


less    文件名称    ##分页浏览文件 “/关键字”表示搜索关键字,n向下匹配,N向上匹配


文件的复制

cp      要复制的文件  目的地
cp  -r  要复制的目录  目的地

cp  file1 file2 file3   目的地


文件的移动

mv   file   file1       ##移动
mv   文件    不存在的文件       ##重命名


文件寻址:

相对路径:不是以/开头的文件名称,此名称是真实文件的简写,这个名字省略了当前路径的值,这个名字会自动在字符前加当前路径的值。

例子:

[kiosk@foundation2 ~]$ pwd            ##打印当前工作路径
/home/kiosk
[kiosk@foundation2 ~]$ touch file     ##touch真实操作对象/home/kiosk/Desktop/file


绝对路径:是以/开头,此名称表示文件真实存在在系统的相应位置,在任何条件下都可以用的名字。

例子:

[kiosk@foundation2 ~]$ touch /home/kiosk/Desktop/file ##file名字是以/开头,它没有省略任何信息。


路径的处理命令:

pwd = print working directory   ##打印当前工作目录

cd = change directory       ##切换当前工作目录
cd directory            ##进入到指定工作目录
cd -
9b0e
##回到old-directory
cd ~               ##回到当前用户家目录
cd ~user           ##进入到指定用户的家目录
cd ..               ##代表进入到当前目录的上一级

ls = list           ##列出文件相应信息
ls              ##列出当前目录中文件的名字
ls -l               ##列出文件中文件的属性
ls -l 目录            ##列出目录中子文件的属性
ls -ld 目录           ##查看目录本身属性


利用通配符批量管理文件

*           ##匹配0-任意字符
?          ##匹配单个字符
[[:digit:]] ##单个数字
[[:alpha:]] ##单个字母
[[:lower:]] ##单个小写字母
[[:upper:]] ##单个大写字母
[[:alnum:]] ##单个数字或字母
[[:space:]] ##单个空格
[[:punct:]] ##单个符号

{1..3}                      ##1 2 3
{a..b}{1..2}                ##a1 a2 b1 b2
[acd]                       ##a或者c或者d
[!acd] | [^acd]             ##除了a并且除了c并且除了d
[![:digit:]] | [^[:digit:]] ##除了数字
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: