Centos7 system initialization and Centos7 software installation

Centos7 system initialization and Centos7 software installation

Centos7 system initialization

System initialization script and function library, pay attention to the path of the function library

#!/bin/bash
# Author:kakaops
# Email:[email protected]

# 初始化shell脚本
# 保证函数库路径正确
source ./function.sh
menu
while true
do
    read -p "请选择>>:" keyword
    clear && menu
    case $keyword in
        1|a)
    ¦   ¦   firewall
    ¦   ¦   change_yum
    ¦   ¦   network
    ¦   ¦   commonds
    ¦   ¦   ;;
        2|b)
    ¦   ¦   software
    ¦   ¦   #yum_install
    ¦   ¦   #chrome_install
    ¦   ¦   ;;
        3|c)
    ¦   ¦   software_install
    ¦   ¦   #fcitx_install
    ¦   ¦   ;;
        4|d)
    ¦   ¦   software_install
    ¦   ¦   #typora_install
    ¦   ¦   ;;
        5|e)
    ¦   ¦   software_install
    ¦   ¦   #sublime_install
    ¦   ¦   ;;
        q|Q)
    ¦   ¦   exit
    ¦   ¦   ;;
        *)
    ¦   ¦   echo "输入无效"
    ¦   ¦   ;;
    esac
done

#!/bin/bash
# Author:kakaops
# Email:[email protected]

# 系统初始化函数库
# 菜单
function menu(){
    
    
source ./function.sh
cat <<!
1|a) 进行操作系统初始化,防火墙、yum源、静态ip、常用命令
2|b) 构建本地yum仓库,yum安装QQ、CherryTree、VNC、谷歌
3|c) 安装小企鹅输入法(fcitx),搜狗输入法
4|d) 安装Typora,创建Typora的桌面快捷方式
5|e) 安装Sublime Text3,汉化,创建桌面快捷方式
q|Q) 退出
!
}

# 永久关闭防火墙和Selinux
function firewall(){
    
    
    echo -e "\e[1;35m永久关闭防火墙和Selinux\e[0m"
    sleep 2
    systemctl stop firewalld
    systemctl disable firewalld
    echo -e "\e[1;31mFirewall permanently closed\e[0m"
    sed  -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config
    echo -e "\e[1;36mSelinux permanently closed\e[0m"
    sleep 2
}

# 国外yum仓库换成阿里镜像
function change_yum(){
    
    
    clear
    echo -e "\e[1;31m即将更换系统yum源\e[0m"
    rm -rvf /etc/yum.repos.d/*
    curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
    yum -y install wget
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    yum clean all
    yum makecache
    clear
    echo -e "\e[1;34mConfiguration of Yum warehouse completed successfully\e[0m"
}

# 把当前ip配置为静态ip 
function network(){
    
    
    clear
    echo -e "\e[1;31m获取网卡信息,配置静态IP地址\e[0m"
    sleep 3
    local ipcfg=`ip a |awk -F'[ : ]+' '/^2/ {print $2}'`
    local ip=`ip a |awk -v m=$ipcfg -F'[ / ]+' '/scope global/ && $NF==m  {print $3}'`
    echo "网卡名称:$ipcfg"
    echo "配置静态IP地址为:$ip"
    cp /etc/sysconfig/network-scripts/ifcfg-$ipcfg /mnt/ifcfg-$ipcfg
    rm -rvf /etc/sysconfig/network-scripts/ifcfg-$ipcfg &>/dev/null
    cat >> /etc/sysconfig/network-scripts/ifcfg-$ipcfg <<!
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
NAME=$ipcfg
DEVICE=$ipcfg
ONBOOT=yes
IPADDR=$ip
NETMASK=255.255.255.0
GATEWAY=10.11.65.1
DNS1=114.114.114.114
!
    systemctl restart network
    echo -e "\e[1;31mNetwork configuration complete\e[0m"
    sleep 3
}

# 安装系统常用命令
function commonds(){
    
    
    clear
    echo -e "\e[1;34m安装系统常用命令\e[0m"
    sleep 2
    yum -y install vim
    yum -y install lsof dstat
    clear
    echo -e "\e[1;34mCommond installed successfully\e[0m"
}

# 利用ftp构建自己的本地yum源
function software(){
    
    
    clear
    echo -e "\e[1;34m从10.11.65.31ftp服务器构建本地yum源\e[0m"
    sleep 3
cat >> /etc/yum.repos.d/mysoftware.repo <<!
[mysoftware]
name=mysoftware
baseurl=ftp://10.11.65.31/software
enable=1
gpgcheck=0
!
    yum clean all
    yum makecache
    yum repolist
}

function software_install(){
    
    
    echo -e "\e[1;31m下文有详细的安装方法,安装软件环境不同报错多种多样,具体问题具体解决\e[0m"
}

Centos7 software installation

Here is a summary of the method of installing different types of packages of centos7 and the error resolution I encountered. My test environment is the environment that has just completed the system initialization. The following is the detailed process, including the installation process and related knowledge expansion. The examples are not complete and need to be installed. Other software can refer to similar examples. When encountering similar software, you can refer to the installation steps of
QQ, KVM, CherryTree, VNC, Chrome, fcitx, Sogou input method, Typora, Sublime Text3. The software package needs to be downloaded on Baidu network disk, or you can I will send you a message.
Package connection:

1. The software that comes with the system

yum -y install cherrytree

2. Software that can be used directly after installing the package

After building the local warehouse,
yum list |grep mysoftware
filters out the rpm installation package of the local yum library mysoftware. Install the software according to the name in front of the first point of the package. After installation, click Trust and launch on the desktop. If the desktop is not available, go to the upper left corner of the desktop Find in Applications, drag or copy to the desktop
yum -y install linuxqq
yum -y install realvnc-vnc-viewer
error: Protected multilib versions: libgcc-4.8.5-39.el7.i686 != libgcc-4.8.5-36 .el7.x86_64
Solution: yum install --setopt=protected_multilib=false realvnc-vnc-viewer (choose according to the library)
yum -y install google-chrome-stable
Google Chrome desktop can’t start solution
vim ~/Desktop /google-chrome.desktop
modify Desktop Entry , add --no-sandbox at the end of the Exec tag
(you can modify the configuration file with sed)
Sandbox (sandbox) refers to a technology in which software runs in an environment with restricted operating systems. Because the software runs in a restricted environment, even an intruder who breaks into the software cannot have unlimited access to the operating system-provided facilities; the loss caused by a hacker who gains control of the software is also limited. In addition, if attackers want to gain full control of the operating system, they have to overcome the sandbox restrictions. Sandbox also provides defense-in-depth. Many PaaS systems provide a real-time operating environment, and its core is a sandbox application, such as Azure and Google App Engime

Three, fcitx install Sogou input method

(More complicated software installation) Install Sogou input method
sogoupinyin_2.2.0.0108_amd64.deb through fcitx.
deb is the Debian software package format, and the file extension is .deb, which is the same as Debian naming. Deb is also due to Debra Murdock (Debian founder Ian Murdock's ex-wife). The Debian package is a standard archive of Unixar. The package file information and package content are packaged by gzip and tar. The classic program for handling these packages is dpkg, which often operates through apt. Through the Alien tool, deb packages can be converted into other forms of packages. .

The Linux Sogou input method uses fcitx as the input platform, so you must first install the fcitx input method.
Fcitx[ˈfaɪtɪks] is the English abbreviation of (Free Chinese Input Toy for X), and the Chinese name is Little Penguin input method. It is written for the desktop environment Provide a flexible input program, completely solve the problem of not having a good Chinese input method under GNU/Linux.
Do not uninstall Ibus: Ibus input method is a new input method framework developed based on Python.
Do not execute yum erase ibus and yum remove ibus, the desktop environment will be deleted together. Don’t!
Reason, if yum is uninstalled, it will be dependent on Gnome (The GNU Network Object Model Environment, one is a set of purely free computer software that runs on the operating system and provides a graphical desktop environment). It means that you only have the text interface and the core part of Linux.

1. Uninstall the ibus software separately, without uninstalling dependent packages!
rpm -e --nodeps ibus

2. Install epel library source
yum -y install epel-release

3. Install fcitx
yum -y install fcitx fcitx-pinyin fcitx-configtool
Go to Applications in the upper left corner to find the little penguin, drag it to the desktop, double-click to open, the small keyboard will appear in the upper right corner, the installation is successful, the small icon right click, you can call up fcitx configuration
fcitx- v Check the version, fcitx version: 4.2.9.5
Insert picture description here
4. The next step is to configure the Fcitx environment: add the content in ~/.bashrc
vim ~/.bashrc
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
restart Or source
source ~/.bashrc

5. Install Sogou input method installation dependent software
yum -y install qtwebkit

6. Sogou input method rpm package installation
rpm -ivh --force sogoupinyin-2.2.0.0108-2.x86_64.rpm
(download Sogou input method deb package deb -> rpm package conversion
Install dpkg package:
yum -y install dpkg
install alien package .
yum -y install Alien
deb -> RPM package conversion
alien -r --scripts sogoupinyin_2.2.0.0108_amd64.deb
command will have the following tips:
sogoupinyin-2.2.0.0108-2.x86_64.rpm Generated)
If you do not want to convert the installation package Use the following method to directly unzip and
go to your own warehouse, or download sogoupinyin_2.2.0.0108_amd64.deb
ar -vx sogoupinyin_2.2.0.0108_amd64.deb //Get the files in the deb package
x-debian-binary
x-control.tar. gz
x-data.tar.xz
The deb package itself consists of three parts: the data package, which contains the actual installed program data, and the file name is data.tar.XXX; the installation information and control script package, which contains the deb installation instructions, logos, scripts, etc., and the file name is control.tar .gz; the last one is some binary data of the deb file, including the file header and other information, which are generally invisible, but can be seen when opened in some software. data.tar.gz contains the actually installed program data, and during the installation process, the data in the package will be directly decompressed to the root directory (ie / ), so you need to set the corresponding file location before packaging File/directory tree.
tar -xvf data.tar.xz -C / //Unzip this package, be sure to unzip it to the root

7. Sogou Pinyin library, create a soft link:
ln -s /usr/lib/x86_64-linux-gnu/fcitx/fcitx-sogoupinyin.so /usr/lib64/fcitx/fcitx-sogoupinyin.so

ln -s /usr/lib/x86_64-linux-gnu/fcitx/fcitx-punc-ng.so /usr/lib64/fcitx/fcitx-punc-ng.so

8. Restart the Little Penguin input method, add Sogou input method and
enter fcitx-configtool to start, uncheck when adding a keyboard, enter sogou (pinyin) to filter, see Sogou Pinyin input method, click to add it, and then press SHIFT to switch input Method, just test the Chinese output.
Insert picture description here

9. Click "Add" in the right column of the pop-up window for gnome-session-properties, (centos7 starts up automatically)
"Name" just write, just write sogou. Command write:

sogou-qimpanel

Problem solving:
If the power-on time is too long after the configuration is started:
modify the time that systemd waits for the fcitx process when restarting or shutting down, the default is 90 seconds, we can change it to wait only 10 seconds at most, it will be fast Restart or shutdown is no longer the effect of waiting for a long time. Specifically, modify the /etc/systemd/system.conf file, remove the # in front of the line #DefaultTimeoutStopSec=90s, and then change its assignment to 10s and save it.

Fourth, Typora creates a desktop shortcut

The software Typora
software that needs to create desktop shortcuts by yourself usually has a .desktop file in the decompression directory, this is the configuration file of the Centos7 system desktop, but Typora does not have it, even the desktop picture is not available.
1. Prepare the installation package

2. Unzip the installation package
tar -xvf Typora-linux-x64.tar.gz
. The bin directory under the unzip directory is the installation directory of Typora. bin/Typora-linux-x64/Typora is the startup command

3. Declare the environment variable
vim ~/.vimrc in ~/.bashrc and
add: export PATH=$PATH:/opt/bin/Typora-linux-x64 //Write
source ~/.bashrc according to your decompression directory

4. Typora command to start the test
Typora
error: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
Solution: yum -y install libXScrnSaver
error: Running as root without --no-sandbox is not supported. See https://crbug.com/638180.Trace/breakpoint trap
solution: Typora --no-sandbox
started successfully

5. Typora creates a desktop icon.
Create a Typora configuration file on the desktop and add execution permissions
vim /root/Desktop/Typora.desktop
chmod a+x /root/Desktop/Typora.desktop

[Desktop Entry]
Encoding=UTF-8
Name=Typora
Comment=Run and manage virtual machines
Exec=/opt/bin/Typora-linux-x64/Typora %U --no-sandbox
Terminal=false
Type=Application
Icon=/root/Downloads/typora.jpg
StartupNotify=true
Categories=System;
MimeType=application

Exec=/opt/bin/Typora-linux-x64/Typora %U Executable file decompression path
Icon=/root/Downloads/typora.jpg The local save path of pictures downloaded online

Five, configure Sublime Text3, and the localization process

The .desktop file in the unzipped directory is the wrong software Sublime Text3, and the finished process
1. Prepare the installation package

2. Unzip the installation package
tar -xvf sublime_text_3_build_3211_x64.tar.bz 2 The sublime_text_3 in the
unzip directory is the installation directory, there is an Icon directory, go in and select a picture, remember the absolute path of the picture, the sublime_text inside is the startup command, remember the command Absolute path

3. Change the [Desktop Entry] tab of the desktop shortcut configuration file
vim sublime_text.desktop to
modify the command path Exec and the image path Icon
cp sublime_text.desktop /root/Desktop
Trust and launch The
startup command can also declare a PATH under ~/.bashrc Path
If the startup fails, 90% of the command path and image path are wrong

4. Localization of Sublime Text3①
Open Sublime Text, use the shortcut key Shift+Ctrl+P to pop up the search bar, enter the keyword install in the search box, a drop-down option appears, click to select one of them: Install Package Control, for a while There is a prompt of successful installation. At this time, add a Package Control under Preference, click Package Control under Preference to continue searching
for Install Package, and click Package Control: Install Package in the search result. Wait for the second image
Insert picture description here
②, enter chinese in the search box, Select ChineseLocalizations in the drop-down box, as shown in Figure
Insert picture description here
③, 4. After clicking, the Chinese package is installed. Note that you need to reopen Sublime Text, click Help->Language->Simplified Chinese in the task bar, and do not reopen It may not be found, the localization is successful
Insert picture description here

6. Installation of VMware-Workstation

VMware-Workstation-Full-15.5.6-16341506.x86_64.bundle
bundle is an executable file in Unix/linux system. The user can use the ./*** (file name).bundle command to make it run in the terminal. If you don’t have executable permissions, you need to add executable permissions. The
installation method is to directly execute
bash VMware-Workstation-Full-15.5.6-16341506.x86_64.bundle
. There are a lot of registration code networks, just find and install it, Centos7 The system is still not recommended to install this virtual software, because it takes up a lot of memory, if the real machine has a small memory, it will cause the system to freeze. Centos7 virtualization software recommends KVM, docker, etc. The
installation is successful when the execution is over: Installation was successful, as shown in the figure, you can find it VMware-Workstation
Insert picture description here

Attached is a desktop picture of my Centos7 Chinese version of the real machine, if you have any questions, you can leave a message and we will explore and solve it

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_50620077/article/details/108677379