Preface
This article is used to record my often used Linux (Debian/Ubuntu) commands.
Suppose we get a server which system version is Debian 11 and only apt installed, because my Hosting Server provides such machines, (because this can save storage?) so we have to install packages we need.
So far, I haven’t used a Linux computer, it’s said that Arch is a good OS for personal computer. If possible, I hope to buy one after work, and experience the difference between Windows and Linux, my plan is to buy it after get the MacBook.
Having said that, the list of things I plan to buy is as follows. (hardwares only)
- Phone
- iPhone
- Pixel
- Computer
- Arch Linux
- MacBook Pro
- PlayStation 5
- NAS
- Router
Do I really need so many computers, and can I really afford the price?
It’s useless to talk, let’s start.
1. Packages
The sorting of these packages has no context,(expect sudo
) write wherever I think.
1.1. Sudo
|
|
The sudo
executes commands as the system administrator, that is, the commands run via sudo
seem to be run by root.
1.2. Git
1.2.1 Install
|
|
sudo apt update
is a very common command, we will use it in almost all commands. If you have experience, you may encounter a command that keeps reporting errors, but you can do it when runsudo apt update
.
We can verify that the installation was successful using git --version
, it will print the following if the installation is successful.
|
|
As of now, the latest version of git
is 2.25.1.
1.2.2 Configure Git
This section is not for novices, because in normal, we don’t need to link GitHub.
Now, we have successfully installed Git, if need to login in GitHub, run the following code.
|
|
1.2.3 Update
|
|
1.3. Curl
|
|
To verify that curl is installed, type curl
in a terminal.
1.4. Python
1.4.1 Install
Here we take Python 3.11
as an example, you can replace it with any version you want to install.
You can find all version in here , and replace the link of you want download.
|
|
1.4.2 Unzip and configure
|
|
1.4.3 Compile
run nproc
to get the number of cores, you need modify the number after -j
of make -j 2
to make it equal with your cores.
Here we assume 2 cores, run
|
|
There we replace
sudo make install
withsudo make altinstall
, becausemake install
will rewriting the system default python version.
1.4.4 Install Python packages
|
|
1.5 Pip
Here we install pip3
as example, all of the commands of pip are python
, and pip3
is python3
|
|
In general, pip corresponds to Python 2.7, and pip3 corresponds to Python 3.x.
If you want update pip version, run python -m pip3 install -U pip
2. Docker
Docker is a very handy tool, i really like it It helps me do many things, for example, my Telegram bot (private) is made by Docker, if you can use Docker well, then you are a good coder.
Of course I am a junior for Docker, only some basic commands.
2.1 Install
2.1.1 Docker
Docker official provides a one-click script, which saves our tedious work.
|
|
If you are live in mainland China, you can use the
mirror
to increase the download speed, by using the--mirror
parameter, for instance, using Aliyun.
1
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
If the user logging in to Linux isn’t root, the docker needs to join the docker group. Run this code
|
|
Log in to the ssh terminal again, and run docker version
to test whether docker is installed. If it’s correct, it will print the following
|
|
If you are using docker for the first time, I recommend running docker run hello-world
, this will help you get started with Docker.
2.1.2 Compose
Docker Compose is a more popular tool than Docker. One you have a Compose file, you can create and start your application with a single command: docker compose up
.
Let’s start the installing Compose
|
|
unname -m
means general version, automatically install the appropriate version for your machine.- Pay attention to replace 2.14.2 with the required version, you can go to Docker Compose releases to find more.
Don’t forget to grant permissions after the download is complete, and move to the correct path.
|
|
2.2 Commands
List Docker containers
|
|
Stop all containers
|
|
Delete all containers
|
|
Delete all images
|
|
Delete specified image
|
|
Summary
For Linux, you need to get used to using the command code to get things done, which is different from Window and MacBook, and you need better trouble-shooting and resolution skills. If you find a problem, I recommend reading the documentation.
Of course, we all use Linux, I believe we all have the sikll.