右键粘贴 临时: :set mouse-=a
1 2 3 4 5 vim ~/.vimrc if has('mouse' ) set mouse-=a endif
改变主机名 1 sudo hostnamectl set-hostname linux
添加主机名和 IP 地址映射
1 2 sudo vim /etc/hosts127.0.0.1 node01
设置静态ip 1 2 3 4 5 6 7 8 9 10 11 12 ip address 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link /ether 00:0c:29:07:18:a0 brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.61.129/24 brd 192.168.61.255 scope global dynamic ens33 valid_lft 1422sec preferred_lft 1422sec inet6 fe80::20c:29ff:fe07:18a0/64 scope link valid_lft forever preferred_lft forever
编辑网卡配置文件:将 allow-htplug ens33 行替换为 auto ens33,并将 dhcp 参数更改为 static。
1 2 3 4 5 6 7 8 9 10 11 12 13 sudo vim /etc/network/interfacesauto ens33 iface ens33 inet static address 192.168.61.110 netmask 255.255.255.0 gateway 192.168.61.2
重启网络服务
1 2 3 systemctl restart networking.service ip add show
设置dns
1 2 3 4 5 6 sudo vi /etc/resolv.confnameserver 114.114.114.114 nameserver 8.8.8.8 nameserver 8.8.8.4 nameserver 192.168.61.2
windows映射 修改 C:\WINDOWS\System32\drivers\etc\hosts
1 2 3 4 5 192.168.61.110 debain 192.168.61.111 node01 192.168.61.112 node02 192.168.61.113 node03 192.168.61.114 node04
安装常用工具 以下是在 Debian 12 中安装常用工具的命令,按类别整理:
文本编辑(vim/nano)
网络请求调试(curl/wget)
网络诊断(traceroute/dig/mtr)
系统监控(htop/lsof)
远程访问(ssh)
开发调试(gdb/strace)
压缩解压(zip/unzip/tar)
硬件诊断(lspci/lsusb)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 sudo apt updatesudo apt install -y vim nano curl wgetsudo apt install -y net-tools iproute2 traceroute dnsutils mtr-tinysudo apt install -y htop lsof tmux screen git unzip zipsudo apt install -y build-essential gdb strace ltracesudo apt install -y openssh-client openssh-server ufw sudo sudo apt install -y lshw pciutils usbutilssudo apt install -y tar gzip bzip2 xz-utilssudo apt install -y aptitude mlocate man-db
安装完成后建议执行:
1 2 3 4 5 sudo updatedbsudo ufw enable
.bashrc别名 1 2 3 4 5 6 7 alias ls ='ls --color=auto' alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto'
SSH SSH免密 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ssh-keygen -t rsa -b 2048 scp ~/.ssh/* root@192.168.61.110:~/.ssh/ scp ~/.ssh/* root@192.168.61.111:~/.ssh/ scp ~/.ssh/* root@192.168.61.112:~/.ssh/ scp ~/.ssh/* root@192.168.61.113:~/.ssh/ scp ~/.ssh/* root@192.168.61.114:~/.ssh/ ssh-copy-id root@192.168.61.110 ssh-copy-id root@192.168.61.111 ssh-copy-id root@192.168.61.112 ssh-copy-id root@192.168.61.113 ssh-copy-id root@192.168.61.114 ssh-copy-id sun@192.168.61.110 ssh-copy-id sun@192.168.61.111 ssh-copy-id sun@192.168.61.112 ssh-copy-id sun@192.168.61.113 ssh-copy-id sun@192.168.61.114 ssh username@remote_server_ip
root开启ssh 1 sudo vim /etc/ssh/sshd_config
PermitRootLogin:确保该项的值为 yes 或 prohibit-password(使用密钥认证登录)
1 2 3 4 5 6 7 8 PermitRootLogin prohibit-password PasswordAuthentication yes sudo systemctl restart ssh