Unix 简明教程

Linux/Unix Tutorial

这个 Linux 教程是为了让初中级 Linux 爱好者、Linux 系统管理员、Bash Shell 脚本程序员和愿意学习和实践 Linux 的其他技术爱好者轻松学习 Linux 而编写的。

This Linux tutorial has been written to somplify the Linux learning for the beginners to advanced Linux Enthusiasts, Linux System Administrators, Bash Shell Script Programmers and other tech enthusiasts willing to learn and practice Linux.

Linux(Unix 的一个变种)是一个开源计算机操作系统,能够同时处理来自多个用户发送来的请求。虽然 Unix 是 1969 年在 AT&T 贝尔实验室由肯·汤普森和丹尼斯·里奇开发的,Linux 则是在 1991 年由 Linus Torvalds 在他还是赫尔辛基大学的学生时开发的。

Linux (A variant of Unix) is an Open Source computer Operating System which is capable of handling activities from multiple users at the same time. Though Unix was developed in 1969 at AT&T Bell Labs by Ken Thompson and Dennis Ritchie but Linux was developed by Linus Torvalds when he was a student at the University of Helsinki.

What is Linux?

Linux 操作系统最初是为了作为其他现有的但昂贵的操作系统的替代品而开发的,尤其是 Unix、Windows、Mac OS、MS-DOS、Solaris 等。当 Linus Torvalds 在赫尔辛基大学学习时,决定创建自己的操作系统并将其作为开源软件,以便世界各地的用户都可以提出改进建议。

Linux is an operating system which was developed to be used as an alternative to other existing but expansive operating systems specially Unix, Windows, Mac OS, MS-DOS, Solaris and others. When Linus Torvalds was studying at the University of Helsinki, decided to create his own operating system and keep it as Open Sources so that users from around the world can contribute their suggestions for improvements.

Linus Torvalds 于 1991 年开发了自己的内核和一些围绕内核的程序,随后发展成一个功能齐全的操作系统,很快就被企业、大学、其他机构的计算机工程师广泛接受。今天,Linux 已成为最广泛使用的操作系统之一,有各种分支,如 Ubuntu、CentOS、Fedora、Debian、openSUSE、RedHat、MX Linux、Arch Linux 和 Gentoo 等。

Linus Torvalds developed his own kernel and a few programs around it in 1991 which later became a full flagged Operating System and soon it was accepted widely by the Computer Engineers in Corporates, Universities and other Institutes. Today Linux is one of the most widely used Operating Systems and it comes in various variants like Ubuntu, CentOS, Fedora, Debian, openSUSE, RedHat, MX Linux, Arch Linux, Gentoo etc.

Online Linux Terminal

作为一个初学者,你在自己的计算机上安装 Linux 可能面临挑战。为此,我们设置了一个在线 Linux 终端,供你练习基本的 Linux 命令和概念。我们提供了 Online Linux Terminal , 你可以在此直接从浏览器在命令提示符下键入并执行几乎所有 Linux 命令,无需设置你的开发环境。

As a beginner you may face a challenge to setup Linux on your own computer. So we have setup an Online Linux Terminal for you to practice basic Linux commands and concepts. We have provided Online Linux Terminal, where you can type and execute almost all the Linux commands at command prompt directly from your browser without the need to set up your development environment.

我们还提供了一个用于编译 Linux Shell 脚本的 IDE。你可以尝试点击图标 ,运行以下 Bash Shell 代码以打印传统的 “Hello, World!”。

We are also providing and IDE to compile Linux Shell scripts. You can try to click the icon to run the following Bash Shell code to print conventional "Hello, World!".

# Hello World Program in Bash Shell

echo "Hello World!"

Linux Command Prompt

当你登录到 Linux 系统后,你会进入一个屏幕,你可以在其中执行所需的任务,比如创建文件、创建目录、更改当前目录等。

When you login inside a Linux system, you land on a screen where you can perform required tasks like creating a file, creating a directory, changing current directory etc.

此登录屏幕根据系统设置提供提示。大多数情况下,该提示符是一个美元符号 $,不过你可以将它更改为你喜欢的符号。许多 Linux 用户将命令提示符称为美元提示符。

This landing screen gives you a prompt based on your system setting. Most of the time this prompt is a dollar sign $, though you can change it to your favorite symbol. Many linux users call command prompt as dollar prompt.

以下是在我登录后显示的 Ubuntu Linux 的屏幕截图。你可以在美元符号后在此输入命令。

Following is a screen shot of the Ubuntu Linux after I logged in. Here you can start giving your commands after the dollar sign.

Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-91-generic x86_64)

.....

Last login: Mon Apr 22 06:40:08 2024 from 183.82.118.37
$

Basic Linux Commands

在学习 Linux 时,你会学到的基础是 Linux 命令。Linux 命令是用户发送给计算机以执行特定任务的指令。

While learning Linux, the basic thing which you will learn are the Linux commands. Linux commands are the directions given by the users to the computer to perform a particular task.

Create Directory - Example

例如,如果用户想要创建一个目录,那么 mkdir 是在 Linux 中创建目录的命令:

For example if a user wants to create a directory then following mkdir is the command to create a directory in Linux:

# Command to create directory in Linux

$ mkdir testing

Change Directory - Example

如果用户想进入特定的目录,则以下 Linux 命令可以切换目录:

If a user wants to go inside a particular directory then following is the command to change the directory in Linux:

# Command to change the directory in Linux

$ cd testing

cd Linux 命令会带你进入 testing 目录。

This cd Linux command will take you inside testing directory.

List Directory - Example

以下命令列出 Linux 中当前目录中可用的所有文件和子目录:

Following is the command list down all the files and sub-directories available in the current directory in Linux:

# Command to list the content inside a directory in Linux

$ ls -l

Linux Jobs - Admins and DevOps Engineers

今天,Linux 是使用最广泛的操作系统,所有主要公司都在其网站和其他应用程序中运行 Linux 操作系统。这些公司正在寻找 Linux 管理员、Shell 脚本程序员和 DevOps 工程师。在我们于 2024 年编写本教程时,由于 DevOps 和系统管理员中对 Linux 专家的高需求,导致 Linux 专家严重短缺。

Today, Linux is the most widely used Operating Systems and all the major companies are running their websites and other applications on Linux Operating System. These companies are looking for Linux Administrators, Shell Script Programmers and DevOps Engineegrs. When we are developing this tutorial in 2024, there is a high shortage of Linux experts where as market demands more number of Linux Admin etc due to it’s application in Websites Applications, Mobile Applications, Machine Learning, Artificial Intelligence etc.

今天,拥有 3-5 年经验的 Linux 专家要价约为 200,000 美元的年薪,这是 DevOps 和系统管理员最需要的专业知识之一。不过它可能会根据工作地点而有所不同。不可能列出所有广泛使用 Linux 的公司,仅举几个大公司为例:

Today a Linux Expert with 3-5 years of experience is asking for around $200,000 annual package and this is one of the most demanding expertise for DevOps and System Admins. Though it can vary depending on the location of the Job. It’s impossible to list all of the companies using Linux extensively, to name a few big companies are:

  1. Tutorials Point

  2. Google

  3. Amazon

  4. Intel

  5. PayPal

  6. Facebook

  7. IBM

  8. NASA

  9. Netflix

  10. Pinterest

  11. Uber

  12. Many more…​

因此,你可能是这些主要公司的下一个潜在员工。我们已经为初学者和高级程序员开发了出色的学习资料,以学习 Linux,这将帮助他们为技术面试和认证考试做好准备。因此,从任何地方、任何时间开始使用本简单有效的教程学习 Linux,完全按照你的进度。

So, you could be the next potential employee for any of these major companies. We have developed a great learning material for beginners and advanced level of programmers to learn Linux which will help them prepare for the technical interviews and certification exams also. So, start learning Linux using this simple and effective tutorial from anywhere and anytime absolutely at your pace.

Why to Learn Linux?

Linux 是一个开源、通用、强大且安全的操作系统,被全球的开发者、系统管理员和技术爱好者广泛使用。Linux 提供了广泛的发行版,以满足不同的需求和偏好。从 Ubuntu 等轻量级发行版到 Red Hat Enterprise Linux 等企业级系统。如今,各类学校、学院和大学都在教授 Linux,以培养优秀的软件工程师。以下还列举了学习 Linux 的其他重要原因:

Linux is an open-source, versatility, robust and secure operating system which is being used extensively by developers, sysadmins, and tech enthusiasts worldwide. Linux offers a wide range of distributions tailored to different needs and preferences. From lightweight distributions like Ubuntu to enterprise-grade systems like Red Hat Enterprise Linux. Today various Schools, Colleges and Universities are teaching Linux to create great software engineers out of their institutions. There are many other good reasons which makes it important to learn Linux:

  1. Linux is Open Source which means its available free of cost.

  2. Linux is one of the most widely used Operating Systems.

  3. Linux has a great Community Support and Collaboration.

  4. Linux can be used for Cloud Computing, Application Development and Programming.

  5. Linux is very good in demand and ensures high salary

Audience

本教程专为从初学者到高级用户而编写,旨在帮助他们了解从基础知识到高级概念,涵盖 Linux 命令、Linux shell 脚本和各种其他实用程序。

This tutorial has been prepared for the beginners to advanced users to help them understand the basics to advanced concepts covering Linux commands, Linux shell scripting and various other utilities.

Prerequisites

你将学习 Linux 操作系统,涉及实际应用,但我们假设你已经充分了解了操作系统以及它们在理论层面的功能。对各种计算机概念的基本理解也有助于你理解本教程中给出的各种练习。

You are going to learn Linux Operating System in practical but we assume you have adequate exposure to Operating Systems and their functionalities at theoritical level. A basic understanding on various computer concepts will also help you in understanding the various exercises given in this tutorial.

FAQs About Linux

有一些关于 Linux 的常见问题 (FAQ),本部分会尝试简要回答这些问题。

There are some very Frequently Asked Questions(FAQ) about Linux, this section tries to answer them briefly.