linux远程管理


一、关闭与重启

shutdown 一分钟后关机
shutdown -c 取消关机
shutdown -r 重新启动
shutdown -r now 立即重新启动
shutdown 20:25 定时关机
shutdown +10 十分钟后关机

二、查看或配置网卡信息

ifconfig  查看计算机网卡配置信息
ifconfig | grep inet
127.0.0.1 本地环回地址 测试网卡是否正常工作
ping ip地址  检测到目标ip连接是否正常
ping 127.0.0.1 测试网卡是否正常工作

域名是IP地址方便记忆的别名 如www.baidu.com

ping www.baidu.com

通过IP地址找到计算机 通过端口号找到计算机程序

IP:端口号
服务器————端口号
SSH     22
Web     80
HTTPS   443
FTP     21

三、远程连接ssh

ssh [-p port] user@remote
user 远程计算机上的用户名 不指定默认当前用户
remote 远程机器地址IP、域名或别名
port 监听端口 不指定默认22
第一次连接需要在提示界面手动输入yes

四、远程复制scp

远程拷贝文件
指定端口的P大写
向本地复制文件 必须在本地终端下运行 即不需要ssh 在本地终端

本地向服务器 注意冒号后面没有空格
scp [-r] [-P port] 源文件 user@remote:目标文件
服务器向本地
scp [-r] [-P port] user@remote:源文件 目标文件
scp -r 递归复制 复制文件夹
例如
ycz@ycz:~$ scp ycz@192.168.1.144:/home/ycz/PycharmProjects/myproject0/sgan-master/scripts/demo.log /home/ycz/log/demo.log

五、免密码登录与别名

免密码登录均在本地执行命令 无需连接到服务器执行

ssh-keygen 三次回车
.ssh 下多了两个远程登录加密文件
将.pub文件传递到服务器.ssh文件夹中
ssh-copy-id -p port user@remote
ssh-copy-id ubuntu@192.168.1.180
ssh-copy-id ycz@192.168.1.180
ssh-copy-id dlserver@192.168.1.144
ssh-copy-id ycz@192.168.1.144
文件保存在服务器.ssh文件夹下

user@remote可以用别名代替

cd .ssh
.ssh文件夹下创建文件config
touch config
gedit config

采用四个空格缩进
ssh 别名   直接登录
Host 别名(不能含空格)
    HostName IP地址
    User 远程计算机用户名
    Port 远程计算机ssh端口
    
ssh fwq   直接登录
Host fwq
    HostName 192.168.1.180
    User ubuntu
    Port 22
Host fwq
    HostName 192.168.1.180
    User ycz
    Port 22
Host xfwq
    HostName 192.168.1.144
    User dlserver
    Port 22
Host xycz
    HostName 192.168.1.144
    User ycz
    Port 22

六、修改shell

记录shell地址
cat /etc/shells
修改各个用户shell
vi /etc/passwd

当修改shell为zch时候
重启在进入Linux 提示如下信息
若不显示则输出以下

zsh /usr/share/zsh/functions/Newuser/zsh-newuser-install -f
This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

--- Type one of the keys in parentheses --- 

按 1 进入主菜单
然后提示如下信息

Please pick one of the following options:

(1)  Configure settings for history, i.e. command lines remembered
     and saved by the shell.  (Recommended.)

(2)  Configure the new completion system.  (Recommended.)

(3)  Configure how keys behave when editing command lines.  (Recommended.)

(4)  Pick some of the more common shell options.  These are simple "on"
     or "off" switches controlling the shell's features.  

(0)  Exit, creating a blank ~/.zshrc file.

(a)  Abort all settings and start from scratch.  Note this will overwrite
     any settings from zsh-newuser-install already in the startup file.
     It will not alter any of your other settings, however.

(q)  Quit and do nothing else.  The function will be run again next time.
--- Type one of the keys in parentheses --- 

直接输入一个 0 会在 ~ 目录下生成一个空的 .zshrc 配置文件
然后提示如下信息

The function will not be run in future, but you can run
it yourself as follows:
  autoload -Uz zsh-newuser-install
  zsh-newuser-install -f

The code added to ~/.zshrc is marked by the lines
# Lines configured by zsh-newuser-install
# End of lines configured by zsh-newuser-install
You should not edit anything between these lines if you intend to
run zsh-newuser-install again.  You may, however, edit any other part
of the file.

将根目录下文件复制过来

sudo cp -i /home/root用户名/.zshrc /home/新用户名/.zshrc

七、通过域名找IP地址

ping 域名 -p 端口号 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值