Linux

You are currently browsing articles tagged Linux.

背景

工作用的Linux 虚机使用的是默认安装, 根只分了50G的空间, 用着用着就不够了,所以想着给扩个空间。

[root@localhost repository]#      df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   41G  9.4G  82% /
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  637M   31G   2% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/sda1               1014M  150M  865M  15% /boot
/dev/mapper/centos-home  441G   15G  427G   4% /home
overlay                   50G   41G  9.4G  82% /var/lib/docker/overlay2/398d2eeb78bef327ecaca5cd7de0087ce59f76a938e5ef5dbce91c2895a4b1aa/merged
overlay                   50G   41G  9.4G  82% /var/lib/docker/overlay2/0f05cdc7e42716c57997501e96310ca1769824b28ea91d2509502a35be589840/merged
overlay                   50G   41G  9.4G  82% /var/lib/docker/overlay2/5c10dbf435357bf50eecc148cb9a90d211384abca9fd9a5314de5fc62910c6f5/merged
overlay                   50G   41G  9.4G  82% /var/lib/docker/overlay2/a0fe47c9a9dca33b1fcfd35684aadc2037dc1398a23b2b09ebcad476636e0dab/merged
overlay                   50G   41G  9.4G  82% /var/lib/docker/overlay2/2eb88ff71135e7b9be851a22905aeded34038a1bdf06cf5d9c963a8378ecc923/merged
overlay                   50G   41G  9.4G  82% /var/lib/docker/overlay2/2013e4d4c128e0da65e969cfc432850615257874a81dd7bf73ade4bec75c4600/merged
overlay                   50G   41G  9.4G  82% /var/lib/docker/overlay2/912b49fbc5ead76d17e25059db4301cbcd0230e6be9063c5e17c6c9a1279da01/merged
tmpfs                    6.3G     0  6.3G   0% /run/user/0
overlay                   50G   41G  9.4G  82% /var/lib/docker/overlay2/11a70ceeddd9c3201fef095c4e65d61e24d1429a5c3e04b90310e1f3ebda6572/merged
Read the rest of this entry »

Tags:

[root@xuxing ~]#yum -y install expect
[root@xuxing ~]# cat 123
#!/bin/expect
spawn ssh root@10.124.45.123 
expect "password:"
send "cisco\r"
interact
[root@xuxing ~]# chmod 777 123 
[root@xuxing ~]# 
[root@xuxing ~]# 
[root@xuxing ~]# ./123
spawn ssh root@10.124.45.123
root@10.124.45.123's password: 
Last login: Fri Nov 20 04:53:03 2020 from 10.140.0.42
[root@nso ~]# 
[root@nso ~]#
四个命令的解释

send:用于向进程发送字符串
expect:从进程接收字符串
spawn:启动新的进程
interact:允许用户交互,如果没有该命令会直接终端session,返回之前的终端

Read the rest of this entry »

Tags:

由于测试,需要安装一个syslog server, Windows上的免费软件搜到了KIWI Syslog Server,但是需要注册,然后还得去等两天的审核,想想还是算了不折腾了,打算在Linux上装一个,还好过滤看log。

Install
[root@xuxing ~]#yum install rsyslog
Configure
Read the rest of this entry »

Tags:

How to install
//Yum
[root@nso ~]# yum -y install screen
//rpm
[root@nso ~]#wget http://mirror-hk.koddos.net/centos/7.8.2003/os/x86_64/
Packages/screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm
[root@nso ~]#rpm -ivh  screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm
Some Tips

Created a session, -S means special a name for that session.

[root@xuxing ~]# screen
[root@xuxing ~]# screen -S test  

Recover your session.

[root@xuxing ~]# screen -ls
There are screens on:
	15741.test	(Detached)
	5971.pts-2.xuxing	(Detached)
	4485.pts-2.xuxing	(Detached)
	4409.pts-0.xuxing	(Detached)
	25997.9922a	(Detached)
5 Sockets in /var/run/screen/S-root.
[root@xuxing ~]# screen -r test    // recover test session
[detached from 15741.test]
Read the rest of this entry »

Tags:

nl命令是用来为文本文件生成行号的,但最实用的用法还是在每行之前添加0。

//显示行号,默认空白行不显示
[root@xuxing ~]# nl /etc/fstab
//空白行也显示行号
[root@xuxing ~]# nl -b a  /etc/fstab
//为每行添加0,默认添加5个
[root@xuxing ~]# nl -b a -n rz /etc/fstab
//指定添加3个0,使用"-w 3"
[root@xuxing ~]# nl -b a -n rz -w 3 /etc/fstab



//示例
[root@xuxing ~]# nl -b a -n rz /etc/fstab
000001  
000002  #
000003  # /etc/fstab
000004  # Created by anaconda on Wed Dec 19 08:07:14 2018
000005  #
000006  # Accessible filesystems, by reference, are maintained under '/dev/disk'
000007  # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
000008  #
000009  /dev/mapper/centos-root /                       xfs     defaults        0 0
000010  UUID=bd47b365-3718-40a2-a835-e6ae1c5187c5 /boot                   xfs     defaults        0 0
000011  /dev/mapper/centos-swap swap                    swap    defaults        0 0
[root@xuxing ~]#

Xu

Step by step the ladder is ascended.

“Only for self-learning use, if infringement will delete.”

Tags:

学习的时候搜到管理CISCO IOX 设备的ansible模块,“iosxr_config – Manage Cisco IOS XR configuration sections“,记录下有空玩玩。

[student@workstation ~]$ ansible-doc -l | grep ios | grep cisco
[student@workstation ~]$ 
[student@workstation ~]$ ansible-doc -l | grep iosxr_config
iosxr_config                                           Manage Cisco IOS XR configuration sections          
[student@workstation ~]$ 
[student@workstation ~]$ 
[student@workstation ~]$ 
[student@workstation ~]$ 
[student@workstation ~]$ 
[student@workstation ~]$ ansible-doc iosxr_config


EXAMPLES:

- name: configure top level configuration
  iosxr_config:
    lines: hostname {{ inventory_hostname }}

- name: configure interface settings
  iosxr_config:
    lines:
      - description test interface
      - ip address 172.31.1.1 255.255.255.0
    parents: interface GigabitEthernet0/0/0/0

- name: load a config from disk and replace the current config
  iosxr_config:
    src: config.cfg
    replace: config
    backup: yes

- name: for idempotency, use full-form commands
  iosxr_config:
    lines:
      # - shut
      - shutdown
    # parents: int g0/0/0/1
    parents: interface GigabitEthernet0/0/0/1

- name: configurable backup path
  iosxr_config:
    src: config.cfg
    backup: yes
    backup_options:
      filename: backup.cfg
      dir_path: /home/user

Xu

Step by step the ladder is ascended.

Tags: