Getting Started with Linux pre-prepared base (B): white reptile learn Python (3)

Life is short, I used Python

The foregoing Portal:

White school Python Reptile (1): Opening

White Python crawler Science (2): Pre-preparation (a) is mounted substantially libraries

Linux Basics

CentOS official website: https://www.centos.org/ .

CentOS official download link: https://www.centos.org/download/ .

Linux is widely used in server systems in the enterprise, whether it is written in the code, or use a third-party open source products, the vast majority are deployed to run on Linux above.

Many students may mention Linux on counseling, the black gooey one, not even a screen, the screen is full of mystery code that no one can understand.

Table fear, I will take you on Linux.

There are different Linux distributions, but we generally used in the enterprise is CentOS, the current version has been commonly used to 7.x.

Because Linux is open source, so release provides between different vendors will be very much more common Ubuntu (Debian-based desktop version), Debian (an international organization of the open source operating system), RedHat (Red Hat Enterprise System ), Fedora (originally sponsored by Red Hat desktop system kit) and so on.

Because the use of more or CentOS in the enterprise, so we get to introduce CentOS.

You can use third-party vendors in the VMware installation of win or win system comes with Hyper-V to build a virtual machine installed, you can also use the Starter Edition of the cloud server (1H1G1M) cloud service vendors, most of the new user preferences in prices are less than 100 yuan.

During the installation, I do not introduced, Baidu, a lot.

After installation is complete, set up the Linux root user password, you can use ssh tool to connect, tool where you can choose xshell (Free for personal use, is the official website of the true bit slow), open xshell input ip, user name (root), password after, you should see the following interface:

Xiao Bian used here is Jingdong cloud server, a code section deals with IP information, so hiding out, afraid of big God is true I do.

Because our goal is not to Linux operation and maintenance engineers, just normal use, some simple common commands enough of our daily operation of Linux.

First, tell us about the Linux directory, because it is to use the root account to log in, so we are in a directory after login /root, query the current directory can use the command pwd, as follows:

Enter the command cd /to enter the root directory, and then outputs the command lsto view the root directory are what directory:

Under general introduction to each directory are put anything:

table of Contents Brief introduction
/bin General common commands in this directory.
/boot For storing various files used when the system boots.
/dev Equipment used to store files.
/etc Generally used to store system management and configuration files.
/home Store root of all user files, is the starting point of the user's home directory, such as users' home directories user is / home / user, you can use ~ user representation.
/lib Deposit with the program running in the file system needed for shared libraries and kernel modules. Dynamically linked shared libraries known as shared libraries, in a role similar to windows .dll files, to store the shared files required to run the root file system.
/usr Used to store system application, the more important the directory / usr / local local system administrator software installation directory (the installation system-level applications). This is the largest directory, use the applications and files to almost all of this directory.
/opt Optional application package is placed additionally installed position.
/root Super user (system administrator) home directory.
/where For the need to change the file data storage operation, the overflow area also some large files, say various services log file (system startup logs, etc.) and so on.

Many directories are used by the system, we need not be concerned, generally use the directory to have /etc(to modify some system configurations, such as changing the host file system environment variables, etc.), /usr(here will install some applications), /opt(here is actually installed some applications).

A few brief command, with these few commands, basically we can operate up happy:

  1. cd: The needless to say it, is to switch directories.
  2. ls: This is the view the directory contents.
  3. pwd: Displays the current working directory.
  4. mkdir: create directory.
  5. vi: edit the document, the command slightly more complex
    1. vi filename : enter general mode (not enter)
    2. Press i from the usual mode, enters into the insertion mode, then the document may be modified
    3. Press esc from insert mode, exit to the normal mode, then the document can not be modified
    4. In normal mode, enter : WQ , save and exit edit; or you can also enter q! Do not save your edits exit.
  6. ps: View Task Manager: PS -ef, for example, view the process of mysql, ps -ef | grep mysql.
  7. kill: this is to kill the process, common formats kill -9 pid (Process ID), with the ps command together with the above, you want to kill kill process.
  8. tar: compression and decompression, decompression commonly used commands tar -xvzf [need to decompress the file name], commonly used compression command tar -cvzf [compressed file name] [compressed file name].
  9. reboot: reboot
  10. halt: Shutdown
  11. rm: delete command, commonly used bomb-level commands rm -rf /; try this command is prohibited in any place, if implemented, will not be reversed, meaning that with the direct delete directories.

Here we demonstrate how to install next to Python3 on CentOS.

Because CentOS itself comes with Python, but the version is Python2.7:

Here we leave it, first go to the official website to find Python Python download address:

Python official website download link: https://www.python.org/downloads/source/

Here is a selection of small series up to now the latest release of version 3.8.0.

Then we switch to xshell user interface start the operation, first switch to the /optdirectory:

cd /opt

Then download Python3.8 installation package:

wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

Here meet new command wget, this command is not available if the CentOS, you need to install it:

yum install wget

Brief, yum is a package management tool in Linux, it can be a simple installation.

Waiting for the progress bar downloaded directly extracted after the download is complete:

tar -xvzf Python-3.8.0.tgz

After extracting compile and install:

# 创建安装目录
mkdir /usr/local/python3
cd Python-3.8.0
# 检查配置
./configure --prefix=/usr/local/python3
# 编译、安装
make && make install
# 创建软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

Test results of the installation:

# 输入
python3 -V
# 输出
Python 3.8.0
# 输入
pip3 -V
# 输出
pip 19.2.3 from /usr/local/python3/lib/python3.8/site-packages/pip (python 3.8)

Because Linux is also dependent on some of the features of Python, we do not cover the current version of Python commands directly create a new Python commands python3. As well as new pip package management commands pip3.

I hope that students can use their own virtual machine to install a CentOS try, the subsequent part will involve Linux.

Guess you like

Origin www.cnblogs.com/babycomeon/p/11925763.html