Linux uses notes

https://morooi.cn/

Some method of recording techniques when using Linux, for easy viewing later.

main content:


Enable SSH client and log in using SSH

For more details see: SSH-free dense Login

Although the form of application experience on Windows 10 Linux is a bad choice, but often operate using the built-in Windows PowerShell Linux or CMD still has not used a lot.

The most crucial is when you need to manipulate files, use the interactive command far less use SFTP to a more "simple and crude." So long as the configuration through SSH remote login, you can operate this as a Linux system as a remote management server.

First, because the Ubuntu system limitations, so we need to set a new password for the root user, enter here:

1
sudo passwd root

Once configured, or when the future use SSH client SFTP client login system, we can use to log in directly as root.

Use cpcommand SSH configuration files are backed up:

1
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

After using vim editor to edit the sshd_configfile:

1
sudo vim /etc/ssh/sshd_config

Edit and adjust the following settings:

1
2
3
4
5
2222 Port 
ListenAddress 0.0.0.0
PermitRootLogin yes # revise yes
#StrictModes yes # comment out this line
PasswordAuthentication yes # turned out to be no, yes change

Then enter the command:

1
service ssh start

Start SSH

Error Handling

If the following error occurs, it can ssh-keygenautomatically generate missing key

1
2
3
4
* Stopping OpenBSD Secure Shell server sshd [ OK ] 
* Starting OpenBSD Secure Shell server sshd Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key

Repair method

carried out

1
sudo ssh-keygen -A

Restart the ssh service

1
sudo service ssh — full-restart

carry out!

1
2
3
[email protected]:~$ sudo service ssh --full-restart 
* Stopping OpenBSD Secure Shell server sshd [ OK ]
* Starting OpenBSD Secure Shell server sshd [ OK ]

View Ubuntu version

  • Method One :

    1
    cat /etc/issue

    Return result:

    1
    Ubuntu 18.04.2 LTS n l
  • Method Two :

    1
    lsb_release -a

    Return result:

    Big Box Linux use notes  
    1
    2
    3
    4
    5
    No LSB modules are available. 
    Distributor ID: Ubuntu
    Description: Ubuntu 18.04.2 LTS
    Release: 18.04
    Codename: bionic
  • Method three :

    1
    cat /etc/lsb-release

    Return result:

    1
    2
    3
    4
    DISTRIB_ID=Ubuntu 
    DISTRIB_RELEASE=18.04
    DISTRIB_CODENAME=bionic
    DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
  • Method four :

    1
    cat /proc/version

    Return result:

    1
    Linux version 4.4.0-17763-Microsoft ([email protected]) (gcc version 5.4.0 (GCC) ) #379-Microsoft Wed Mar 06 19:16:00 PST 2019
  • Method five :

    1
    uname -a

    Return result:

    1
    Linux Monster 4.4.0-17763-Microsoft #379-Microsoft Wed Mar 06 19:16:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Method six : only core edition

    1
    uname -r

    Return result:

    1
    4.4.0-17763-Microsoft

to add domestic apt-get source

Use Tsinghua Mirror: https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/

Here Ubuntu versionUbuntu 18.04 LTS

1
vim /etc/apt/sources.list

Replace the following

1
2
3
4
5
6
7
8
9
10
11
12
13
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

执行更新

1
apt update && apt upgrade

Ubuntu删除无用缓存及垃圾文件

linux和windows系统不同,linux不会产生无用垃圾文件,但是在升级缓存中,linux不会自动删除这些文件。

非常有用的清理命令

1
2
3
sudo apt-get autoclean # 清理旧版本的软件缓存
sudo apt-get clean # 清理所有软件缓存
sudo apt-get autoremove # 删除系统不再使用的孤立软件

这三个命令主要清理升级缓存以及无用包的。

清理Linux下孤立的包

1
sudo apt-get install deborphan -y

Guess you like

Origin www.cnblogs.com/lijianming180/p/12147639.html