如何在Linux上查看历史命令

5.查看最近使用的10条历史命令

[root@Myliunx ~]# history 10
  386  root 2022/07/18 22:53:29 history -10
  387  root 2022/07/18 22:55:44 history -N 10
  388  root 2022/07/18 22:56:36 history -10
  389  root 2022/07/18 22:57:41 history 
  390  root 2022/07/18 22:58:00 history -a
  391  root 2022/07/18 22:58:19 history -n
history -a
  392  root 2022/07/18 22:58:22 history -n
history -a
  393  root 2022/07/18 22:58:22 history -a
  394* root 2022/07/18 22:58:29 
  395  root 2022/07/18 22:58:42 history 10

6.在一行上执行两个命令,打印123和从root切换到普通用户

[root@Myliunx ~]# echo 123; su - admin
123
su: user admin does not exist

7.引号的使用举例: 无引号,单引号,双引号,反引号,$()

[root@Myliunx ~]# data=1
[root@Myliunx ~]# echo $data
1
[root@Myliunx ~]# data1='$data'
[root@Myliunx ~]# data2="$data"
[root@Myliunx ~]# echo $data1;echo $data2
$data
1
[root@Myliunx ~]# data3=`$data`
-bash: 1: command not found
[root@Myliunx ~]# data3=`echo 123`
[root@Myliunx ~]# echo $data3
123
[root@Myliunx ~]# data3="echo 123"
[root@Myliunx ~]# echo $data3
echo 123
[root@Myliunx ~]# data3='echo 123'
[root@Myliunx ~]# echo $data3
echo 123
[root@Myliunx ~]# data3=`pwd`
[root@Myliunx ~]# echo $data3
/root
[root@Myliunx ~]# data3=$(pwd)
[root@Myliunx ~]# echo $data3
/root

你可能感兴趣的:(linux,linux,bash,运维)