Complete Ubuntu tutorial, let you become a master of Ubuntu

Ubuntu pronunciation

Ubuntu, derived from the languages ​​of the Zulu and Xhosa people in Africa, pronounces oo-boon-too. Knowing the pronunciation makes sense, you're not the first to be confused by this, and certainly, you won't be the last :) Most Americans pronounce ubuntu with the u as a vowel, similar to who or boo, The accent is on the second syllable i.e. u'buntu, oo-boon-too. If you like the Sahara, like its suffocating tenderness, dreamlike solitude, and unrestrained openness, you can add some buzzing sound after the first u: oom-boon-too. The Chinese pronunciation of Ubuntu is approximately: Ubuntu

1. The meaning of Ubuntu

The word Ubuntu comes from Africa, which means "Bantu spirit" ─ ─ ─ ─ ─ No one is an island, it is a whole of its own. Everyone is conceived in human beings, exists because of the existence of others, and is happy because of the happiness of others.

2. Features of Ubuntu

Ubuntu is completely based on the Linux operating system and can be supported by the community and professional organizations for free. A large community is fertile ground for it to grow, so open your heart to this touching passion.

The Ubuntu community lives by the Ubuntu philosophy: Freedom! Software should be free, should respect the free will of human beings, and there should be no gap between it and human beings. Local languages, functional limitations, and the right to self-improvement... should not be barriers or burdens to use. Freedom makes Ubuntu fundamentally different from traditional proprietary software: free is not something to hide, you have the right to fix it to your satisfaction.

Ubuntu is suitable for desktops and servers. Current Ubuntu releases support PC (Intel x86), 64-bit PC (AMD64) and PowerPC (Apple iBook and Powerbook, G4 and G5) architectures.

Ubuntu includes more than 16,000 kinds of software, but the core desktop system has only one CD. Ubuntu covers all desktop applications, from word processing, spreadsheets to web servers and development and design environments. See the introduction to Ubuntu Desktop and Ubuntu Server for details.

The main features of Ubuntu compared to other Linux distributions:

1. Based on Debian/Linux: use the APT package management system.

2. Compared with Fedora Code: The APT package management system elegantly solves the dependency problem, and can install and upgrade online calmly

3. Compared with Debian: software updates are active, while Debian is more conservative.

4. Compared with Gentoo: Basically no compilation is required, saving labor, time and worry.

enter the system

Enter your user name in the login interface, and then the system will ask you for your password. After entering your password, press Enter and wait for a while, you can enter the Ubuntu system, click the icon in the upper left corner of the desktop, and you can open a menu (or use the Alt+F1 key combination), if you want to exit the system, you can click on this icon. In the launch bar above the desktop, there are some common program start icons. These icons can also be found in the start menu. Now click the FireFox icon , you can use the FireFox browser to surf, or press the Alt+F2 key combination to pop up a run command dialog box. Enter firefox and press Enter, you can also start FireFox, find the terminal in the menu, click it to open a terminal window, you can run commands in the terminal window, or enter commands in the console. Use Ctrl+Alt+[F1~F6], you can switch to console No. 1~6, and use Ctrl+Alt+F7 to return to the graphical interface (you can use Ctrl+Alt+BackSpace to close the graphical interface)

command line prompt

user@ubuntu:~$ is the command prompt, the part before @ is the current user ID, the part between @ and : is your host name, and the part between : and $ is the current path.

Exit system

You can click this icon to log out of the system

You can also enter the command in the terminal or console

stop sudo

The system will ask your password, enter the correct password, you can log out of the system

In later chapters, if we prompt you to enter commands, you can enter them either in the terminal or in the console. You can also use the Alt+F2 key combination if you just start the application.

Install

Zoning concept

First of all, we need to know that the existence of hard disk partitions is determined by the physical characteristics of the hard disk and will not change due to different operating systems.

Please think of a hard drive as a book... Even if you don't like reading, you must be very familiar with it, all books are the same, including the textbooks we use... You must be very familiar

A complete book, usually including title, index, and text.

If you need Linux, you first need to find a book called "linux". The title of the book is equivalent to the MBR in the hard disk, which is the master boot record. The difference is that MBR can be a combination of several titles, similar to "XX Bundle". This part of the content has no practical value yet, you only need a general understanding.

The text is the data recorded in the hard disk, which is also very easy to understand, and has no effect on the installation system, so now let's understand the index

The index is equivalent to the partition table in the hard disk, and each chapter in the book is equivalent to a partition in the hard disk, and its starting and ending page numbers can be found in the index. Just imagine, if you read a book with a tear-off index, you will have a hard time finding the part you want to read. Likewise, without a partition table, the operating system cannot locate data on the hard disk.

Due to historical reasons, the size of the partition table in the hard disk is limited, and can only accommodate up to four partitions (primary partitions). Wouldn't it be terrible if a book's index could only have four chapters at most? Many books have far more than four chapters!

So smart people thought of a workaround, which is to use one of the chapters to store the indexes of other parts. For example, the first chapter is the preface, the second chapter is the index of other parts, we turn to the second chapter

Chapter, huh, here is the second index, because only the first index is limited by four chapters, so the content of this index can be very detailed. The second index is the extended partition in the partition table, which defines

Chapters are the logical partitions in the hard disk, isn't it difficult to understand?

With this in mind, let's take a look at the different representations of Linux and Windows for partitions:

Maybe you are already familiar with Windows, which uses drive letters to represent partitions, such as C: D: E:

, each partition is identified by a drive letter, and the order can be reversed, D:

It doesn't have to be the second partition on your system. (If you assign the last hard drive letter to the second partition, arrange all the drive letters in order, and reinstall the system once, you will understand what is called "header"

It hurts" :)

In Linux, the partition is represented like this

/dev/hda               /dev/hda1          /dev/hda2             /dev/hda5/            dev/sdb1

以 /dev/hda5 为例:

因为在Linux中,每一个设备都是用 /dev/ 文件夹下的一个文件来表示,所以 /dev/hda5 中, /dev/ 表示的是根目录下的dev目录,我们来看剩下的部分 hda5 。

前两位的字母 hd 表示这是一块IDE硬盘,如果是 sd ,则代表SATA硬盘,或者闪存等外设。

第三位的字母 a 表示这是该类型接口上的第一个设备。同理, b、c、d…… 分别代表该类型接口上的第二三四……个设备。例如 hdc 表示第二个IDE接口上的主硬盘(每个IDE接口上允许一个主设备和一个从设备)。

第四位的数字 5,并不表示这是该硬盘中的第5个分区,而是第一个逻辑分区。因为在Linux中,为了避免不必要的混乱,分区的顺序是不能改变的,分区标识则由它们在硬盘中的位置决定。系统又要为所有可能的主分区预留标识,所以 1-4 一定不会是逻辑分区, 5 则是第一个逻辑分区,以此类推。

安装中的注意事项

在Ubuntu系统的安装过程中,您需要选择系统目录的挂载点。

我们知道,安装Windows时,我们可以选择把系统安装在哪一个分区,把系统挂载到分区上。而在buntu/Linux中则相反,我们要把分区挂载到系统中。当我们使用Windows的安装方式,把系统挂载到分区上,我们就不可能把Windows目录放在C盘,而把MyDocuments目录放到其它分区。您或者出于习惯,或者出于数据安全方面的考虑,通常把文档放到其它分区中。但是Windows下很多软件保存文件的默认目录就是MyDocument目录,这就比较不方便。

After the system installation is complete, we can still transfer the MyDocuments directory to other partitions, but it is a bit troublesome, and many friends may not know how to do it... But for any Linux system, of course including Ubuntu, we can install it in the system Then mount the partition to the directory. The /home directory is equivalent to MyDocuments of Windows. We can mount /dev/hda5 to this directory, so that when we save something in the /home directory, it is actually saved in the first in an extended partition. If you install the system again, just mount this partition to the /home directory, then entering the new system is like going home, which is great.

Theoretically speaking, you can mount partitions under any directory, and you can customize the mounting path. But we don't recommend you to do this, because it doesn't make any sense. The mount directory suggested by the system installer is usually also suggested by us. Now let's find out what these directories are usually used for:

/ root directory, the only directory that must be mounted. Don't hesitate, pick a partition and mount it! (In most cases, 2G capacity should be enough. Of course, many things are better:)

Swap swap partition may not be necessary, but according to tradition and taking care of your sense of security, mount it. As long as its capacity is larger than your physical memory, if it exceeds twice the capacity of your physical memory, it is definitely a waste.

/home has been introduced earlier, this is your home directory, usually the files you create are saved here, you'd better assign a partition to it

/usr Application directory. Most of the software is installed here. If you plan to install a lot of software, it is recommended that you assign it a partition as well

/var If you want to do some server applications, you can consider assigning a larger partition to it

/boot If your hard disk does not support LBA mode (I think that is unlikely :), you'd better mount it, if you mount the first partition of the hard disk, it should be safe. Generally speaking, as long as the mounted partition is 100M in size, it is enough

In the file system section, we recommend that you choose: ReiserFS

Maybe you have noticed that in Windows, the drive letter is used to represent both hardware (partitions on the hard disk) and paths in the system. In Linux, the hardware is the hardware, and the path is the path, which will not be confused together, simple and direct!

Linux basics

Shell

Maybe you have already been able to use the GUI (graphical user interface) proficiently, for example, you can use the mouse to double-click an icon to open or execute it.

Let's look at the process: You position the mouse on a program icon on the desktop and press the left button twice. The system reads the position of the mouse pointer, and judges the meaning of the icon under the position, and runs the program or opens the file according to the preset double-click action.

This set of GUI system is a kind of Shell, and its function is to realize human-computer interaction. If we can't control the computer, then the computer is not as fun as the TV, isn't it? The TV can also select the channel (the remote control of the TV is also a kind of human-computer interaction interface, but compared to the computer, it is indeed quite simple:)

Easy to use and intuitive interface are the advantages of GUI, but GUI does not mean simple! Maybe you have a similar experience: there are dozens of program startup icons on the desktop, and you know their names, but finding one is not an easy task.

In my Windows system, the desktop is full of various icons. Whenever I start a program, I am very troubled. Later, I tried a program startup manager such as Sonic Startup, but the effect was not satisfactory.

With my unremitting efforts, this problem was finally solved: Simplify the shortcut name, put it in a specific directory, use the Win+R key combination to call out the run dialog box, and type the shortcut name to run the program. For example, the shortcut of Counter-Strike is cs, I put it in the Windows directory; run the cs command, and you can maintain world peace.

So many shortcuts are all placed in the Windows directory, which is very confusing. Therefore, I created a directory named path on the D drive, and added its path to the path item of the environment variable, and put the shortcut in the D:\path directory. Even if the system is reinstalled, as long as this path is re-added to the environment variable, most of the original programs can be run directly with commands... Many of my friends strongly asked me to help them set this startup method, because it is really convenient: )

In fact, under Linux, all programs can be run through commands. Although Linux also has a GUI, it is not better than the Windows GUI! The above is just a brief introduction to the advantages of CLI (command line interface) over GUI, and there are more benefits of using CLI, which you will gradually realize.

Of course, in your impression, CLI must be very unfriendly, lack of affinity, indifferent and repulsive... There is even a generation gap between you and CLI :)

Order

Frankly speaking, seeing such a long string of orders suddenly would make everyone's hair stand on end.

Maybe you have used DOS and left this impression: Put aside the commands first, just the correct input directory and file name are enough. And DOS is not case-sensitive, if it is case-sensitive like Linux, it would be horrible! ! !

In fact, the Linux command line has a completion function, which is very practical. Suppose there is such a command:

command path/file

If there is only one command starting with c, type c and press the tab key again, the system will automatically complete the rest of the command. As long as c tab is pressed twice, the input of command can be completed.

If there is more than one command starting with c, you can press the tab key twice, and the system will list all eligible options, that is, all commands starting with c. Further input o, if there is only one command starting with co (keep input until the item meets the condition is the only option), press tab again, the command will be completed.

Paths and filenames can also be tab-completed. There is also a way of traversal completion. If your file name is in Chinese and you don’t want to switch the input method; even if there are garbled characters in your file name and you cannot input it, then traversal completion can be used to the fullest. We'll talk about this part later :)

Now let's understand the grammatical structure of the command, this part is very important, you have to look carefully.

We know that any language has a specific grammatical structure, take our Chinese as an example:

We solemnly recommend you Ubuntu/Linux!

Although the syntax of this sentence is simple, it is the sentence pattern used by most command lines. Let's see what's in this sentence:

us

Subject, there is only one executor of the Linux command, so the subject is omitted.

recommend

A verb exists as a predicate. In Linux commands, this part is required. This part is also the most fundamental way to distinguish between different commands, so it is usually written at the top as the command name. You can view the current time and date by typing the date command. (Applications -> Accessories -> Terminal)

Solemnly

Adverbs are used to modify predicates. In contrast, Linux commands can use parameters to fine-tune a program's behavior. In order to distinguish it from the operation object of the command, the - or -- symbol is usually added before the parameter. In principle, after the command name, the position of the parameter can be arbitrary, but in order to develop a good habit, we recommend that you follow the command name directly with the parameter.

您 Ubuntu/linux

Both parts are objects, which are the operands of the command. Most commands have only one operand, and some commands have a double-object structure, with a direct object and an indirect object. For example, copy this command cp (copy)

delimiter

Our Chinese is pictographic and has no separators. But all phonetic characters have delimiters to separate words. Spaces are also used as separators in Linux commands.

cp a /home means to copy the a file in the current directory to the /home directory. (Different parts of the command are separated by spaces, consecutive spaces are considered as one space)

The above sentence, translated into Linux commands, should look like this:

RECOMMENDED -- Sincerely you Ubuntu/Linux (By tradition, "-" is followed by arguments abbreviated as single letters, and "--" is followed by full-word arguments. There are exceptions though :)

Ha, Linux commands are quite simple, right?

Linux program, process

Maybe you will think this way, the sentence patterns of Linux commands are really not difficult, but with so many commands, how do I know what they all do? And in different systems, the commands that can be used seem to be different, which is really confusing...

In fact, Linux commands run programs in the Linux system. As long as you have installed the program, you can run it through commands, and you can use parameters to fine-tune its running status. It can also be run by clicking the start icon, but the start icon cannot conveniently adjust the parameters, which is not very convenient.

As an example:

mplayer -shuffle -loop 3 -playlist mymp3.list

Maybe when you run the above command, the system will prompt you that the command cannot be found, that is because you have not installed the mplayer program. Mplayer is the player that supports the most formats I have ever seen. Almost any multimedia file in a known format can be played with mplayer. It includes a graphical interface front end, which you can find in the menu and run with a mouse click; you can also run its command line version by executing a command.

If you do not have mplayer on your system, we recommend installing one. For program installation, see Software Installation.

In the above command, mplayer calls the mplayer player program. Parameter -shuffle means random play, -loop means loop play, the following 3 is the number of loops, if it is 0, it will play all the time. -playlist Indicates the tracks in the playlist. We can put the mp3 path into the mymp3.list file and let mplayer play them.

A process is a running program, which is a mirror image of the program in memory.

Well, now that you have understood the concepts of Shell, commands, programs, and processes, you have basically understood Linux (the Linux system is really very concise and easy to understand:).

But only know these, you can't use it smoothly. In the next chapters, we will introduce its details further.

Introduction to Linux System

path

Paths are divided into absolute paths and relative paths.

The starting point of an absolute path is the root directory /, for example, /usr/local/bin is an absolute path, which points to an absolute location in the system and is not affected by other factors.

The starting point of the relative path is the current directory. If you are currently in the /usr directory, the location indicated by the relative path local/bin is /usr/local/bin

也就是说,相对路径所指示的位置,除了相对路径本身,还受到当前位置的影响。例如Linux系统中常见的目录 /bin 、 /usr/bin、 /usr/local/bin ,如果只有一个相对路径 bin,那么它指示的位置可能上面三个目录中的任意一个,也可能是其它目录。

如果我告诉您到 bin 目录寻找一个文件,您可能搞不清楚是哪一个 bin 目录。只有当前位置确定,相对路径指示的位置才能够确定。

现在我说, /usr/local 目录下,它的相对路径 bin 中有某个文件,这样就比较明确了。

在相对路径中 . 表示当前目录, .. 表示当前目录的上一级目录。

假设您安装了一个程序,它的主程序没有被放置到上面三个 bin 目录中的任何一个,或者其它系统能够找到的地方,您就得告诉系统,它的可执行文件在哪里。

可以使用绝对路径,例如: /home/user/bin/可执行文件

或者定位到 /home/user/bin 目录,使用相对目录来定位它 ./可执行文件

如果您定位到了它的子目录,比如 /home/user/bin/gui,您可以使用 .. 来表示它的上级目录 ../可执行文件

路径相关命令

cd (change directory) 更改目录。

pwd (print working directory)显示当前路径。

ls (list) 显示当前目录中的文件列表。

请尝试以下操作:

cd /etc 进入“/etc”目录,这里使用的是绝对路径

pwd 显示当前路径,这个命令返回结果“/etc”

cd init.d 进入“/etc”目录的子目录“init.d”,这里使用的是相对路径

cd .. 进入上一级目录“/etc”

cd ../home “/etc” 目录的上一级目录为“/”,它的子目录“home”为“/home”

cd - 回到上一次的目录,我们在“/etc”目录跳转到“/home”目录,所以这次是回到“/etc”目录

cd ~ “~”代表当前用户的“$HOME”目录,也就是“/home/{用户名}”目录。

ls 在任何时候,您都可以使用“ls”命令,来了解当前目录下都有哪些文件。

远程路径:

远程路径的表示方法为 协议://用户名:密码@位置/路径:端口

大多数的远程路径可以使用默认端口匿名访问,由此用户名、密码、端口通常不需要填写。例如:

http://www.ubuntu.org.cn/.../index.html

要求身份验证的远程路径,您可以使用下面的方式访问:

ftp://user:[email protected]:21

软件

Linux中没有注册表这个概念。安装软件,理论上讲,只要拷贝所有相关文件,并运行它的主程序就可以了。

按照传统,一个软件通常分别拷贝到同级目录下的 bin、etc、lib、share等文件夹。

Bin可执行文件,程序的可执行文件通常在这个目录下。在环境变量中设定搜索路径,就可以直接执行,而不需要定位其路径。

Etc配置文件,大部分系统程序的配置文件保存于 /etc 目录,便于集中修改。

Lib库文件,集中在一起,方便共享给不同程序。相较不同的软件单独保存库文件,能够节约一些磁盘空间。

Share程序运行所需要的其它资源,例如图标、文本。这部分文件是专有的,不需要共享;而且目录结构相对复杂,混放在一起比较混乱,所以单独存放。

还有一些软件,占用一个单独的目录,所有的资源都在这个目录中。类似于Windows下的绿色软件,不推荐在Linux系统下这样作。

* 执行时,系统找不到可执行文件(搜索所有路径,资源开销过大,是不现实的),需要定位其位置,像这样 /home/user/bin/可执行文件 ,不够方便。

* 许多系统软件需要协作运行,配置文件分别保存,定位它们非常麻烦

* If the library files used by the program, such as graphics library files, are stored separately, the waste of disk space will be very serious.

For some large-scale software or important applications you deploy, you can install them separately in a folder. (Usually source code installation supports this method, which will be introduced in the software installation section)

configuration method

There is no registry-like system under Linux, and both the system and software can be set through plain text configuration files.

In fact, configuration tools with a graphical interface usually modify configuration files in the form of a graphical interface, which is suitable for setting some relatively simple programs. Imagine if the software had thousands of configurable options, all made into menus... start shaking...

A configuration tool with a graphical interface, which can be regarded as a dedicated editor for a specific configuration file. You can also use a common text editor to edit configuration files, such as Nano, Gedit, Knote, Vim or Emacs, etc. Regardless of the time it takes to read and modify the configuration text, it is even faster to directly modify the configuration file.

If you just want to modify a common option, and modify it frequently, such as the IP address of the host. Using a text editor, you have to find the corresponding configuration file and find the corresponding options in the configuration file, which will waste your time and patience.

Graphical configuration tools are often restricted by various factors, such as the network server does not provide graphical services, and the graphical interface is not stable enough... At this time, you can use the configuration tool of the command line to complete these tasks.

For example: To modify the host IP address, you can use the ifconfig program to execute the following command:

ifconfig eth0 192.168.0.1

In later chapters, if we prompt you to modify a file, such as /etc/fstab, you can open it with any text editor you are comfortable with.

hidden files

Under Linux, the file or folder whose first character is . in the name will be hidden by the system by default.

You can try the following:

cd ~ into your user directory

ls View the list of files in the current directory

ls -a View a file listing of all files (including hidden files).

Now, you can see many files or folders whose filenames start with ., right? They cannot be displayed with the ls command

* If you only want to view hidden files without including these two special directories, you can use the parameter -A of the ls command (ls -A)

* Each directory contains two special directories . and .. . As you probably guessed, . stands for the current directory and .. stands for the previous directory. A directory is a special type of file!

file type

The Linux system mainly judges the file type based on the file header information, and the extension is not the determining factor.

Now use the ls -l command to view the file list in detail format, you will see the following:

total 5

drwxr-x--- 4 user group 4096 Mar 10 00:37 filename

drwxr-xr-x 21 user group 4096 Mar 10 20:16 filename

-rw------- 1 user group 524 Mar 10 00:40 a

-rw-r--r-- 1 user group 24 Jun 11 2000 b

drwx------ 2 user group 4096 Mar 9 11:06 c

A total of seven columns of information are displayed, from left to right: permission, number of files, belonging user, belonging group, file size, creation date, file name

Of particular note is the first column:

drwxr-xr-x

There are 10 positions in total, which can be divided into 4 groups:

d      rwx   r-x   r-x

The first group has only one character:

* d folder * - ordinary file * l link * b block device file * c character device file.

The remaining three groups are the permissions of the belonging user, belonging group, and other users or groups on the file. we look at its format

rwx rwx   rwx

*r is readable *w is writable *x is executable

By the way, they cannot be reversed. If a certain position is empty (-), it means that it does not have the corresponding authority.

Explanation: The executable file under Linux is not determined by the extension (such as .exe), but by its executable permission bit.

permissions

We already know that the permissions of files are divided into three types: r (readable), w (writable), and x (executable), and a file can be targeted at the user, the group, and other users or groups. Set permissions.

This permission management method is flexible, simple, rigorous and clear. Still, in the initial stages, there may be a little discomfort. Because it's ubiquitous, and the Windows permissions management you're used to isn't like that (very messy, useless most of the time, and nerve-wracking when used occasionally).

Use the chmod command to change file permissions and chown to change file ownership. For example:

chmod 755 xxx

chmod a+x xxx

chown user:group xxx is used to change the attribution user of the file, and can also change its attribution group at the same time

chgrp group xxx is used to change the ownership group of the file

755 and a+x in the above command are two types of expressions

We will introduce rights management and user management in detail in the following chapters

Permission to execute commands

Some commands can be executed by ordinary users, but only the root user can execute them successfully. Why?

For example, add a new user useradd to the system

ls -l /usr/sbin/useradd

can be seen:

-rwxr-xr-x 1 root root 56156 2006-04-03 21:37 /usr/sbin/useradd

Obviously all users can execute it?

This is because the useradd command is a tool for modifying the /etc/passwd file. Take a look at this file:

ls -l /etc/passwd

-rw-r--r-- 1 root root 1835 2006-06-24 17:58 /etc/passwd

It turns out that only the root user can write the modification result, and of course there will be no result when the non-root user executes the useradd command.

The identity that executes the order

By default, your command prompt ends with a $, which means you are executing the command as a normal user.

You can use the su (switch user) command to switch other users.

For example su root, switch to the root user, if there is no switching target after the su command, then this command switches to the root user by default.

Now you execute the su command, the system will prompt you to enter the password, please enter the password of the administrator. At this time, you will find that the end of the command prompt has changed to #, and you will execute the command as the root user.

By default, the Ubuntu system will randomly set the root password of the system, which will be more secure. At this time, you can execute the "sudo" command, enter the current user password, and temporarily log in as root

Execute the command as the user. (The premise is that your ID should be included in the sudoer list. The user you created when you installed the Ubuntu system has the "sudo" permission by default)

If you are able to execute the "sudo" command, then you also have root privileges. In the following chapters, if we mentioned "root authority", then you can achieve it through the above two ways

Command Line

Shell、Console、Terminal

In the previous chapters, we mentioned that the remote control of the TV is also a kind of human-computer interaction interface, which can be regarded as a kind of Shell.

But this concept is not accurate. The remote control is just a tool for sending commands to the Shell. After receiving the commands from the remote control, the Shell converts the commands into system commands and the system executes them.

For example, if we press the number key 1 on the remote control, the remote control will send the instruction to switch to channel 1 to the Shell, and the Shell will convert the instruction into the channel 1 that the system can recognize, and the system will execute it, and you can watch the TV program of channel 1 up.

Usually there is only one shell for each TV. For example, some TV systems have the function of "picture in picture", then there is a corresponding function definition in the shell. You can use the "picture in picture" function key on the remote control to turn it on. Assuming your TV does not have this function, there is no corresponding function definition in Shell. Having a remote with a control key for the "picture in picture" function, even if the signal is compatible, you will not be able to use this function :)

You can control the TV without a remote control. If your remote control is lost, you can still go to the TV and use the control panel on the fuselage to control it (equivalent to using a Linux console). But you must not like this unless you want to work out :)

In the Linux system, since the resolutions of the graphical interface and the console are usually inconsistent, there must be a delay when switching. For our Chinese users, the Chinese display under the console is also more troublesome. Moreover, the content displayed on the console is usually not as comprehensive as that displayed on the terminal.

So we recommend you use the terminal to execute commands, it feels a lot like a remote control :)

rxvt-unicode

通常情况下,您买一台电视机,只能获得一个遥控器。虽然它为您的电视机量身定作,能够最大限度发挥电视机的能力,但您却不一定喜欢它。说不定这个遥控器体形太大,持握不方便;或者它体形太小,容易失踪;又或者它的按键要么太硬,要么太软;它的键盘要么太大,要么太小……您一般也可以容忍,毕竟遥控器使用频率并不算高:)

如果您的终端有些地方不讨您喜欢,比如说响应太慢,或者不能正常显示中文……那就难以忍受了,您应该换一个其它的试试。

在前面的章节,我们介绍您使用的终端为Gnome-Termianl,它是系统默认使用的终端,显示中文不错,不过响应比较慢,您可能已经处于水深火热之中了。。。

我们推荐您使用urxvt(mlterm也是不错的选择)

您可以使用 sudo apt-get install rxvt-unicode 命令来安装它。

urxvt 启动它 (urxvt不支持控制台,您得在图形界面下启动它。终端、Alt+F2,建议您在启动栏里新建一个启动图标)

rxvt-unicode还支持“服务器/客户端”的运行模式:

urxvtd 启动一个守护进程daemon(支持控制台)

urxvtc 启动客户端client。多个客户端可以同时连接到一个urxvtd,以达到节省系统资源的目的。

或许您对rxvt的默认设置不满意,您可以修改用户配置文件 ~/.Xresources 来设定它。修改全局配置文件 /etc/X11/Xresources/Xresources ,则对所有用户生效,只有root才可以修改此文件。

这里有一些简单的选项:(以 ! 起始的行是注释,您可以直接拷贝此文件的内容)

!!=============================================================================

!! RXVT-unicode setting

!!=============================================================================

!设置字体分辨率

Xft.dpi:96

!窗口大小

Rxvt.geometry: 80x40+80+80

!颜色

Rxvt.background:#333333

Rxvt.foreground:antiquewhite

Rxvt.inheritPixmap:False

Rxvt.colorBD:yellow

Rxvt.colorUL:antiquewhite

!scroll bar

Rxvt.scrollBar:True

Rxvt.scrollBar_left:True

Rxvt.scrollBar_floating:False

Rxvt.scrollstyle:next

Rxvt.scrollColor:#999999

!screenbuffer

Rxvt.saveLines:30000

Rxvt.color12:DodgerBlue

Rxvt.font:7x14,xft:AR PL New Sung

!The input method is generally set to xim

!inputMethod:xim;except for Scim

!Optional input method style: Root (bottom) OverTheSpot (follow) OffTheSpot OnTheSpot, the latter two not all support

Rxvt.preeditType:Root

Tip: Right-click on the launch bar, add self-launcher, customize program, and you can add your own launch icon.

online help system

You can use the command man or info to read the online documentation of Linux commands. The format of the command is very simple:

man xxx

Most of the command manuals are in English, which may be difficult if your English is not very good. In the following system management chapters, we will try our best to introduce you how to use the commands.

Note: When using the "man" browser, you may use some shortcut keys:

Ctrl+f(orward) turn down one page Ctrl+d(own) turn down half a page

Ctrl+b(ackward) turn up one page Ctrl+u(p) turn up half a page

/ Find q(uit) exit

The above are VI-style keybindings. You can also use Emacs-style keybindings

bash

Well, now we have changed to a remote control, which feels much smoother. Now let's practice and download an mp3:

We use the program wget, which is very reliable and you can rely on it.

首先找到一个可以下载的地址,复制链接,在终端窗口内点击鼠标中键,把它粘贴进去。

现在终端中大概是这种情形:

http://www.download.net/xxx.mp3

按下 Ctrl+a 组合键,我们发现光标移动到了行首。输入 wget 和 空格

wget http://www.download.net/xxx.mp3

回车后,终端中出现一些信息,不一会儿工夫,mp3便下载完成。

使用 Ctrl+a 组合键,我们就不需要使用方向键来移动光标,方向键每次只能移动一个字符,没有效率

您还可以使用 Ctrl+f 向前移动光标, Ctrl+b 向后移动光标, Ctrl+e 将光标移动到行末……………… (键绑定)

Note

Linux的图形界面中,鼠标中键通常执行“粘贴”的操作,如果您的鼠标没有中键,您可以左右键同时按下。

中止正在运行的程序

如果一个命令持续时间很长,以致于不能够进行其它操作,可以使用 Ctrl+c 来强行中止它。

Ctrl+s

出于意外,有时您会按下 Ctrl+s 这个组合键,Shell便被冻结。尝试使用 Ctrl+q 组合键,看能否恢复正常。

键绑定

等等,有必要记这么多快捷键么?都这么复杂!

我们强烈建议您记住,以大幅度的提高操作效率。而且这是readline控件的键绑定,在任何使用readline控件的程序中,您都可以使用它们。例如bash、lftp、gdb等程序;同时,Linux下最著名的Emacs编辑器,也是这种风格的键绑定(其实是readline使用了Emacs风格的键绑定才对),甚至FireFox中,也可以使用类似风格的快捷键!(Linux下主要有两种风格的键绑定,一种是VI风格,另一种是Emacs风格,我们会在 简明VIM教程中介绍)

现在列举一些ReadLine的键绑定,您可以自行尝试。(运行 man readline 命令,来查看ReadLine手册)

先来了解一些约定:

\C-a 表示 Ctrl+a

\M-a 表示 Meta+a Meta键在PC中通常为ALT键

A 表示 Shift+a

(\A in brackets below stands for Alt, and \S stands for Shift)

Move command:

\Ca moves to the beginning of the line Aheah \Ce moves to the end of the line End \Cf moves forward one character Forward

\Cb move backward one character Backward \Mf move forward one word \Mb move backward one word

\Cl clears the screen cLear These two commands can also be understood as the movement command \Cp flip up, the previous command Previous

\Cn Scroll down, the next command Next edit command:

\Cd deletes a character after the cursor \Md deletes a word after the cursor Delete

\BackSpace deletes a character before the cursor \M-BackSpace deletes a word before the cursor

\Ck delete the part from the cursor to the end of the line Kill \Cu delete the part from the cursor to the beginning of the line Unix-line-discard

\C-w删除光标前的一个单词Word              \C-y粘贴(最后删除的对象)Yank            \C--撤消

搜索历史纪录:

\C-r连续使用``C-r``可以查找下一个\M-p           \M-n

补全:

\Tab使用频率最高的功能!\C-o遍历补全(未定义)

\M-? M-=列出所有可能选项,相当于按两次Tab键(M-实际按键为\A+\S+/)

\M-#注释掉当前命令,用于将当前命令暂存于历史纪录列表(\A+\S+3

\M-!补全命令,通常用来补全子命令,例如``sudo``的子命令(\A+\S+1

\M-~补全用户名(\A+\S+`\M-@补全主机名(\A+\S+2

\M-$ completion variable ( \A+\S+4 ) \M- _completion record in history ( \A+\S+- )

\M-* put all possible options on the command line ( \A+\S+8 )

custom key bindings

Keybindings can be changed by modifying the /etc/inputrc file. It is recommended that you use the default keybindings to avoid unnecessary annoyance. Of course, Emacs-style keybindings are generic and may be used anytime.

Add this line to the file to set the keybindings of ReadLine to VI style. (Bash, Lftp and other software using ReadLine take effect at the same time)

set editing-mode vi

Find this line:

$if mode=emacs

Add the following below it

"\C-o": menu-complete

### These two lines are not necessary, it depends on the situation###

"\c-p": non-incremental-reverse-search-history

"\c-n": non-incremental-forward-search-history

Log back into the shell and you can use \Co (Ctrl+o) to traverse completions. If your file name is Chinese, or there are garbled characters, you can use \M-*

Putting all the filenames on the command line and removing the extra is a real pain in the ass! So you can use \Co to iterate through completion, putting all possible options on the command line in turn.

Or use the Vim editor to edit the /etc/inputrc file and use the Ctrl+v key combination in insert mode. Press Ctrl+o, then a ^O character is added to the editing area, which is equivalent to \Co

wildcard

Use ? to represent any single character. For example???lo means there are three characters before lo, which can match Hello

Use * to represent any number of arbitrary characters. For example, *.iso represents all files in iso format.

Note: You can combine traversal completion with wildcards to improve efficiency.

For example:

cd */ traverses and completes only folders

chmview *.chm traverses and completes only the chm file

task management

&---------------------------- Add an & symbol at the end of the command to indicate a background task, for example:

wget http://www.download.net/xxx/mp3 &

;----------------------------------Use; to connect multiple commands, it means that the tasks are executed in order

&&------------------------------Using && to connect multiple commands means that only the previous commands are executed successfully, and the following order to be executed

``-----------------------------------`<command>`, if a command contains ` (the key below the Esc key), then the subcommand will be executed first, and the execution result will be substituted into the upper level command to continue execution. For example, create a file named after the current time:

touch `date +%m.%d_%H:%M:%S`

The touch command can create a file, and its operation object is the output of the date +%m%d%H%M%S command 06.06_06:06:60

This way, we create a file called 06.06_06:06:60 (sixty seconds past 6:06 on June 6th -_-!)

Ctrl+z

Suspend the task in the current shell

At this time, the status of the task is

[1]+ Stopped xxx

Bg------------------------------------------------- Run pending tasks in the background. At this time its state is [1]+ xxx &

Fg------------------------------------------------- Bring background tasks to the foreground to execute jobs

The number in square brackets is the task number of the command, you can use the jobs command to view all background tasks

如果后台运行多个任务,您可以在 bg 或者 fg 后跟任务编号,作为操作对象,例如:bg 2

管道、重定向

>-----------------------重定向符号,它的作用是将命令的输出重定向到一个文件中。比如我们想把命令 ls 的结果保存为 FileList 文件,作一个清单,我们可以使用重定向符号来完成它:

ls -l > FileList

>>----------------------作用与 > 基本相同,不同点在于, >> 以追加的方式,将命令的输出写入文件的末尾。

<-----------------------是从文件到命令的重定向,将文件的内容作为命令的输入。

|------------------------为管道符号,它的作用是将前一个命令的输出,作为下一个命令的输入。假设一个目录下的文件太多,使用 ls命令不能够在屏幕中完全显示,这个时候您可以将 ls 命令的输出,通过管道符号,作为浏览器 less 的输入。就可以使用浏览器的功能翻页、查找:ls -al | less

说明: less 浏览器的键绑定几乎与 man 相同,请参阅 在线帮助系统

脱字符

Shell中的一些功能是通过特殊符号作为控制字符来实现的,上面已经介绍了很多了。这产生一个问题,如果一个文件名中,刚好包含了这些字符,比如 ; ,就很难对它进行操作。使用 less 浏览这个文件

less ;xxx

less 会很快返回一个错误信息,因为并没有一个文件名作为操作对象。接着,Shell会报告,系统中没有 xxx 这个命令。

这是因为Shell将文件名中的 ; 解析为按顺序执行命令。

或者您的文件名以空白起始,而在Shell中,无论多少个空格,都将被解析为一个分隔符。您甚至不是使用命令重命名此文件。

这个时候就要用到脱字符 \ 了,它能够将一个具有特殊涵义的字符转换普通字符。上面的两个任务,可以在文件名中每个特殊字符前加一个 \ ,像这样

less \;xxx

less \ \xxx

less \;\ \&\xxx

Note: You can also use " to enclose the file name, such as less "; &xxx", which is even more convenient in many cases.

The caret can also be used as a line break in the shell, add a \ at the end of a command, and then press Enter, continue to enter the rest of the command on the next line, split a command into multiple lines without affecting its execution (if executed A very long command, please split it into multiple lines for readability)

In fact, the newline character also meets the definition of the caret character. The Enter key has two meanings, one is execution (Enter), and the other is line feed (broken arrow). It is implemented as a control character in the shell, and when the caret is used, it represents a typesetting character for a line break.

Fish

the friendly interactive shell

Just like its name, Fish is a very friendly Shell, highly recommended! Install it with the command sudo apt-get install fish. When finished, run the command fish to switch to fish and exit to return to bash.

Briefly introduce its advantages:

1. Auto-completion, syntax highlighting

By default, bash’s automatic completion only completes commands and paths. If you want to complete variables, parameters, etc., you usually need to use complex key combinations (see the introduction of bash above), even if you can remember them, quickly

It is also a severe test to press these key combinations quickly and accurately. FISH's auto-completion can automatically recognize grammar and complete the correct content. And it has the function of syntax highlighting, such as using MPLAYER to put

MP3:

mpl(ayer) -l(oop) (0)

-sh(uffle) -pl(aylist) (mp3_playlist)

With a burst of key presses, a rather long command is completed.

The prompt given when the completion result is not unique contains a short explanation, so you usually don't need to read the help :) For example:

mplayer -l

After that, automatically complete the parameter as -lo and then give a prompt

-{lo}adidx (Load index from file) -{lo}op (Loop playback) {Cyan text in curly braces}

Its syntax highlighting function is very useful. If the command you entered is correct, it will be displayed in cyan, the correct parameters will be displayed in white, and the wrong ones will be displayed in red.

2. Convenient history search

Or the command above

mplayer -loop 0 -shuffle -playlist mp3_playlist

Use scroll up and scroll down to browse the command history until you find this command, of course that is too slow.

You can also enter a part of the above commands, such as uffle, you can find it by flipping it once

(You can also insert a historical word in the input part by META+turn up)

3. Folder History

dirh (dir history) can display the folder records entered in the current session

Use prevd and nextd to jump

If you have entered the folders 1 2 3 4 5, prevd 4 allows you to jump directly to 1 in 5

4. Other functions

Fish is basically compatible with bash. The key bindings are also very similar, a few key bindings are not consistent, for example:

\Ch Delete a character before the cursor (bash is the backspace key, which is inconvenient)

Modify the file /etc/fish_inputrc and add the following lines:

"\C-n": history-search-forward

"\C-p": history-search-backward

Now use Ctrl+p to scroll up and Ctrl+n to scroll down. If you have already entered characters on the command line, then Ctrl+p is to look up the characters you entered in the history record, and Ctrl+n is to look down, which is very convenient.

Set your default shell

If you have root privileges, you can directly modify the /etc/passwd file. Find the line where your user ID starts

user:x:1000:112:user,,,:/home/user:/bin/bash

The last field is the default shell after login, and /bin/bash is the main program path of the program bash. The path of the fish main program is usually /usr/bin/fish.

All available shells in the system are listed in /etc/shells (/bin/false means that the shell is disabled)

You can also change your default shell with a command like

chsh -s /usr/bin/fish

(need to enter your password)

Tip: You can use the whereis xxx command to find the installation location of the xxx program, see Search for details

Set the search path for commands

Using echo $PATH, you can display the $PATH variable, the output is as follows:

/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/bin/X11 /usr/games /usr/X11R6/bin

It is an environment variable that represents the search path of the Shell when executing commands.

When a command is executed, the Shell will search the path defined by the $PATH variable and run the executable file with the same name as the command. If executable files such as programs and scripts are not in the above path, you must use an absolute path or a relative path to locate the executable file.

For example:

/usr/local/mplayer -menu xxx.rmvb

/etc/init.d/powernowd start

cd /usr/local/ && ./mplayer -menu xxx.rmvb

You can modify the /etc/environment file to set your command search path, find the line starting with PATH

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin"

Add your custom paths in double quotes, separated by : .

Introduction to Ubuntu system

Ubuntu system directory structure

The following is the main directory structure of the Ubuntu directory. You only need to know what files they contain, and you don't need to memorize them.

/ Root directory

├boot/ startup file. All files related to system startup are saved here

│ └grub/ Grub boot loader related files

├dev/ device file

├proc/ kernel and process image

├mnt/ temporary mount

├media/ mount media device

├root/ $HOME directory of root user

├home/

│ ├user/ The $HOME directory of ordinary users

│ └.../

├bin/ system program

├sbin/ Administrator system program

├lib/ system library file

├etc/ System programs and global configuration files for most applications

│ ├init.d/ SystemV style startup script

│ ├rcX.d/ link to start script, define run level

│ ├network/ network configuration file

│ ├X11/ GUI configuration file

├usr/

│ ├bin/ Applications

│ ├sbin/ Administrator application

│ ├lib/ Application library files

│ ├share/ Application resource files

│ ├src/ Application source code

│ ├local/

│ │ ├soft/ User program

│ │ └.../ usually use separate folders

│ ├X11R6/ GUI system

├var/ dynamic data

├temp/ Temporary files

├lost+found/ disk repair file

start process

The Linux system is mainly started through the following steps:

1. Read MBR information and start Boot Manager

Windows uses NTLDR as Boot

Manager, if multiple versions of Windows are installed in your system, you need to select the system you want to enter in NTLDR.

Linux usually uses the powerful and flexible GRUB as the Boot Manager, and we will introduce how to use it in the chapter on boot management.

2. Load the system kernel and start the init process

The init process is the root process of Linux, and all system processes are its child processes.

3. The init process reads the information in the /etc/inittab file , enters the preset run level, and runs the scripts in the folder corresponding to the run level in order. Scripts are usually started with the start parameter and point to a program on the system.

Normally, the startup scripts in the /etc/rcS.d/ directory are executed first, followed by the /etc/rcN.d/ directory. For example, if you set the operation level as 3, then its corresponding startup directory is /etc/rc3.d/.

4. Start the Xwindow server xorg according to the corresponding script in the /etc/rcS.d/ folder

Xwindow is a graphical user interface system under Linux.

5. Start the login manager and wait for the user to log in

The Ubuntu system uses GDM as the login manager by default. After you enter the user name and password in the login manager interface, you can log in to the system. (you can find a link called S13gdm in /etc/rc3.d/ folder)

change runlevel

Find the following in the /etc/inittab file:

# The default runlevel.

id:2:initdefault:

The number 2 in this line is the operating level of the system. The default operating level has the following meanings:

0 Shutdown 1 Single-user maintenance mode 2~5 Multi-user mode 6 Restart

service management

change startup service

In the folder corresponding to the run level, you can see many links to startup scripts whose filenames start with S## and K##. For example:

/etc/rcS.d/S35mountall.sh mount file system

/etc/rcS.d/S40networking enable networking support

/etc/rc2.d/S13gdm start login manager

/etc/rc2.d/S20makedev Create device files

/etc/rc2.d/S23xinetd starts the super process

The init process will take start as a parameter and execute all scripts starting with S## in order of file names. The lower the number in the script name, the earlier it will be executed. For example in

/etc/rc2.d/ 文件夹中, S13gdm 文件名中的数字小于 S23xinetd , S13gdm 将比 S23xinetd 先执行。

如果一个脚本链接,以 K## 起始,表示它将以 stop 参数被执行。如果相应服务没有启动,则不执行该脚本。例如:

/etc/rc2.d/K20powernowd 针对某种硬件的电源管理支持

如果您想禁止某一服务在启动时自动运行,您可以将相应运行级别中的脚本由 S##xxx 重命名为 K##xxx 。

手动控制服务

您也可以手动运行带有以下参数的启动脚本,来控制系统服务。

- start启动      - stop停止      - restart重启

例如:

/etc/rc2.d/K20powernowd start

有时您并不清楚当前运行级别,该运行级别下未必有相应脚本;而且此类脚本的前三位字符并不固定,不便于记忆。这时,可以直接使用

/etc/init.d/ 文件夹中的启动脚本( /etc/rcX.d/ 中的启动脚本链接到 /etc/init.d/

文件夹下相应脚本),这也是推荐的方式。

例如:

/etc/init.d/powernowd start

Note:以上命令的位置并没有包含在环境变量的搜索路径中,所以要输入完整路径。

常用系统服务

acpi-support 高级电源管理支持          acpid acpi守护程序.这两个用于电源管理,非常重要

alsa 声音子系统                   alsa-utils

anacron cron的子系统,将系统关闭期间的计划任务,在下一次系统运行时执行。

apmd acpi的扩展                 atd 类似于cron的任务调度系统。建议关闭

binfmt-support 核心支持其他二进制的文件格式。建议开启                  bluez-utiles 蓝牙设备支持

bootlogd Boot log. Open it cron task scheduling system, it is recommended to open

cupsys Printer subsystem. dbus Message bus system. Very important

dns-clean When using a dial-up connection, clear dns information.

evms Enterprise Volume Management system (Enterprise Volume Management system)

fetchmail mail user agent daemon for fetching mail gdm gnome login and desktop manager.

Gdomap Mouse support in gpm terminal. halt don't touch it.

hdparm is a script to adjust the hard disk, and the configuration file is /etc/hdparm.conf. hibernate system hibernation

hotkey-setup Notebook function key support. Supported types include: HP, Acer, ASUS, Sony, Dell, and IBM

hotplug and hotplug-net plug and play support, more complicated, it is recommended not to touch it

hplip HP printer and graphics subsystem ifrename Network interface renaming script. If you have ten network cards, you should enable it

inetd In the file /etc/inetd.conf, comment out any services you don't need. If the file does not contain any services, it is safe to turn it off. klogd important.

linux-restricted-modules-common Restricted modules support. Modules in the /lib/linux-restricted-modules/ folder are restricted modules. Some drivers, for example, don't need to enable it if you are not using restricted modules.

lvm logical volume management system support. makedev creates device files, very important. mdamd disk array

module-init-tools loads extension modules from /etc/modules, it is recommended to enable it.

networking Network support. It is very important to activate the network by default in the /etc/network/interfaces file.

ntpdate time synchronization service, it is recommended to close it. pcmcia pcmcia device support. powernowd Mobile CPU power saving support

ppp and ppp-dns dial-up connection readahead preload library files. reboot don't touch it

resolvconf auto configure DNS rmnologin clear nologin rsync rsync daemon

sendsigs Send signals during reboot and shutdown single Activate single-user mode ssh ssh daemon. It is recommended to open

stop-bootlogd Stop the bootlogd service in runlevels 2, 3, 4, 5 sudo Check sudo status. important

sysklogd system log udev & udev-mab user space dev file system (userspace dev filesystem). important

umountfs unmount file system urandom random number generator usplash splash screen support

vbesave Graphics card BIOS configuration tool. Save the state of the graphics card xorg-common Set the X service ICE socket.

adjtimex A tool for adjusting the core clock dirmngr A certificate list management tool that works with gnupg.

hwtools irqs optimization tool libpam-devperm A daemon used to repair device file permissions after a system crash.

lm-sensors onboard sensors support mdadm-raid disk array manager

screen-cleanup script to clear the boot screen xinetd an inetd super daemon that manages other daemons

important configuration files

! In any case, before modifying the configuration file, backup it first!

It is recommended to use this command: sudo cp xxx xxx_`date +%y%m%d_%H:%M` .

Of course, this is very troublesome, you can create a new file named bak, the content is as follows:

#!/bin/bash

sudo cp $1 $1_`date +%y%m%d_%H:%M`

Put it in a directory you can remember, such as /home, execute the command sh /home/bak xxx, and you can save the file xxx in the current folder as xxx_yymmdd_HH:MM format

global configuration file

system initialization

/etc/inittab run level, number of consoles /etc/timezone time zone /etc/inetd.conf superprocess

File system

/etc/fstab The file system mounted at boot time /etc/mtab The currently mounted file system

user system

/etc/passwd user information /etc/shadow user password /etc/group group information

/etc/gshadow group password /etc/sudoers sudoer list (please use the "visudo" command to modify this file instead of editing it directly)

Shell

/etc/shell list of available shells /etc/inputrc ReadLine control settings /etc/profile user preferences

/etc/bash.bashrc bash configuration file

system environment

/etc/environment environment variables /etc/updatedb.conf file retrieves database configuration information /etc/issue release information

/etc/issue.net /etc/screenrc screen config

network

/etc/iftab NIC MAC address binding /etc/hosts host list /etc/hostname host name

/etc/resolv.conf domain name resolution server address /etc/network/interfaces network card configuration file

user profile

Only the root user has the right to modify the files in the /etc/ directory. The global configuration file of the application software is usually not modifiable by ordinary users. If you want to adapt the software to meet special needs, you can modify the user configuration file.

The user configuration file is usually a hidden file with the same name as the global configuration file, placed in the $HOME directory, for example:

/etc/inputrc /home/user/.inputrc

/etc/vim/vimrc /home/user/.vim/vimrc

There are a few exceptions, usually system programs

Software Installation

DPKG

In Linux systems, software is usually provided in the form of source code or precompiled packages.

The software source code needs to be compiled into binary machine code before it can be used, and the installation is time-consuming. However, you can adjust the compilation options by yourself, determine the required functions or components, or make some optimizations for the hardware platform.

Precompiled software packages are usually compiled by the software publisher, and you only need to copy the software to the system. Considering the applicability of precompiled software packages, precompiled software packages are usually not optimized for a certain hardware platform. The functions and components it contains are also generic combinations.

In the Ubuntu system, software is usually released as a package file in deb format, which is a precompiled package. In addition to the compiled software, the deb package usually includes the copy path of the software, the dependency record on other software packages, the more general configuration files, and the description, version, author, category, and occupied space of the software.

deb package commands comply with the following conventions:

soft_ver-rev_arch.deb

soft软件包名称ver软件版本号revUbuntu修订版本号arch目标架构名称

例如: azureus_2.4.0.2-0ubuntu2_all.deb

您需要使用 dpkg 命令来管理deb软件包:

dpkg -i | --install xxx.deb 安装deb软件包

dpkg -r | --remove xxx.deb 删除软件包

dpkg -r -P | --purge xxx.deb 连同配置文件一起删除

dpkg -I | -info xxx.deb 查看软件包信息

dpkg -L xxx.deb 查看包内文件

dpkg -l 查看系统中已安装软件包信息

dpkg-reconfigure xxx 重新配置软件包

有些时候,您使用 dpkg 安装一个软件包,系统会提示您该软件包依赖其它软件包。这时,您先安装其它软件包,直到满足依赖关系为止。或者同时安装多个软件包

dpkg -i aaa.deb bbb.deb ccc.deb

APT

如果一个软件依赖关系过于复杂,使用 dpkg

来安装它,并不是一个明智的选择,这个时候您就需要用到APT软件包管理系统。APT可以自动的检查依赖关系,通过您预设的方式来获得相关软件包,并自动

安装配置它。事实上,在多数情况下,我们推荐您使用APT软件包管理系统。

APT系统需要一个软件信息数据库和至少一个存放着大量deb包的软件仓库,我们称之为 源 。 源 可以是网络服务器,安装CD或者本地软件仓库。您需要修改 /etc/apt/sources.list 文件,使APT系统能够连接到 源。

从以下页面中获得网络安装源的列表,并且根据您的网络环境,选择速度较快的源。

http://wiki.ubuntu.org.cn/%E5%BF%AB%E9%80%9F%E......%97/DapperDrake

The APT system mainly includes commands such as apt-get and apt-cache. Usually a compound command, containing several subcommands.

apt-get install xxx install xxx

-d download only -f force install

apt-get remove xxx uninstall xxx

apt-get update Update software information database

apt-get upgrade for system upgrade

apt-cache search Search for packages

Note: It is recommended that you frequently use the sudo apt-get update command to update your software information database

APT system repair

Due to various accidents, the APT system may have problems. Use the following command to try to fix it: apt-get -f install

source package

For most software, we recommend that you use the APT system to install it. In a few cases, for example, a certain software is not released in the deb package format, or you need to customize the software that suits you, you can install it by compiling the source code.

First you need to download the source code package of the software and unpack it into some source code files. And for easy management, it is recommended to move the downloaded source package to the /usr/local/src/ directory and unpack it here.

sudo mv xxx.tar.gz /usr/local/src mobile source package

cd /usr/local/src to enter the "/usr/local/src/" directory

sudo tar -xzvf xxx.tar.gz Unpack the source code

cd xxx_ver/ Unpacked source code directory

There is usually a configure script in the source code directory, which is used to configure the compilation process to be started. you can execute it

sudo ./configure [--prefix=/usr/loca/xxx ......]

It will automatically detect the compilation environment and dependencies of the software, and generate Makefile files.

Use the command ./configure --help with parameters, or read the INSTALL file to see the parameters allowed by this script. For example using

--prefix=/usr/local/xxx parameter, set the software installation directory to /usr/local/xxx/

. (If you must install the software in a separate directory, it is recommended that you install it here)

Now execute the make command, the system will invoke the compiler and the required resource files through the make tool according to the settings in the Makefile, and compile the source code into an object file.

sudo make

Execute the make install command, the make tool will automatically connect the target file and the library file, copy the final generated file to the path set by the Makefile, and complete the activities such as changing the file's attribute and deleting the residual file.

sudo make install

Now, the compilation and installation have been completed. In order to use it more conveniently, a symbolic link needs to be made to the executable file of the program.

sudo ln -sf /usr/local/xxx/executables /usr/local/bin/executables

Tip: In order to compile smoothly, at least the build-essential package needs to be installed.

sudo apt-get install build-essential

Introduction to Xwindow

Xwindow is the industry standard for workstation graphics systems. It has many different implementations. Xorg is used in Ubuntu systems.

(The avant-garde graphical interface system XGL actually replaces the role of the X server, and there is also a matching window manager)

history

Of course, Xwindow has a long history and tradition, but that is beyond the scope of our discussion. There are two things you should pay attention to:

* The original meaning of "X" in Xwindow and Xbox is different. X is just a letter after W. It should be understood in this way. Xwindow is the successor of Window (note that Window is not Windows)

* Also, don't call Xwindows Xwindows, that's sacrilege! All great creations deserve due understanding and respect.

Architecture and Principles

Xwindow uses a server-client architecture. Regardless of the local graphical interface or the remote graphical interface, they all work in the same process. This eliminates the need for separate design and maintenance, greatly improving network transparency.

Native X client ┐ ┌ keyboard

Remote X Client ┼ X Protocol ─ X Server ─ Hardware Specification ┼ Mouse

Remote X Client ┘ └ Display

Xserver

On the server side of the Xwindow system, hardware resources are managed through drivers (hardware specifications).

For example: when we move the mouse, send information to Xserver through the driver:

"Move right 200 points, move up 100 points" (move right up); "Press the left button"...

The Xserver responds as follows:

1. The coordinates of the last mouse stop are 600,500

2. 200 to the right and 100 to the up. Now the mouse is at coordinates 800,600

3. At coordinates 800 and 600, it is the "Close" button of Firefox

4. According to the default action, translate "click the close button of the Firefox window" into "close the Firefox window"

5. Send an "exit" message to the X client Firefox

6. Xserver displays the position and movement of the mouse throughout the process through the display subsystem (graphics card, monitor)

* In fact, sending an "exit" signal to the program is usually done by the window manager... For the convenience of description, the distinction is not made here. Later, we will introduce you to some other details of the window manager.

Most mice don't need special drivers, because they conform to a certain hardware specification, for example: there are four directions of movement and three keys

Xclient

The Xwindow system client realizes the interaction with the Xserver through the X protocol.

For example:

1. Xclient (assuming Firefox) receives the message from Xserver: Input focus within the range of the address bar, "ubuntu.org.cn", press Enter

2. Firefox recognizes these messages as "open the link ubuntu.org.cn" according to the preset action

3. Firefox requests the link "ubuntu.org.cn" from the domain name server. The domain name server converts this request to "http://ubuntu.org.cn/" and IP address 211.148.131.7, and sends it back to Firefox

4. Firefox will display "http://ubuntu.org.cn/" in the address bar (send a request to Xserver, and display this address in the address bar)

5. Firefox asks the address 211.148.131.7 to display the page.

6. Firefox displays the page sent back from the server in the main window

Xprotocol

Xwindow system protocol, rules for communication between Xserver and Xclient

window manager

Window Manager, a special Xclient.

When using a window manager, Xserver does not directly communicate with other Xclients, but relays through WM. When some messages are defined as WM commands, they will be intercepted. For example, Alt+F4 closes the window, drags the title bar...

The message "Open the link ubuntu.org.cn", the specific content is as follows:

Input focus within the range of the address bar, "ubuntu.org.cn", press Enter

Xserver can't directly judge the focus, but like this:

1. Xserver sends location and click information to WM, and WM determines that the activated (topmost) window is Firefox according to the current "focus strategy".

2. Xserver displays Firefox on the top layer and highlights its title bar

3. Click the address bar in the Firefox window, or Ctrl+L, Xserver will send the location information to WM, and WM will send it to Firefox

4. After Firefox judges the current focus, it displays a flashing text input cursor

5. Firefox sends the input cursor to Xserver through WM, and Xserver displays it at the corresponding position on the screen

So, what exactly can a "window manager" do? In fact, all it does is manage windows. For example:

1. The top window will block other windows

2. It is usually an "activated window". According to different "focus strategies", the window manager determines the activated window.

Activates window title bar highlighting, receives most keyboard messages and mouse click messages within the window.

3. In order to be beautiful and easy to distinguish, most windows must have title bars and borders.

For convenience, there are some buttons on the title bar, such as: minimize, maximize, close (these buttons are small windows requested by the window manager)

4. A window can be displayed next to another window without being completely blocked. In order to achieve this, it is necessary to control the position of the window display

5. In order to control the display position of the window, it is necessary to describe the entire screen with coordinates. The best way is to draw a window that fills the entire screen, that is, the root window.

6. Because the root window is the largest, it can completely block any window. In order to avoid this, the root window is always at the bottom.

This vividly explains why it is called "root window"...root

7. There is not necessarily only one root window. Most window managers can use the "workspace" to switch and display multiple root windows

8. Some other Xclient windows are usually placed on the fixed position of the root window, such as the bottom panel, top panel, side panel, program startup icon

9. Some other Xclient windows can be placed on the panel, such as task bar, launch bar, menu...

The task bar can display running tasks with icons, and can also do other miscellaneous tasks, such as automatically mounting USB devices...

start process

We know that init is the root process of linux and the parent process of all processes. Similarly, xinit is the root process of all Xwindow processes

Startx

The startx command can start the graphical interface under the command line. When the startx command is executed, this command is actually executed:

xinit /etc/X11/xinit/xinitrc -- /etc/X11/xinit/xserverrc

Start the Xserver according to the script /etc/X11/xinit/xserverrc, and start the specified Xclient process, such as the window manager, according to the script /etc/X11/xinit/xinitrc

The script /etc/X11/xinit/xserverrc runs the program /usr/bin/X11/X with preset parameters

The /etc/X11/xinit/xinitrc script points to /etc/X11/Xsession, and starts the scripts in the /etc/X11/Xsession.d directory in turn

* You can define the used WM in the user configuration file ~/.Xsession, which has priority over the global configuration file (does not work for GDM sessions)

* When startx starts, no authentication will be performed. Because it starts /etc/X11/Xsession.d/gnome-session instead of GDM session

GDM session

When the Ubuntu system starts, it automatically enters the graphical interface without running the startx command

In some startup levels, the gdm startup script is included, for example: /etc/rc2.d/S13gdm

1. Point to /etc/gdm/gdm-cdd.conf file, load preset visual theme, start /usr/lib/gdm/gdmgreeter (login screen)

2. After the user authentication is completed, start the default window manager /usr/sbin/gdm set in the file /etc/X11/default-display-manager

When gdm starts, it will ask for a username and password, which is the login screen we see (gdmgreeter)

* Scripts for all available login sessions in the /usr/share/xsessions directory

configuration file

X server

The main configuration file for the X server is /etc/X11/xorg.conf

layout

Section "ServerLayout"

Identifier "Default Layout"

Screen "Default Screen" 0 0

InputDevice "Generic Keyboard"

InputDevice "Configured Mouse"

EndSection

* defines the layout logo, screen logo, keyboard logo, mouse logo

module

Section "Module"

Load "i2c"

Load "bitmap"

Load "ddc"

Load "dri"

Load "extmod"

Load "freetype"

Load "glx"

Load "int10"

Load "type1"

Load "vbe"

EndSection

X core font path

Section "Files"

FontPath "/usr/share/X11/fonts/75dpi"

FontPath "/usr/share/X11/fonts/100dpi"

FontPath "/usr/share/X11/fonts/misc"

FontPath "/usr/share/X11/fonts/cyrillic"

FontPath "/usr/share/X11/fonts/100dpi/:unscaled"

FontPath "/usr/share/X11/fonts/75dpi/:unscaled"

FontPath "/usr/share/X11/fonts/Type1"

FontPath "/usr/share/fonts/Chinese/wqy-bitmapfont"

EndSection

Screen

Section "Screen"

Identifier "Default Screen"

Device "ATI Technologies, Inc. RV370 5B62 [Radeon X600 (PCIE)]"

Monitor "DELL E176FP"

DefaultDepth 24

SubSection "Display"

Depth 1

Modes "1280x1024" "1152x864" "1024x768" "800x600" "720x400" "640x480"

………………

EndSubSection

EndSection

* DefaultDepth 24 default color depth

* Available color depth and resolution for SubSection

graphics card

Section "Device"

Identifier "ATI Technologies, Inc. RV370 5B62 [Radeon X600 (PCIE)]"

Driver "fglrx"

Option "KernelModuleParm" "agplock=0"

Video Ram 131072

EndSection

* Identifier graphics card identification

* Driver Graphics card driver (if the graphics interface is not enabled normally, try "vesa" first)

* Option graphics card parameters

* VideoRam video memory size

monitor

Section "Device"

Identifier "ATI Technologies, Inc. RV370 5B62 [Radeon X600 (PCIE)]"

Driver "fglrx"

Option "KernelModuleParm" "agplock=0"

Video Ram 131072

EndSection

Configuration file internal structure

/

├/ "ServerLayout" layout

│├ "InputDevice" keyboard keyboard

│├ "InputDevice" mouse

││

│└/ "Screen" display subsystem

│ ├ "Monitor" Display

│ ├ "Device" videocard

├ "Files" font

└ "Module" module

X client

The following can be found in the /etc/X11/Xsession file

OPTIONFILE=/etc/X11/Xsession.options

SYSRESOURCES=/etc/X11/Xresources

USRRESOURCES=$HOME/.Xresources

SYSSESSIONDIR=/etc/X11/Xsession.d

USERXSESSION=$HOME/.xsession

ALTUSERXSESSION=$HOME/.Xsession

ERRFILE=$HOME/.xsession-errors

* OPTIONFILE=/etc/X11/Xsession.options 设定X进程的启动参数。例如允许用户进程allow-user-xsession

* Xresources X资源文件。许多程序保留了X接口,允许X服务器管理一些视觉选项,例如窗口内的字体,配色等

* xsession X进程。可以设置一些启动时自动运行的程序,也可以用来设定自己的窗口管理器(窗口管理器和桌面环境或者登录管理器是无关的)

字体

freetype渲染引擎

作为Xorg服务器的一个模块,freetype的功能包括读取Truetype字体信息,如大小、分辨率、编码等,并以之为依据渲染字体 -

freetype2.x相对于freetype1.x 增加了抗锯齿等功能 - ( /etc/X11/xorg/conf 的 Module

字段中,可以选择字体渲染模块,建议使用默认的 freetype )

freetype只负责渲染字体。而查找字体,则可以由X服务器、X客户端或者字体服务器来完成。找到字体后,使用freetype引擎就地渲染

X核心字体

X服务器根据X客户端的请求(字符编码),查找字体并进行渲染,然后显示,我们称之为

Xft字体

X客户端自行查找字体并进行渲染,X服务器只负责显示

由于Xft字体的渲染在客户端完成,所以它可以动态的加载,而不需要随同X服务器一同启动

字体服务器

另外还有一种字体服务器模式,例如 XFT字体:当客户端请求字体时,X服务器将请求转发到字体服务器,由字体服务器查找字体,并使用freetype引擎渲染,将结果传回X服务器,X服务器进行显示……

X核心字体

/etc/X11/xorg.conf 中可以配置X核心字体的搜索路径

Section "Files"

FontPath "/usr/X11R6/lib/X11/fonts/misc/"

FontPath "/usr/X11R6/lib/X11/fonts/Type1/"

FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"

FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"

FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"

EndSection

*

When the X client requests the X server to display text, the X server will search for fonts in the order of the above list

For example, when displaying Chinese, if the font in the first path does not contain Chinese, then search the following paths until Chinese fonts are found

*

Please put your preferred font in the front position

To make installed fonts available as X core fonts, add the font's installation path to the list above, using mkfontscale, mkfontdir

Scan the fonts in the folder and generate an index, that's it (it is recommended to use ttmkfdir to generate fonts.scale, copy it as fonts.dir)

For font selection and display style, you can modify the GTK1 configuration file, or define the program separately in the Xresources file

In fact, in our daily applications, the X core font environment is not common, programs using the GTK1 graphics library, certain types of terminals...

* Emacs is such an old-school program... but Emacs23 just added support for xft fonts

XFT font

Xft font related options are configured in the /etc/fonts/fonts.conf file

You can use the fc-cache command to recursively scan the fonts in the following directories (including fonts in subfolders) to create a font cache

/usr/share/X11/fonts

/usr/share/fonts

/usr/local/share/fonts

~/.fonts

* Fields of the /etc/fonts/fonts.conf file

Most X clients that support GTK2 or the Qt graphics library can use Xft font rendering technology

* GTK2 is the graphics library used by Gnome, and Qt is the graphics library used by KDE. Relatively speaking, the GTK2 graphics library is more versatile in the GUI design of the program

To install fonts, just copy the fonts to any of the above directories, and fc-cache -fv refresh the font cache (parameters: -f force refresh; -v display process)

Use the command fc-list to list all available fonts

For font selection and display style, you can modify GTK2 or Qt configuration files, it is recommended to use GUI configuration

* Generally, related programs are included with the desktop environment, such as gnome-font-properties

System Management

some details

Linux is a case-sensitive system, all commands, paths, parameters, variables... are case-sensitive

Use the TAB key to complete the command, no matter what time, pressing TAB a few times will always help

Shell's function keys can help you edit commands more efficiently, please be familiar with its key bindings and use them as much as possible

Command consists of command name, delimiter, parameter and operation object

command name

Identifies the function of the command, such as cp(copy), mv(move), rm(remove)...

Some commands contain subcommands that you can think of as two-word command names, such as "apt" for the package management system:

apt-get install install a software

apt-get remove removes a software

delimiter

Usually it is a space, multiple consecutive spaces are regarded as one space, the following two commands are the same:

ab

ab

Some special symbols are also delimiters, such as pipeline | , redirection > , >> , < , background running & , sequence execution && , ; . You no longer need to use spaces as delimiters when using these symbols, for example:

ls -al|less

It is written in the following form to make it easier for you to read it:

ls -al | less

parameter

Fine tune the behavior of the command, leading with -, usually the first letter of the parameter name. Many software can use the -h parameter to read the instructions, for example:

apt-get -h

You can also use the full name of the parameter, generally guided by --, for example:

apt-get --help

In most commands, using - to guide multiple characters will be treated as multiple parameters, for example:

apt-get -help

will be interpreted as the following command

apt-get -h -e -l -p

The parameters of a few commands do not need to be guided by -, or use - to guide the full name of the parameter, for example:

ps to

/etc/init.d/gdm start

mplayer -loop xxx

When you need to operate on multiple objects, you can use a space separator to separate them:

touch 1 2 3 4 5 6

Multiple objects separated by spaces are treated as a whole and used as an operation object of the command:

mv 1 2 3 4 5 6 /home/

This command takes "1 2 3 4 5 6" as an operation object and moves to another operation object, "/home/" directory

Recursion means repeating the same operation in sub-levels. For example, recursively copying a directory not only copies the current directory and all the files under it, but also recursively copies the subdirectories of the current directory.

format convention

Use [] to indicate optional items, and the actual input is the content in square brackets, for example

ls [-al]

ls is required, and the parameters do not need to be enclosed in square brackets.

Use <> to indicate required items, and the actual input is the content in angle brackets

Use | to indicate or, items separated by | cannot be used at the same time, for example

tar [-z|jc|x vf] <archive file> [source file]

Parameters usually follow the command name, unless necessary, in the command format, we usually omit them

system message

uptime

Online information - time, as shown below

11:27pm up 9 days, 7:12, 3 user, load average: 0.07, 0.12, 0.14

Current system time System running time Current online users System load 1 minute ago 5 minutes ago 15 minutes ago

w

Online information - logged in user, as shown below

01:04:10 up 1:34, 2 users, load average: 0.25, 0.16, 0.11

uptime information

USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT

user tty1 192.168.0.1 23:30 1:33 0.14s 0.12s -bash

Username, login method, source address, login time, dazed time, resource occupation, current task

Tip: w [username] : Display information about a certain user

who

Online information, common parameters

-r run level

whoami

show current username

last

Recent user login information

-<数字> 使用数字作为参数,控制显示条目。例如

last -10 显示10条纪录

uname

系统信息

-s内核名称(默认参数)-a全部-p CPU信息-n主机名

-r内核发行信息(版本号)-v内核版本信息

date

显示、设定系统时间

-u 显示格林尼洛时间(UTC)

MMDDhhmm[[CC]YY][.ss] 设定时间,需要管理员权限。例如: date 12292359

MM 月份 DD 天数 hh 小时 mm 分钟 CC 年份前两位 YY 年份后两位 ss 秒钟

秒钟、年份为可选,例如: date 122923592006.59

+[%X]设定显示格式,以下为date默认输出格式:

date +%Y年%m月%d日%A%H:%M:%S%Z

格式控制            %n 换行             %t 制表符

小时                    %H(00~23) %I(01~12) %k(0~23) %l(1~12) %p(AM|PM)

分、秒                %M分钟(00~59)                  %S秒(00..61)              %T(hh:mm:ss) %r(hh:mm:ss [AM|PM])

%s 从1970年1月1日00:00:00 UTC到目前为止的秒数              %X(%H:%M:%S)                 %Z时区

星期                    %a(Sun~Sat) %A(Sunday~Saturday) %w : 一周中的第几天 (0..6)

Year %Y(0000~9999) %y(00~99)

月作 %m(01~12) %b %h(Jan~Dec) %B(January~December)

Date %d(01~31) %j(001~366)

%x(local format mm/dd/yy) %D(mm/dd/yy) %c

week of the year

%U(00~53) takes Sunday as the first day of the week %W(00~53) takes Monday as the first day of the week

cal

show calendar

file management

some details

The / directory is the root directory of the file system, and all directories are its subdirectories

Absolute paths start with /, relative paths start with the current directory

A directory is a special type of file. If not specified, a file includes files and directories

.. means the upper level directory, . means the current directory, they are two special directories

Link

Create access methods in other paths for the current file. For example, link executable files in other locations in the system to the /usr/local/bin directory, and use commands to call.

ls [path]

Display a list of files in the current directory

--color Different attributes are displayed in different colors (default parameter)

-a show all -i show inode values ​​-l detail

-F show file type suffix dir/link@executable*port file=pipeline file | >

-A show hidden files -R recursively show subdirectory file list -S sort by file size

-t Sort by modification time -u Sort by access time -d Only display directories, do not recursively display files under directories

cd [directory path] | [special path]

switch directory

Directory path can use absolute path or relative path special path:

~ $HOME dir (default) - previous dir..upper dir.current dir

Note: You can define the $CDPATH variable by modifying the /etc/environment file to set the search path for the "cd" command.

pwd

show current path

file <filename>

show file type

-i show mime type

du [path]

Calculate file or directory space usage

-h Humanize display. Automatically display the size of occupied space in units of G , M and K -l recalculate the size of hard link files

-L count symbolic link file size -a show files in subdirectories of current directory -c show number of files

less <filename>

Browse files, use both VI and Emacs-style keybindings. The following are VI style key bindings

Ctrl+f (orward) turn down one page Ctrl+d (own) turn down half a page

Ctrl+b(ackward) turn up one page Ctrl+u(p) turn up half a page / find q(uit) to exit

touch <target file>

Touch to change the time attribute of the file without modifying it. Usually used to create an empty file

mkdir <folder>

create folder

-p < multi-level directory > create multi-level directory by path -m < numerical permission value > set permissions

cp <source file> <destination directory|file>

Copy a source file as a directory file, or copy a source file to a target directory. Multiple source files are separated by spaces

cp <source directory> <destination directory>

Copy the source directory to the target directory, if copying multiple source directories, you need to use the -R parameter

-a is equivalent to -dpr parameter -d keep the link -f force copy, overwrite the target file -i ask the user when overwriting

-p preserve modification time and access permissions -r -R copy recursively (directory => directory) -l create link

-v show process

rm <target directory|file>

delete

-r -R recursive deletion -f force deletion (no confirmation, delete directly. Use with caution!) -i interactive deletion (ask the user)

rmdir <target directory>

When deleting a directory, it is recommended that you use the "rm -r" command

mv <source file> <destination directory|file>

It is equivalent to deleting the source file after cp, and it can also be used as "rename".

mv <source directory> <destination directory>

-r -R recurse

ln <source file> <link>

Link

-s symbolic link -f force link, overwrite target file -i ask user before overwriting

file operation

nano

A simple and lightweight text editor with Emacs-style keybindings.

split <source file> [destination file name prefix]

Divide the source file into several target files according to certain rules. The default filename prefix is ​​x

-< number of lines > split the file by the number of lines -l < number of lines > ditto

-b <bytes> Split files by size. b , k , m can be used as the unit, if no unit is specified, the default unit is b

-C <bytes> split the file by size, and try to keep each line intact

Example: split -C 100k file.split x

cat <filename>

Output file contents. Separate multiple file names with spaces, you can concatenate the contents of multiple files together for output. Merge into one file using redirection

-n adds line numbers to the output -b adds line numbers to the output, empty lines are not numbered

-s Merge two or more blank lines into one blank line

Example: cat xaa xab xac > file.split

sort [-o <output file>] [-t <delimiter character>] [+<start field> - <end field>] [file]

Sort text content

-m to merge files -c to check if the files are sorted -b to ignore the space character at the beginning of the line

-u ignore duplicate lines of content -f ignore case -l ignore non-printing characters -M as month comparison

-d Sort in dictionary order, sort by letters, numbers, spaces, tabs -r reverse output

more

To view the contents of the file, we recommend that you use less

diff <filename>

compare files

cksum [filename]

Calculate the CRC value of the file. If no file name is specified, data is read from the standard input device, for example:

echo xxx | cksum

md5sum [filename] Calculate the md5 value of the file. ditto

authority management

some details

A file mainly contains the following attributes, ls -l

- rwx rwx rwx user group date filename

111 101 101

Wherein, the first group is the authority belonging to the user, the second group is the authority belonging to the group, and the third group is the authority of other user groups. user is the user who belongs to the file, group is the group to which the file belongs, date is the date information, and filename is the file name.

For a folder, you must have its executable permission before you can use the cd command to enter the folder; with read permission, you can use the ls command to view the file list of the folder.

The root user has the highest authority.

You can use 3-digit binary numbers to describe a group of permissions. If the number corresponding to a certain permission is 1, it means that you have this kind of permission, and if it is 0, you don’t have this kind of permission.

Using binary numbers to describe a set of permissions is very intuitive, but 3 sets of permissions need to be represented by 9 digits, which is not convenient enough to use. Therefore, we represent the three sets of permissions using 3-digit octal numbers. Their corresponding relationship is:

r 100 4

w 010 2

x 001 1

The result of adding these three octal numbers can represent the specific content of the group permissions, for example:

7=4+2+1=rwx

5=4+1=rx

755=4+2+1 4+1 4+1=rwx r-x r-x

You can also use a , u , g , o to indicate the attribution relationship, use = , + , - to indicate the authority change, use r , w , x to indicate the authority content,

a All users u Belonging user g Belonging to group o Other users

= With permission + Add permission - Remove permission

r read permission w write permission x executable permission

For example:

a+x adds executable permissions to all users

go-wx removes the writable and executable permissions of the belonging group and other users

u=rwx The attributed user has read, write, and execute permissions

chmod <permission expression> <file|directory>

Change the permissions of the file. The expression of permission can be represented by three octal numbers, or by augo +-= rxw-s

-R recursive

-v show process

-c Like "-v", only show changes

--reference=<reference file or directory> change permissions with reference to specified file

Example:

chmod -R a+x path

chmod -Rv 755 path

chown <belonging to user>[:belonging to group] <file|directory>

Change the attribution user of a file. Username or UID can be used

-R recursively -v show process -c like -v , only show changes

--reference=<reference file or directory> change permissions with reference to specified file

Example:

chown user:admin path                   chown -R user.admin path              chown user path

chgrp <归属群组> <文件|目录>

更改文件的归属群组。可以使用群组名或者GID

参数同上

SUID、SGID、Sticky bit

某些情况下,需要以可执行文件归属用户的身份执行该文件,可以为该文件设置SUID。同样,设置SGID能够以该文件归属群组的身份执行它。

例如:用户自行设定密码。出于安全方面的考虑, /etc/shadow 只能由root用户直接修改。

-rw------- root root /etc/shadow

这个时候,可以为程序 /usr/bin/passwd

设置SUID,当普通用户执行“passwd”命令时,便能够以该程序归属用户root的身份修改 /etc/shadow

文件。而“passwd”程序自身带有身份验证机制,不能通过验证时拒绝执行,从而保证了安全。

ls -l /usr/bin/passwd

-r-s--x--x root root /usr/bin/passwd

我们发现,归属用户的可执行权限位使用 s ,表示SUID。同样,归属群组的可执行权限位使用 s ,表示SGID。任何用户或群组都拥有

其它用户 的权限,所以不需要以 其它用户 身份执行文件,其它用户的可执行权限位便不会出现 s 。该权限位可能出现的属性为 t

,也就是粘着位Sticky bit。

ls -ld /tmp

drwxrwxrwt root root /tmp

粘着位表示任何用户都可能具有写权限,但只有该归属用户或root用户才能够删除

SUID、SGID、Sticky bit也可以像权限一样,使用一个八进制数表示,如下:

4 SUID

2 SGID

1 Sticky bit

通过在“chmod”命令中使用4个八进制数的表达式,如 4755 ,用第一位表示SUID、SGID、或Sticky bit,便能够为文件设置这些特殊权限。示例:

chmod -R 4755 path

lsattr [路径]

查看文件的特殊属性

-a show all -d show only directories -R recurse

Special properties include:

a : for additional purposes only b : do not update last access time c : store after compaction d : exclude from dump operations

i : Do not change files or directories arbitrarily s : Delete files or directories confidentially S : Update files or directories immediately

u : delete except prevention

chattr +|-|=<attribute> <path>

Change file special attributes

-R recursive -V show process

compression decompression

tar -c|x|u|r|t[z|j][v] -f <archive file> [unpacked file]

Pack multiple files into an archive file, which can be compressed while packing. The supported formats are tar (archive), gz (compression), bz2 (higher compression rate, more time-consuming)

-c create -x unpack -u update -r add -t view

-d compare files and files in compressed package -A add tar file to archive file -z use gz compression format

-j use bz2 compression format -v show process -f <filename> filename of the archive

-C < decompression path > Decompress the files in the compressed package to the specified directory

[Unpackaged file] must be filled in when creating and updating

Example:

tar -zcvf xxx.tar.gz xxx/ xxx1 xxx2 xxx3 Multiple files to be packed are separated by spaces

tar -zcvf xxx.tar.gz /home/user/xxx/ is packaged with absolute paths, and absolute paths are also used for unpacking

tar -zxvf xxx.tar.gz Unpack to the current directory by relative path, or unpack by absolute path

tar -zcvf xxx.tar.gz xxx | split -b 1m After packaging, use split to split into multiple files of 1m size

Other parameters

-P When using absolute path compression, keep the root directory "/" -W check -p restore file permissions

-w ask user --totals stats -T <expression> process qualified files

-X <expression> exclude matching files

zip [parameters] <compressed package> <source file>

Pack files in zip format

-r recursively, process all files and subdirectories in the specified directory together -S includes system and hidden files

-y save the symbolic link directly, not the file pointed to by the link -X don't save additional file attributes

-m After compressing the file and joining the compressed file, delete the source file

-<compression level> 1~9, the larger the number, the higher the compression rate

-F Attempts to repair damaged archives -T Checks that each file inside the backup file is correct

-q does not display the command execution process -g compresses the file and appends it to the existing compressed file instead of creating a new compressed file

-u Update the files in the compressed package

-f Update the files in the compressed package. If the qualified file is not included in the compressed package, it will be added after compression

-$ save the volume label of the disk where the first compressed file is located -j only save the file name and its content

-D Do not create a directory name in the compressed file -i <expression> When compressing a directory, only compress files that meet the conditions

-x <expression> exclude files that meet the criteria -n < filename suffix > exclude files with specified filename suffix

-b <缓存路径>指定临时文件目录-d <表达式>从压缩文件内删除指定的文件

-t <日期时间>把压缩文件的日期设成指定的日期

-o以压缩文件内拥有最新更改时间的文件为准,将压缩文件的更改时间设成和该文件相同

-A调整可执行的自动解压缩文件-c替每个被压缩的文件加上注释

-z替压缩文件加上注释-k使用MS-DOS兼容格式的文件名称。

-l压缩文件时,把LF字符置换成LF+CR字符。-ll压缩文件时,把LF+CR字符置换成LF字符。

unzip [参数] <压缩文件> [压缩包中将被释放的文件]

解压zip压缩包文件

-P <密码> zip压缩包的密码-d <路径>指定解压路径-n解压缩时不覆盖原有文件

-f覆盖原有文件-o不经询问,直接覆盖原有文件

-u覆盖原有文件,并将压缩文件中的其他文件解压缩到目录中

-l显示压缩文件内所包含的文件-t检查压缩文件是否正确-z显示压缩包注释

-Z unzip -Z等于执行zipinfo指令-j不处理压缩文件中原有的目录路径

-C压缩文件中的文件名称区分大小写-L将压缩文件中的全部文件名改为小写

-s将文件名中的空格转换下划线-X解压缩时保留文件原来的UID/GID

-q执行时不显示任何信息-v执行是时显示详细的信息

-c将解压缩的结果显示到屏幕上,并对字符做适当的转换

-p-c参数类似,会将解压缩的结果显示到屏幕上,但不会执行任何的转换

-a对文本文件进行必要的字符转换-b不要对文本文件进行字符转换

-x <表达式>处理里排除压缩包中的指定文件-M将输出结果送到more程序处理

7z|7za <子命令> [参数] <压缩包> [文件]

子命令

a添加d删除e解压x带路径解压l列表查看t测试u更新

参数

-m<压缩方式>            -m0=<压缩算法>默认使用lzma                  -mx=<1~9>压缩级别

-mfb=64 number of fast bytes for LZMA = 64           -md=<字典大小>设置字典大小,例如-md=32m

-ms=是否固实压缩-o<输出目录>设置输出目录-p[密码]使用密码

-r[数字]递归,使用数字定义递归子目录的深度-sfx[<模块名称>]使用自解压模块

-si从标准输入设备读入数据-so将数据写入标准输出设备-y所有询问均回答Yes

-w<工作目录>

rar <子命令> [参数] <压缩包> [文件|文件列表|路径]

子命令

x带路径解压e解压到当前目录a将文件添加到压缩包内d从压缩包中删除文件

u更新压缩包内文件f更新压缩包内文件,并添加压缩包内不存在的文件m添加并删除源文件

r修复l列表查看压缩包内文件信息lt更详细信息lb简短信息c添加压缩包注释

cf <文件名> 将文件内容添加为注释

cw <文件名> 将注释保存为文件

t 测试压缩包              rr 添加恢复纪录                  rv 恢复到文件

参数

-p<密码> 设置密码

-m<0~5> Set the compression level, the larger the number, the higher the compression level

search

whereis <program name>

Find the installation path of the software

-b only finds binary files -m only finds help files -s only finds source code -u excludes specified types of files

-f show only filenames -B <directory> find binaries in the specified directory

-M <directory> Find help files in the specified directory -S <directory> Find source code in the specified directory

locate <filename>

Search for files in the file index database

-d <database path> Search the specified database

updatedb Updates the file index database

find [path] <expression>

find files

-name <expression> find files by filename

-iname <expression> Find files by filename, ignoring case

-path <expression> find files by path

-ipath <expression> Find files by path, ignoring case

-amin <minutes> files accessed in the past N minutes

-atime <number of days> files accessed in the past N days

-cmin <minutes> Files modified in the past N minutes

-ctime <number of days> files modified in the past N days

-anewer <reference file> file that was read later than the reference file

-cnewer <reference file> file that was modified later than the reference file

-size <size> Find files according to file size, unit bcwk MG

-type <filetype> Find files by file type. b block device c character device d directory p pipe file f ordinary file l link s port file

-user <username> find files by belonging user

-uid Find files by UID

-group <group name> find files by belonging group

-gid find files by GID

-empty find empty files

grep <string>|"<regular expression>" [filename]

other

echo <string>

echo. More complex strings can be enclosed in ".

-n does not output newlines -E does not parse carets -e parses carets

control character

\ backslash a warning b backspace n newline r carriage return t horizontal tab

clear

remove screen

alias <input content> <actual content>

Alias, to specify an alias for the command to simplify typing. For example:

alias ls='ls --color=auto'

alias ls="l -CF"

You can keep your definitions in the ~/.bashrc file.

export <variable name>

Export the variable as an environment variable and use it together with variable assignment, for example:

export PATH="$PATH:xxx"

Where $PATH represents the original value of the variable PATH

shutdown

Shut down the computer, send a signal to the root process init, change the runlevel to 0 (halt)

-h power off -r reboot -n force shutdown without sending a signal to the init process

-k simulate shutdown , send a shutdown warning to the login -t <seconds> shutdown after N seconds time <time> timing shutdown

-c [ Description information ] cancel shutdown -f ignore file system detection when restarting -F force detection file system when restarting

halt

Shut down the computer. Call shutdown -h to end the system process, synchronize the file system, and stop the kernel.

-n do not synchronize the file system -w simulate shutdown, write /var/log/wtmp records -f do not call shutdown, force shutdown

-p default option, call poweroff when shutting down -i disconnect the network before shutting down

reboot

Restart the computer. Parameters are similar to halt

chroot <path>

Change Root changes the root directory and redefines the session's runtime environment.

User Management

some details

The root user is the root user, that is, the system administrator has all permissions

A user can only have one GID, but can also belong to other additional groups

Important configuration files for user management:

/etc/passwd user name password UID attribution GID name $HOME directory login shell

/etc/shadow username encrypted password password change information password policy

/etc/group group name password bit GID group users

/etc/gshadow group password related files, not important

/etc/sudoers username permissions define permissions

Shadow passwords can be created using the pwconv command to convert passwords in the /etc/passwd file to the /etc/shadow file

su [username]

Switch to other users, and switch to the root user by default. Prompt password is will switch user password

-f fast switch, ignore configuration file -l relogin -m , -p do not change environment variables

-c <command> Execute the command after the switch, and exit the switch

sudo [command]

Execute commands as other users, and execute as root by default. The prompt password is the current user password

-s switches to the root shell -i switches to the root shell , and initializes -u < username |UID> to execute the command

-l show own permissions

passwd [username]

set user password

-d clear password -l lock user -e expire password, change password at next login

-S显示密码认证信息-x <天数>密码过期,最大使用时间

-n <天数>冻结密码,最小使用时间-s更改登录Shell                 -f更改用户信息

示例:

$passwd

Changing password for user

(current) UNIX password: 原密码

Enter new UNIX password: 新密码

Retype new UNIX password: 确认新密码

chsh [-s ] [用户名]

更改登录Shell

usermod <用户名>

修改用户账号

-d <目录>设定$HOME目录-m设定$HOME目录时自动建立

-s 修改用户登录Shell              -l <新用户名>修改为新用户名

-u 修改用户UID                      -g <群组名>修改用户归属群组

-G < group name > modify user belonging to additional group -L lock account -U unlock

-e < expiration time > set user account expiration time -f < buffer days > set how long to close the account after the password expires

-c <string> modify user comments

useradd <username>

new user

-d <directory> set $ HOME directory -m automatically create $HOME directory -M do not automatically create $ HOME directory

-s modify user login shell -l <username> to new user name -u modify user UID

-g < group name > modify the group the user belongs to -G < group name > modify the additional group the user belongs to

-n不建立以用户名为名称的群组-e <过期时间>设定用户账号过期时间

-f <缓冲天数>设定密码过期后多长时间关闭账号-c <字符串>修改用户备注

-D [表达式]更改预设值(预设值保存于/etc/default/useradd文件中)

新建用户规则保存于 /etc/login.defs 文件中

新建用户默认文件保存于 /etc/skel/ 目录中。新建用户时,系统自动拷贝此目录下的文件至新建用户的 $HOME 目录

userdel <用户名>

删除用户

-r删除用户相关文件和目录

id [用户名]

显示用户 UID GID 归属附加群组

finger [用户名]

显示用户信息

进程管理

一些细节

进程一般分为交互进程、批处理进程和守护进程三类。

守护进程总是活跃,在系统启动时通过脚本自动启动,或由root启动,通常在后台运行。

一个进程可以拥有子进程。当父进程终止时,它的子进程也随之终止;而子进程终止时,父进程通常可以继续运行。

init 进程为根进程,所有进程都是它的子进程

ps

显示进程信息,参数可省略 -

aux displays processes in BSD style ( commonly used ) -efH displays processes in System V style

-e , -A show all processes a show processes of all users on the terminal x show processes without a terminal

uShow detailed information fTree displaywFull display informationlShow long list

Example:

ps alx Another common output format

ps aux | less pipes output, view with less

ps aux | grep <keyword> find process by keyword

output field

USER process owner PID process ID PPID parent process %CPU CPU usage

%MEM memory usage NI process priority. The larger the value, the less CPU time is occupied VSZ process virtual size

RSS page file occupies TTY terminal ID STAT Process status

D Uninterruptible Uninterruptible sleep (usually IO) R is running, or a process in the queue

S dormant T stopped or tracked Z zombie process

W 进入内存交换(从内核2.6开始无效)           X 死掉的进程            < 高优先级                 N 低优先级

L 有些页被锁进内存          s 包含子进程              + 位于后台的进程组;

l 多线程,克隆线程 multi-threaded (using CLONE_THREAD, like NPTL pthreads do)

pstree

树状显示进程信息

-a显示完整命令及参数-c重复进程分别显示-c显示进程ID PID   -nPID排列进程

pgrep <进程名>

显示进程的PID

-l显示进程名和进程PID            -o进程起始ID           -n进程终止ID

xkill

在图形界面中点杀进程。执行此命令后,鼠标指针变为骷髅图案(一定看过《加勒比海盗》吧)。在窗口中点击左键杀死进程,右键取消

pkill <进程名>

结束进程族。如果结束单个进程,请用 kill

kill [信号代码] <进程PID>

根据PID向进程发送信号,常用来结束进程,默认信号为 -9

-l [信号数字] 显示、翻译信号代码

-9 , -KILL 发送 kill 信号退出

-6 , -ABRT 发送 abort 信号退出

-15 , -TERM 发送 Termination 信号

-1 , -HUP 挂起

-2 , -INT 从键盘中断,相当于 Ctrl+c

-3 , -QUIT 从键盘退出,相当于 Ctrl+d

-4 , -ILL 非法指令

-11 , -SEGV 内存错误

-13 , -PIPE 破坏管道

-14 , -ALRM

-STOP 停止进程,但不结束

-CONT 继续运行已停止的进程

-9 -1 结束当前用户的所有进程

renice <优先级表达式> <进程表达式>

重新设定进程优先级(无此必要)

优先级表达式:

+|-|=

nice取值范围: -20~19

进程表达式:

-p 通过进程ID进行设定

-g 通过进程群组ID

-u 通过进程拥有者UID设定

top

动态、交互式进程管理器

-c 显示进程启动状态,包括参数、操作对象等;而不只是进程名

-d <秒> 刷新频率。 -d 5,表示5秒刷新一次

-n <次> 刷新次数,然后退出。 -n 5,表示刷新5次后退出;

-b 以批量模式运行,让输出能够使用管道或重定向。但不能进行交互,最好和 -n <次> 参数一同使用

-i 禁止显示空闲进程或僵尸进程;

-p PID 仅监视指定进程的ID;PID是一个数值;

-s 安全模式运行,禁用一些效互指令;

-S 累积模式,输出每个进程的总的CPU时间,包括已死的子进程;

交互命令:

立即刷新

k 交互式杀死进程,提示输入进程 PID (默认发送信号15)

r 设定renice,提示输入PID和renice值

s 改变两次刷新时间间隔,以秒为单位

n 设定显示进程数, 0 为不作限制

i 隐藏空闲进程和僵尸进程

S 切换到累积时间模式

l 开关,在顶部显示 uptime 信息

t 开关,在顶部显示 进程和CPU状态

m 开关,在顶部显示 free 信息

c 显示方式切换: 进程名/进程启动状态

A 按进程启动顺序进行排序。由新到旧

M 按内存占用排序。由大到小

N 以进程ID排序。由大到小

P 按CPU占用排序。由大到小

T 按时间/累积时间排序

f ,F 设定显示字段。设定完成后空格退出

o,O 设定显示字段的排序。大写向前移动,小写向后移动,空格退出

h,? 显示有关安全模式和累积模式的帮助信息

W 把当前的配置写到~/.toprc中;

nohup <命令>

将任务提交到后台,输出附加到 ~/nohup.out 文件。即便用户退出登录,提交的命令仍继续执行。

<命令> &

背景执行此命令,如果用户退出登录,则命令停止执行

<命令1> ; <命令2> ; ......

命令队列,从左向右,依次执行以 ; 分隔的命令

<命令1> && <命令2> && ......

命令队列,从左向右,依次执行以 && 分隔的命令。前一个命令执行成功,后一个命令才能执行

<命令>

挂起当前Shell中的任务

jobs

显示背景任务

bg [任务编号]

将挂起的任务背景执行

fg [任务编号]

将背景任务调到前台执行

计划任务

磁盘和内存管理

一些细节

Linux中,设备用/dev/目录下的文件表示。例如

/dev/hda1 第一块硬盘的第一主分区

/dev/hdb5 第二块硬盘的第一逻辑分区

/dev/sda4 第一块SATA硬盘的第四主分区,或者扩展分区

/dev/null 黑洞设备

关于磁盘设备,详见 分区概念

mount <设备文件> [挂载路径]

挂载文件系统

-t 指定文件系统的类型。通常不必指定,mount自动检测。下面是常用的格式

reiserfs ReiserFS 3.6版

jfs IBM技术

xfs SGI技术(适合高级服务器,桌面用户慎用)

ext3 Linux传统文件系统

vfat fat fat32

ext2 不带日志的ext3

ntfs WINNT

iso9660 光盘

smbfs Windows文件共享

-o [选项1] [选项2] ......

loop 环设备。光盘、ISO镜像等

ro | rw 只读readonly;可读写read-write

sync | async 同步模式|异步模式。决定修改是否立即写入文件系统

atime | noattime 读取时是否修改访问时间。对于写入敏感设备,例如闪存、软盘,建议使用 *noatime*

auto | noauto 自动挂载模式

exec | noexec 是否允许可执行权限

defaults 使用预设的选项 rw, suid, dev, exec, auto, nouser, async

iocharset=UTF-8 指定字符集,可简写为 utf8

codepage=936 指定代码页,可简写为 cp936 西文系统代码页为 437

umask=<权限掩码> 设定权限掩码

uid= 设定归属用户

gid= 设定归属群组

remount 以不同选项重新挂载

-L <卷标> 将带有特殊卷标的分区

Tip

权限掩码

权限=777-权限掩码(三位) | 7777-权限掩码(四位)

假如权限掩码为 022 ,则新建对象权限为 755 rwxr-xr-x

可以使用 umask 命令设置权限掩码

mount -a

挂载 /etc/fstab 文件中定义的所有设备

示例:

sudo mount -t iso9660 -o loop /dev/cdrom0 /media/cdrom

sudo mount -t vfat -o remount iocharset=utf8,codepage=cp936 /dev/hda5 /media/hda5

umount <设备文件> | <挂载路径>

卸载已挂载文件系统

df

查看已挂载文件系统的磁盘空间占用

-a 显示所有文件系统的磁盘使用情况,包括0块(block)的文件系统,如/proc文件系统

-T 显示文件系统类型                  -k 以k字节为单位显示              -i 显示i节点信息,而不是磁盘块

-t <文件系统类型> 显示指定类型的文件系统的磁盘空间使用情况

-x <文件系统类型> 列出不是某一指定类型文件系统的磁盘空间使用情况(与t选项相反)。

-l 只显示本地文件系统

free

查看内存、缓冲区、交换空间的占用

-b 以字节为单位显示数值           -k 以千字节为单位显示数值                -m 以兆字节为单位显示数值

-g 以吉字节为单位显示数值                -l 显示内存占用峰值          -o 不显示缓冲区占用                   -t 统计结果

-s <秒> 刷新频率

sync

同步文件系统。将缓冲区中的数据写入文件系统

fdisk <磁盘设备文件>

分区表修改工具

交互命令:

m 使用帮助                l 查看已知文件系统类型             p 显示分区信息

n 新建分区 (p:主分区 l:扩展分区 参见 分区概念 )          d 删除分区                 t 改变分区类型

w 将改动写入分区表                   q 放弃改动并退出

* 磁盘设备名称为整块磁盘,而不是磁盘中的分区。例如 /dev/hda ,而不是 /dev/hda1

fdisk -l

查看所有磁盘分区信息

cfdisk

更加友善的分区表修改工具

mkfs.<文件系统类型> <分区设备文件>

将分区格式化为文件系统。 文件系统类型

示例:

sudo mkfs.reiserfs /dev/hda1

mkfs <分区设备文件>

-t <文件系统类型> 指定文件系统类型                  -c 格式化前检查磁盘

mkisofs -o <镜像文件> [源文件目录]

用光盘或者文件制作iso镜像

-b 可启动镜像

hdparm <磁盘设备文件>

设置硬盘参数

-d <0|1> DMA mode switch -a <0|1> expected mode switch -t performance test -T cache performance test

-c <0|1|3> 32-bit transfer mode switch -g display cylinder, sector and other information -i -I display disk information

Network and Hardware Management

ifconfig

configure network interface

-a show all network interfaces

ifconfig <network card> up|down

activate|disable network card

Example: ::

sudo ifconfig eth0 up

ifconfig <network card> add [ netmask <subnet mask> ]

Specify the IP address or subnet mask for the network card

route

Configure routing and gateway

route add -net <routing address> gw <gateway address> [ netmask <subnet mask> ] dev <network card>

Specify routing and gateway

route del -net <gateway address> gw <gateway address> [ netmask <subnet mask> ]

Delete routes and gateways

ip

configure network

Child instruction:

link Network card configuration address Configure address. Equivalent to ifconfig route to configure routing. Equivalent to route

parameter:

show display (default) set set add add del delete

Example:

ip link show shows network card configuration

ip link set eth0 name xxx rename network interface

ping

Send ICMP packets to the target address, often used to test the network

-b <broadcast address> ping the entire network segment -c number of times to send packets -s <packet size> default is 64 bytes

netstat

network connection status

-r display routing table, same as route -a all connections -t only display TCP protocol -U only display UDP protocol

-l only display the port that is listening -p display PID and process name -c <seconds> refresh rate

* http/ftp/ssh... is the application layer protocol * TCP/UDP is the transport layer protocol * IP/ICMP is the network layer protocol

lspci

View devices connected to the PCI bus

lsusb

View the devices connected to the USB interface

lsmod

View loaded modules

* All available modules under the /lib/modules/uname -r directory

modprobe <module name>

Concise VIM Tutorial

Introduction to VIM

Most of the editors we use can directly input characters in the editing area, and can complete some control functions through some shortcut keys, such as using the arrow keys to move the cursor, using

BackSpack or Delete keys to delete text, use PgUp and PgDn to turn pages, use Home and End to locate the beginning and end of a line...

And Vim is an editor with modes, the same key has different function definitions in different modes. For example, hjkl enters the corresponding characters in edit mode, but it is equivalent to the direction key in normal mode.

Due to the need to switch modes, Vim is a bit cumbersome to use. But the advantages are also obvious: you only need to place your hands firmly on the typing area, without using such things as direction keys, typesetting keys, small keyboards, etc.

Keys that require your hands to be out of the way increase your efficiency and focus. In fact, when Vim's predecessor, Vi, was born, there were no arrow keys, typesetting keys, and keypads on the keyboard:)

Order

Edit the file with Vim:

vi [filename]

vim [filename]

Teaching mode:

vimtutor [language]

vim tutorial, which is equivalent to using the Vim editor to open the tutorial file in read-only mode. No matter what you do to this file, it will be restored to its original appearance after exiting. The difference from the read-only mode is that it will not remind you without a wink that the current status is read-only mode. You can use it for some practice

You can specify the language of the tutorial file, if there are garbled characters in the local language (ZH_cn), you can try English

vimtutor one

Use Vim to compare file differences

vimdiff [file1] [file2] [other files]...

configuration file

The global configuration file of Vim is /etc/vim/vimrc, the user configuration file is ~/.vimrc, and the behavior comment line starting with ". The configuration items we provide, you can directly add them to the configuration file

You can do some simple configuration on Vim first:

"Set file encoding

set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

"Enable syntax highlighting

syntax on

"color style

colorscheme pablo

"Set the line spacing to take effect in the GUI interface

set linespace=4

"Set GUI options

"set guioptions=gmrLtT m: menu T: toolbar

set guioptions=gmrLt

"Set the number of spaces for Tab key indentation

set tabstop=4

"Set how many spaces the editor treats as an indent

set shiftwidth=4

"Convert indentation to spaces

"set expandtab

"Set the folding method

"set foldmethod=indent

"The following characters will be considered part of a word (ASCII):

"set iskeyword+=33-47,58-64,91-96,123-128

Mode introduction

The common modes of Vim are: normal mode, insert mode, command mode, and we also often use visual mode.

Enter the normal mode when Vim starts; or press the Esc key in other modes to return to the normal mode.

Use the vimtutor en command to enter the tutorial, which is now in normal mode. Just press the j , k , l , h keys a few times, and you will find that the position of the cursor changes.

Press the i key, -- insert -- or -- insert -- appears at the bottom of the editor, and you're in insert mode. Press j , k , l , h casually a few times, you will find that the corresponding characters appear in the editing area, and now you can also move the cursor through the direction keys. You may think that using the arrow keys to move the cursor is not a problem, but after getting used to Vim, you will think that the arrow keys are too cumbersome and cannot be tolerated! Well, now press the Esc key to return to normal mode, and we can use j , k , l , h to move the cursor again.

In normal mode, press the : key (that is, Shift+; ), a : appears at the bottom of the editor, and you enter command mode. Enter a command new after : and press Enter, the editor is divided into upper and lower columns. For convenience, we add a: before the command to indicate the command entered in the command mode, like this

:vnew

A command can be simplified with some rules, the above command can also be written in this form

:vne

Now your editing area must be torn apart, you can use the command ":quit" to close the current column, just use the abbreviation

:q

This command is to exit the editor, if the editing area is divided into multiple columns, it is to exit the current column.

After executing a command (after pressing Enter), the editor will automatically return to normal mode. If you want to return to normal mode without executing the current command, you can press the Esc key.

By pressing the v key, you enter visual mode, and you can use j , k , l , h to move the cursor and highlight selected text.

In fact, visual mode is equivalent to normal mode after highlighting selected text.

The visual mode has sub-modes, the visual line mode for selection in line units, use the V key to enter (that is, Shift+v); and the visual block mode for selection in block units, use the Ctrl+v key to enter.

mode switch

Ok, now let's summarize the method of switching between modes

Other modes ==> normal mode

Esc

normal mode ==> insert mode

i inserts before the cursor I inserts at the beginning of the line a inserts after the cursor A inserts at the end of the line

o Create a new line below the current line O Create a new line above the current line r Replace the current character R Replace from the current character

Normal Mode ==>Command Mode Normal Mode==>Visual Mode v Visual Mode V Visual Block Mode

visual block mode

move

In normal mode you can move the cursor using

j down k up l right hl h left j

You can use other more efficient ways to move the cursor

w Next word initial W Treat special symbols as part of word b Previous word initial B Same as above

e The end of the word E Same as above 0 The beginning of the line ^ The beginning of the line (after the space at the beginning of the line) $ The end of the line

H Top of page M Middle of page L Bottom of page

In other modes, you can use the arrow keys to move the cursor, but we do not recommend you to do that, you can bind the function keys in insert mode in the configuration file

noremap!

noremap!

noremap!

noremap!

………………

<Range of action> <Key position> <Function>

Among them, the keymap bound by map! acts on all modes; the mapping bound by inoremap! only acts on insert mode.

numeric parameter

You can also use numeric parameters to repeat execution. For example

100j Execute the j key 100 times, and go down 100 lines

Or as a jump line number, percentage. See Browse section below

<line number> Ctrl+g jump by line number

mark

You can make a mark at the current cursor for quick return

m<tag name> defines a tag. Tag name as one character

`<tag name> returns tag

mx defines the current cursor position as marker x

`x returns the token x

browse

Turn down a page Turn down a half page Turn up a page Turn up a half page

gg The first line of the file G The last line of the file <line number>G Go to the corresponding line according to the line number

<1~100>% Go to the corresponding line number according to the percentage zz Adjust the line where the cursor is located to the middle of the page

Scroll down a line Scroll up a line

Explanation: gg locates the first line of the file, V enters the visible line mode, G locates the last line of the file, and realizes a function similar to "select all". Press gg V(Shift+v) G(Shift+g) in sequence

edit

x cut current character dd cut current line y copy visual mode selected character yy copy current line

p paste after cursor P paste before cursor u undo redo

Clone the previous line verbatim Clone the next line verbatim

register operation

Vim can cut or copy different fields into different registers, and you can take out the contents from different registers and paste them

"<register name> Press the """ key and another character key to define a register. For example:

"a "1

Operate directly after defining the register

"ayy copies the current line into register a

"ap Paste the contents of register a after the cursor

* Normally, register + ( " + Shift+= ) corresponds to the clipboard under X. You can use "+p to paste into Vim the content you copy in other programs; you can use "+y to paste in Vim Copy the content to the clipboard and paste it into other programs

* When no register is specified, Vim uses "unnamed register" to store the content

search and replace

Press the / key, a / symbol will appear at the bottom of the editor, and then enter a string to search

/ search down? search up

n search next

N search previous

:s/<source string>/<target string> replace source string with target string

:s/<source string>/<target string>/g Replace all matching strings in the current line

:<line number 1>,<line number 2>s/<source string>/<target string>/g Replace in the specified line

:%s/<source string>/<target string>/g full text replacement

regular expression

When searching and replacing, you can use regular expressions to match

macro

You can record a sequence of actions as a macro and execute it

q<macro name> Start recording a macro. Macro name as one character

q Press the "q" key during recording to end the recording

@<macro name> Execute the macro

Shortcut keys in insert mode

<register name> Enter the specified register content

<2 characters> Enter a digraph

<Number> Enter characters by numeric encoding

<key> Enter the name of the key

keybindings, abbreviations

We've introduced you to key bindings earlier,

map!

The angle brackets and the content in them are the conventions of the Vim configuration file, which respectively describe the keys and functions, indicating that the functions are written on the keys. If only ordinary characters are bound, for example:

map! xxx XXXXX

It means binding fXXXXX to xxx. When you type xxx, the editor automatically replaces it with XXXXX.

If you just want to bind strings to abbreviations for easy typing, we recommend you use iabbrev for binding. For example:

iabbrev for Ubuntu

Type ubt in insert mode and the editor will automatically replace it with Ubuntu. You can abbreviate the iabbrev command to iab, for example:

iab ubuntu

You can enter the above commands directly in the command mode to enable them temporarily. It can also be written to the configuration file to enable it permanently.

word completion

next match

previous match

You can define the completion method in the configuration file

"Auto-completion methods: (comma-separated)

set complete=k,.

" . current file

" b has been buffered, but there is no file in the window

" d defined in the current file and included by #include

" i files included by #include

" k files defined by the dictionary option

" kfile file named {file}

" t tags file

" u no buffer loaded

" w Files in other windows

"Set autocompletion dictionary:

set dictionary=path

命令模式

前面介绍了普通模式和插入模式。我们发现,普通模式主要用来浏览和修改文本内容,而插入模式则用来向文本中添加内容。

而命令模式则多用于操作文本文件(而不是操作文本文件的内容),例如保存文件;或者用来更改编辑器本身的状态,例如设定多栏窗口、标签或者退出编辑器……

w(rote) 将更改写入文件

:w

q(uit) 退出编辑器:

:q

某些情况下,编辑器会阻止命令的执行。例如您修改了文件,而没有保存,那么您使用 :q 命令退出时,编辑器就不会执行这条命令,而是提醒您保存文件。

这个时候,您可以在命令末尾追加 ! 来强制执行命令

:<命令>!

例如 :q! ,即便您没有保存已修改的文件,使用此命令,编辑器也会放弃修改而强行退出

以 ! 引导一个Shell命令,则可以从Vim临时切换到Shell中,执行一个Shell

:!<命令>

例如 :!ls

多栏窗口

您可以使用以下命令,将当前窗口水平分为两栏

:new

新建一栏空白窗口

:split

将当前文件分两栏显示

同理,您可以使用下列命令,将当前窗口垂直分为两栏

:vnew

:vsplit

先按下 键,再按下方向键 j 、 k 、 l 、 h ,您可以切换到其它栏;在当前栏中使用 :q 命令,可以退出当前栏,也可以使用其它命令,对当前栏作出修改

如果您希望当前命令在所有栏中生效,您可以在命令的末尾追加 all

:<命令>all

例如:

:qall

如果您希望这条命令强制执行,那么 ! 位于命令的最末

:<命令>all!

例如:

:qall! 强行退出所有栏窗口

标签页

Vim在7以后的版本,开始支持标签页的功能

:tabnew 新建一个标签

:tabnext 转到下一个标签

:tabprevious 转到上一个标签

多数情况下,您可以使用鼠标点击标签进行切换。

引导管理器Grub

硬件基础

一块硬盘,它起始的一部分扇区为主引导扇区,包括MBR(主引导纪录)和DPT(分区表,您可以阅读分区概念章节中相关内容)

每个分区起始的一部分扇区,为分区引导扇区。

在分区引导扇区之后的部分,为文件系统的索引,文件系统通过它定位文件在硬盘上的位置。不同的文件系统采用不同的索引,例如FAT文件系统使用文件分配表和目录区。

绝大多数操作系统,对硬盘的读写操作,通过文件系统来完成,因此引导扇区中的内容,我们不能够在文件系统中进行操作,而需要专用软件,比如引导管理器。

我们对文件进行修改后,操作系统会将文件系统索引中的内容同步。

系统引导流程

1.系统启动时,首先引导至MBR,将控制权移交安装在MBR中的引导管理器

(Windows使用NTLDR,Linux通常用Grub)

2.引导管理器读取分区表

3.引导管理器读取分区中的配置文件,并按配置文件中预设的参数运行

例如,Grub读取“/boot/grub/menu.lst”文件中内容,将可引导系统通过菜单显示

4.引导管理器根据您的选择,可能会有如下活动

加载内核,启动Linux系统检查活动分区,并引导它(单一Windows系统)读取相应分区的引导扇区,将控制权移交该扇区中的引导管理器,Ubuntu系统在安装Grub时,会提问您安装在MBR或者分区引导扇区中。如果将Grub安装在分区引导纪录中,您必须确保MBR中的引导管理器能够正确的引导至分区引导扇区。

如果您在MBR中使用的是Windows的引导管理器NTLDR,完成这件工作会非常困难,因而我们推荐您使用Grub。

Grub介绍

Grub主要有以下功能:

菜单式选择

命令行模式

支持开机画面

支持大硬盘

其它的功能还有很多,就不一一介绍了。

您可以运行命令 grub 启动它。会显示一些版本信息和使用提示,当然还有命令提示符,如下:

GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For

the first word, TAB lists possible command

completions. Anywhere else TAB lists the possible

completions of a device/filename. ]

grub>

You can use the TAB key to complete commands and paths, which is very important, because the path representation in Grub is different from that of the operating system, and you may be unfamiliar with it, so try to use TAB to complete it, which is convenient and less error-prone.

You can press TAB at the grub> prompt and all available commands will be displayed.

Hehe, are you a little dizzy, there are so many commands! ! !

In fact, there are only two commands we will use,

root

setup

Grub Terminology

In the partition concept chapter, we have introduced the method of representing partitions in the Linux system /dev/hda5

/dev/hdMN M is a lowercase letter starting with a, indicating the hard disk serial number; N is a number starting with 1, indicating the partition serial number

The representation method used in Grub is hd0,1

hdX, YX is a number starting from 0, indicating the serial number of the hard disk; Y is a number starting from 0, indicating the serial number of the partition

You need to be aware of the difference between them:

N counts from 1, X and Y start counting from 0

N is 1~4, it is a primary partition; N is 5 or greater than 5, it is the (N-4)th logical partition. Y is in the order the partitions are arranged on the hard drive, whether it represents a primary or a logical partition.

for example:

master master logic master

/dev/hdMN hda1 hda2 hda5 hda6 hda3

hdX,Y hd0,0 hd0,1 hd0,2 hd0,3 hd0,4

Now let's look at the use of the root and setup commands:

grub>root (hd0,1)

This command locates Grub's root partition as "(hd0,1)"

grub>setup (hd0)

This command means to install Grub in "(hd0)", because there is no partition specified for installation, so the installation location is MBR

The root partition of Grub is the partition where the Grub configuration file /boot/grub/menu.lst is located. If you mount a separate partition for the /boot directory, then the root partition of Grub is usually the partition where the /boot directory is located in your system.

If you get the root partition wrong, Grub can't read the configuration file correctly, and naturally it can't boot correctly.

Boot partition, the boot partition of Windows and other systems is its installation partition, and the boot partition of Linux system is the partition where its /boot directory is located

The partition where the system root directory is located, and the mount partition of the Linux root directory /. The partition mount information of the Linux system is stored in the file system allocation table /etc/fstab file

Grub first reads /boot/grub/menu.lst in the root partition

file, and go to the boot partition, if it is a system like Windows, then move control to the boot manager in the boot sector of the partition. If it is a Linux system, load the kernel and device, and according to

The contents of the /etc/fstab file mount the file system.

Look at this example: (assuming Grub is installed in MBR)

title Ubuntu

root (hd0,0)

kernel (hd0,1)/boot/vmlinuz-2.6.15-25-686 root=/dev/sda3 ro splash vga=0x31b

initrd (hd0,1)/boot/initrd.img-2.6.15-25-686

boot

The installation location of Grub is (hd0)

root (hd0,0), this line indicates that the root partition of Grub is the first partition (hd0,0) of the first hard disk, and it reads the configuration file grub/menu.lst in this partition

(hd0,1) in the line of kernel and initrd means that the /boot directory of the current system is mounted to the second partition (hd0,1) of the first hard disk

The root=/dev/sda3 in the kernel line means that the / directory of the current system is mounted to the third partition (hd0,2) of the first hard disk, and the kernel mounts the file system according to the /etc/fstab file in this partition

Grub configuration file

The /boot/grub/menu.lst file is mainly composed of some blocks like the following

title Ubuntu

root (hd0,2)

kernel (hd0,2)/boot/vmlinuz-2.6.15-25-686 root=/dev/sda3 ro splash vga=0x31b

initrd (hd0,2)/boot/initrd.img-2.6.15-25-686

boot

title Windows xp

root (hd0,0)

makeactive

chainloader +1

Each block represents an operating system, including the following parts

title xxx title, the content after title and separator is the entry displayed in the Grub menu

root (hdX,Y) Boot partition, can be left blank, the default is the partition where grub/menu.lst is located (root partition), can be set using the grub>root (hdX,Y) command, or automatically set when you install the system

If you plan to boot to the partition boot sector, such as Windows or Unix systems (Unix and Linux systems, you need to choose to install the boot manager into the partition), then you need to configure it like this

makeactive Set the active partition, the system default setting, can be deleted

chainloader +1 chain boot, don't touch it.

If booting the system in this way, the line above root (hdX,Y) usually needs to be configured, where (hdX,Y) is the partition where your system is located. If your Windows is the first partition of the first hard disk, then write root (hd0,0) like this

If you are booting a Linux system (without installing a boot manager in the partition, but to the MBR), you need to configure it like this

kernel (hd0,2)/boot/vmlinuz-2.6.15-25-686 root=/dev/sda2 ro splash vga=0x31b

initrd (hd0,2)/boot/initrd.img-2.6.15-25-686 Device image file, consistent with the previous line

boot don't touch it

The kernel line is the most critical, it controls the loading of the system kernel. At the end of the line, the part starting with ro is used as a parameter (ro is read-only, splash displays the startup screen, and vga sets the resolution of the startup screen)

The previous part can be written in this form:

kernel (hdX,Y)/boot/vmlinuz root=/dev/sdMN

(hdX,Y) is usually not necessary. If you have installed multiple Linux systems, or the /boot``directory and the root directory``/ are not in the same partition, you should write it as the partition where the /boot directory is located. And the following root=/dev/sdMN is the partition where the system root directory / is located.

The (hdX,Y) of the initrd line is consistent with the previous line.

Grub installation

The installation of Grub has been introduced to you above, but more emphasis is placed on theory. Now let's practice it, assuming your system can't boot, you can try the following method :)

1.

1. Find an Ubuntu LiveCD (Knoppix is ​​also a good choice)

2. You can also use the installation CD, enter linux rescue at the boot prompt after startup, and press Enter to enter the rescue mode.

2. If you have root authority, the command line prompt is #, and if you are a normal user, it is $.

1. In rescue mode, usually you already have root privileges

b. If it is a LiveCD and does not have root privileges, enter su in the terminal

The command to switch to root will ask you the root password. If you don't know the root password, you can use this command sudo su

, as long as you know your password and your ID is in the sudoer list.

3. Enter grub in the terminal to enter the Grub prompt interface

a. Enter the command root (hd and press the Tab key, all available options will be listed on the screen. For example, mine is like this:

Possible disks are: hd0 hd1

This means that I installed two hard drives, if you only have one hard drive, it must be hd0.

Enter 0 after root(hd, press Tab, and a , will be added automatically, and now your input becomes like this:

root(hd0,

Press Tab again and all available options will be listed, mine is like this.

Possible partitions are:

Partition num: 0, Filesystem type unknown, partition type 0x7

Partition num: 1, Filesystem type is fat, partition type 0xc

Partition num: 2, Filesystem type is reiserfs, partition type 0x83

Partition num: 4, Filesystem type is reiserfs, partition type 0x83

Partition num: 5, Filesystem type unknown, partition type 0x82

Partition num: 6, Filesystem type unknown, partition type 0x7

Partition num: 7, Filesystem type is fat, partition type 0xc

Enter your choice, such as 1, after Tab once, the result is like this:

root (hd1,1)

Enter now

2.

input the command

setup (hd0)

install grub in mbr

3. The quit command exits GRUB

Grub uses

Command Line

In the Grub boot menu, you can select the option you want, press the e key to enter the command line mode

Modify your startup parameters, press Enter after completion

Press the b key and Grub will boot the system with your modified parameters.

other

In the Grub boot menu, press c to enter command line mode

Press d to delete the currently selected item

FAQ

Where did my D drive go?

During the first few days of using Linux, I felt a little uneasy.

Under Windows, I can install the system on the C drive, the software on the D drive, and the music on the E drive... If there is a problem with the system, I just need to reinstall the system, and most of the software can be used directly (developed using

Using green software is a good habit :), and my painstaking collection of movies and music, I always put them in a safe place, so as not to cause serious consequences of insomnia.

In fact, the hard disk under Linux also has the concept of partition, which is no different from Windows (the concept of partition is generated by the physical characteristics of the hard disk, not the operating system). The difference is that Linux can mount the partition to any directory, unlike Windows, your partition can only be in "My Computer" :)

So is there any benefit to doing this?

Let's take a look at the representation of paths under Linux and Windows:

Windows C:\Documents and Settings\Users\Documents\MyDocument

Linux /home/User/MyDocument

You must have noticed that under Windows, the path contains the drive letter "C:", which usually represents the first partition on your hard disk. That said, when working with these files, you need to know where they are on your hard drive

The relevant physical details of the storage. But under Linux, you don't need to know these, or in other words, as long as you set the directory to mount the partition, you don't need to bother about any partition.

The path under Windows includes three parts: partitions, directories, and files; while the path under Linux only contains directories and files, without any partition information, and its hardware abstraction is higher!

The directory under Linux is represented by "/", is this not standard? ?

Quite the contrary, this is the embodiment of the standard. You're just used to Windows' directory notation, but that doesn't mean it's standard.

Take a look at the representation methods of various locations and paths under Winodws:

http://www.ubuntu.org.cn

ftp://192.168.0.1

c:\Windows\

file:///C:/Windows/

\127.0.0.1\$C

……………………………………………………………………

The operating system is a very sophisticated high-tech product, how could it be so confusing! ! ! How did they do it? ? ?

There are fewer viruses under Linux because there are fewer users of Linux. Hackers are obviously unwilling to waste their energy attacking an operating system that no one uses.

You may already know that a large part of the servers used for important purposes on the Internet are Linux systems, and the other part is Unix systems:) If hackers can get rid of the Linux system, the entire Internet will be paralyzed! The effect seems to be better.

Of course, you must think: Hackers are human beings, and they also like to surf the Internet. Rabbits don’t even eat grass beside their nests... Rabbits are so stupid that even tortoises can’t run away... Hackers are much smarter than rabbits!

Yes, I admit that...but they don't necessarily have to kill the Internet. Many hackers dream of invading the servers of the U.S. military. As long as the top-secret data in the U.S. military servers is 1kb, you should be able to buy a top-level personal computer:)

If possible, why don't hackers hack into the servers of the US military, but hack into your computer?

This is a very interesting point of view, and in contrast to it, another argument is also eye-catching: Windows servers account for xx% of the server operating system.

Perhaps this phenomenon can be explained by the 80:20 rule :)

Windows, which accounts for 80% of the total number of servers, provides 20% of the total number of services!

Please do note that this is just an example, Windows servers will probably never account for 80% of the total number of servers! The service it provides, from my personal point of view, I don't think it can reach 20%, and there will never be that day.

Software installation is cumbersome

Maybe you have read some articles about Linux software installation, but don't ignore that the number of such articles cannot be compared with similar Windows articles.

Of course, using the source code package to install software is indeed a bit troublesome, but it is not necessarily more complicated than some software under Windows. In particular, Ubuntu's package management system provides you with an efficient and fast

With the software management method, you only need to know what software you need, and you don't even need to care which server it is stored on the network, and most software can be installed in this way.

See APT for details

If you have the following needs, you can also try to install the software in the form of source code:

You need technical preview versions of some software

You want to test the computing power of your machine

You can't find a better way to kill time than installing software

The confidentiality of the source code is not strong, and there are security risks

Since the software under Linux is open source, will it cause some security risks? Let's say a hacker finds a bug in it and exploits it?

The fact is just the opposite. Even if a piece of software is not open source, hackers can find loopholes in it. The software giant in Raymond is the best proof. Like a lock, no matter how strong it is, it can always be picked! Its role is nothing more than "chat prepared in case a gentleman" :)

And this lock is precisely the engineer who can improve it! Engineers know its loopholes, but cannot improve it; hackers know its loopholes, but can take advantage of it... This lock is exactly closed source code!

Isn't this bad?

The software function is not strong enough

Although you are willing to use the Linux system, its software does not satisfy you, and even casts a shadow on your sentimental heart, "Long breath to cover your tears..."

First of all, don't forget that the special effects of "Titanic" were completed under the Linux system, and even the industry giant SGI is migrating to Linux (although SGI's IRIX is originally a Unix system). If you don't know SoftImage, have you heard of Maya? It was originally multi-platform.

For the high-throughput data (in TB) and computing power required for movie special effects processing, the Windows system may not even have the chance to crash =_=# (The latest statistics show that among the Top500 computers, Linux accounts for 73.4 %, including the top two fastest. Among them, there are 367 Linux systems, 98 Unix systems, 24 hybrid operating systems, 5 AppleMacOS systems, 4 BSD systems, and 2 Windows systems) similar to atmospheric simulation and genetic decoding Wait for the real scientific computing...Windows...I saw a set of astronomy software from a European observatory on verycd.com a few days ago, only the Linux version!

Of course, most of the powerful software under Linux is command line, and the program with graphical interface can only be visually powerful, strong on the outside but dry on the inside! It is recommended that you use the man command to query the usage methods of various software. It has beautiful layout, neat format, concise grammar, and smooth meaning. It is really a rare teaching material for learning English.

unfriendly interface

If you mean how aesthetically pleasing the system is. I think the default effect of Gnome is on the same level as Windows, and the effect of KDE is slightly better. Many experts can use FVWM to create dazzling effects... and Novell's XGL can be described as "amazing". .

If you mean the operation, this is a conflict between the concepts of "easy to learn but difficult to master" and "difficult to learn but easy to master".

Of course, the proficiency I refer to is mainly for efficiency. If you've played Blizzard games a lot, you probably know, maybe even appreciate, the "easy to learn, hard to master" philosophy.

But this concept only applies to competitive games! Competitive games need balls that can attract a large number of players, so they need to be easy to play. But competitive games are born for competition, so it is impossible for everyone to be a master────In fact, masters are only a small number of people!

The operating system is for people to use, and it is best for everyone to become a master, so it is very important to be easy to master... Of course, it is best to be easy to use. But considering the problem of efficiency, this is difficult to solve...

How does Linux take up so much memory?

Linux will maximize the use of physical memory and avoid using swap space; instead of reclaiming memory as much as possible, use page files.

And because the memory management of the Linux system is very good, memory can be efficiently reclaimed when the program exits, so there is no need to reclaim memory when the program is running!

Therefore, the Linux system seems to have a large memory overhead on the surface, but in fact the system is running very stable—Linux will not run smoothly from time to time, and from time to time it will be paralyzed. In fact, under normal circumstances, it runs very smoothly.

Guess you like

Origin blog.csdn.net/qq_21743659/article/details/113744442