Linux—文本编辑Vim

1.去掉DNS域名解析:

[root@localhost ~]# vim /etc/ssh/sshd_config   //进入Vim文本编辑

#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes ——>#UseDNS no //修改
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

在这里插入图片

[root@localhost ~]# systemctl restart sshd   //重启服务
[root@localhost ~]# 

2.当前用户永久生效的命令别名

(1)写一个命令别名为hello,实现的功能为每输入一次hello命令,就有hello,everyone写入到文件/file.txt文件中

 [root@localhost ~]# vim ~/.bashrc   //进入别名的配置文件

在这里插入图片描述

alias hello=‘echo hello,every one>>/file.text’ //追加重定向写入

在这里插入图片描述

  [root@localhost ~]# source .bashrc     //使其生效
  [root@localhost ~]# hello              //测试命令
  [root@localhost ~]# cat /file.text     //查看文件
  hello,every one
  [root@localhost ~]# hello
  [root@localhost ~]# hello
  [root@localhost ~]# cat /file.text     //命令生效
  hello,every one
  hello,every one
  hello,every one

(2)写一个命令别名为shuaxin,实现的功能为每输入一次该命令,file.txt文件的所有时间就更新为当前时间

 [root@localhost ~]# vim ~/.bashrc   //进入别名的配置文件

在这里插入图片描述

 alias shuaxin='touch /file.txt'     
    :wq    //保存并退出
    [root@localhost ~]# source .bashrc    //使其生效
    [root@localhost ~]# shuaxin           //测试命令
    [root@localhost ~]# stat /file.txt    //文件的详细信息显示
      File: ‘/file.txt’
      Size: 15        	Blocks: 8          IO Block: 4096   regular file
    Device: 802h/2050d	Inode: 2328652     Links: 1
    Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
    Context: unconfined_u:object_r:etc_runtime_t:s0
    Access: 2019-03-17 19:34:56.429961137 +0800
    Modify: 2019-03-17 19:34:52.934961306 +0800
    Change: 2019-03-17 19:34:52.934961306 +0800
     Birth: -
    [root@localhost ~]# 

3.所有用户生效的命令别名

(1)写一个所有用户都生效的命令别名为hh,输入这个命令之后可以在当前用户家目录下面创建一个file1文件

[root@localhost ~]# vim /etc/bashrc

在这里插入图片描述

alias hh='touch ~/file1'   //touch—创建普通文件
:wq                        //保存并退出
[root@localhost ~]# source .bashrc    //使其生效
[root@localhost ~]# hh                //测试命令
[root@localhost ~]# ll      
total 8
-rw-------. 1 root root 1632 Mar  6 05:37 anaconda-ks.cfg
drwxr-xr-x. 2 root root    6 Mar 14 23:23 Desktop
drwxr-xr-x. 2 root root    6 Mar 14 23:23 Documents
drwxr-xr-x. 2 root root    6 Mar 14 23:23 Downloads
-rw-r--r--. 1 root root    0 Mar 17 19:51 file1
-rw-------. 1 root root 1725 Mar  5 21:46 initial-setup-ks.cfg
drwxr-xr-x. 2 root root    6 Mar 14 23:23 Music
drwxr-xr-x. 2 root root    6 Mar 14 23:23 Pictures
drwxr-xr-x. 2 root root    6 Mar 14 23:23 Public
drwxr-xr-x. 2 root root    6 Mar 14 23:23 Templates
drwxr-xr-x. 2 root root    6 Mar 14 23:23 Videos
[root@localhost ~]# 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值