mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
5f615bf4c5
@ -0,0 +1,97 @@
|
||||
如何在 Linux 系统中使用 dd 命令而不会损毁你的磁盘
|
||||
===========
|
||||
|
||||
> 使用 Linux 中的 dd 工具安全、可靠地制作一个驱动器、分区和文件系统的完整镜像。
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_happy_sad_developer_programming.png?itok=72nkfSQ_)
|
||||
|
||||
*这篇文章节选自 Manning 出版社出版的图书 [Linux in Action][1]的第 4 章。*
|
||||
|
||||
你是否正在从一个即将损坏的存储驱动器挽救数据,或者要把本地归档进行远程备份,或者要把一个别处的活动分区做个完整的副本,那么你需要懂得如何安全而可靠的复制驱动器和文件系统。幸运的是,`dd` 是一个可以使用的简单而又功能强大的镜像复制命令,从现在到未来很长的时间内,也许直到永远都不会出现比 `dd` 更好的工具了。
|
||||
|
||||
### 对驱动器和分区做个完整的副本
|
||||
|
||||
仔细研究后,你会发现你可以使用 `dd` 做各种任务,但是它最重要的功能是处理磁盘分区。当然,你可以使用 `tar` 命令或者 `scp` 命令从一台计算机复制整个文件系统的文件,然后把这些文件原样粘贴在另一台刚刚安装好 Linux 操作系统的计算机中。但是,因为那些文件系统归档不是完整的映像文件,所以在复制文件的过程中需要计算机操作系统的运行作为基础。
|
||||
|
||||
另一方面,使用 `dd` 可以对任何数字信息完美的进行逐个字节的镜像。但是不论何时何地,当你要对分区进行操作时,我要告诉你早期的 Unix 管理员曾开过这样的玩笑:“ dd 的意思是<ruby>磁盘毁灭者<rt>disk destroyer</rt></ruby>”(LCTT 译注:`dd` 原意是<ruby>磁盘复制<rt>disk dump</rt></ruby>)。 在使用 `dd` 命令的时候,如果你输入了哪怕是一个字母,也可能立即永久性的擦除掉整个磁盘驱动器里的所有重要的数据。因此,一定要注意命令的拼写格式规范。
|
||||
|
||||
**记住:** 在按下回车键执行 `dd` 命令之前,暂时停下来仔细的认真思考一下。
|
||||
|
||||
### dd 命令的基本操作
|
||||
|
||||
现在你已经得到了适当的提醒,我们将从简单的事情开始。假设你要对代号为 `/dev/sda` 的整个磁盘数据创建精确的映像,你已经插入了一块空的磁盘驱动器 (理想情况下具有与代号为 `/dev/sda` 的磁盘驱动器相同的容量)。语法很简单: `if=` 定义源驱动器,`of=` 定义你要将数据保存到的文件或位置:
|
||||
|
||||
```
|
||||
# dd if=/dev/sda of=/dev/sdb
|
||||
```
|
||||
|
||||
接下来的例子将要对 `/dev/sda` 驱动器创建一个 .img 的映像文件,然后把该文件保存的你的用户帐号家目录:
|
||||
|
||||
```
|
||||
# dd if=/dev/sda of=/home/username/sdadisk.img
|
||||
```
|
||||
|
||||
上面的命令针对整个驱动器创建映像文件,你也可以针对驱动器上的单个分区进行操作。下面的例子针对驱动器的单个分区进行操作,同时使用了一个 `bs` 参数用于设置单次拷贝的字节数量 (此例中是 4096)。设定 `bs` 参数值可能会影响 `dd` 命令的整体操作速度,该参数的理想设置取决于你的硬件配置和其它考虑。
|
||||
|
||||
```
|
||||
# dd if=/dev/sda2 of=/home/username/partition2.img bs=4096
|
||||
```
|
||||
|
||||
数据的恢复非常简单:通过颠倒 `if` 和 `of` 参数可以有效的完成任务。在此例中,`if=` 使用你要恢复的映像,`of=` 使用你想要写入映像的目标驱动器:
|
||||
|
||||
```
|
||||
# dd if=sdadisk.img of=/dev/sdb
|
||||
```
|
||||
|
||||
你也可以在一条命令中同时完成创建和拷贝任务。下面的例子中将使用 SSH 从远程驱动器创建一个压缩的映像文件,并把该文件保存到你的本地计算机中:
|
||||
|
||||
```
|
||||
# ssh username@54.98.132.10 "dd if=/dev/sda | gzip -1 -" | dd of=backup.gz
|
||||
```
|
||||
|
||||
你应该经常测试你的归档,确保它们可正常使用。如果它是你创建的启动驱动器,将它粘贴到计算机中,看看它是否能够按预期启动。如果它是普通分区的数据,挂载该分区,确保文件都存在而且可以正常的访问。
|
||||
|
||||
### 使用 dd 擦除磁盘数据
|
||||
|
||||
多年以前,我的一个负责政府海外大使馆安全的朋友曾经告诉我,在他当时在任的时候, 政府会给每一个大使馆提供一个官方版的锤子。为什么呢? 一旦大使馆设施可能被不友善的人员侵占,就会使用这个锤子毁坏所有的硬盘.
|
||||
|
||||
为什么要那样做?为什么不是删除数据就好了?你在开玩笑,对吧?所有人都知道从存储设备中删除包含敏感信息的文件实际上并没有真正移除这些数据。除非使用锤子彻底的毁坏这些存储介质,否则,只要有足够的时间和动机, 几乎所有的内容都可以从几乎任何数字存储介质重新获取。
|
||||
|
||||
但是,你可以使用 `dd` 命令让坏人非常难以获得你的旧数据。这个命令需要花费一些时间在 `/dev/sda1` 分区的每个扇区写入数百万个 `0`(LCTT 译注:是指 0x0 字节,意即 NUL ,而不是数字 0 ):
|
||||
|
||||
```
|
||||
# dd if=/dev/zero of=/dev/sda1
|
||||
```
|
||||
|
||||
还有更好的方法。通过使用 `/dev/urandom` 作为源文件,你可以在磁盘上写入随机字符:
|
||||
|
||||
```
|
||||
# dd if=/dev/urandom of=/dev/sda1
|
||||
```
|
||||
|
||||
### 监控 dd 的操作
|
||||
|
||||
由于磁盘或磁盘分区的归档可能需要很长的时间,因此你可能需要在命令中添加进度查看器。安装管道查看器(在 Ubuntu 系统上安装命令为 `sudo apt install pv`),然后把 `pv` 命令和 `dd` 命令结合在一起。使用 `pv`,最终的命令是这样的:
|
||||
|
||||
```
|
||||
# dd if=/dev/urandom | pv | dd of=/dev/sda1
|
||||
|
||||
4,14MB 0:00:05 [ 98kB/s] [ <=> ]
|
||||
```
|
||||
|
||||
想要推迟备份和磁盘管理工作?有了 `dd` 工具,你不会有太多的借口。它真的非常简单,但是要小心。祝你好运!
|
||||
|
||||
----------------
|
||||
|
||||
via:https://opensource.com/article/18/7/how-use-dd-linux
|
||||
|
||||
作者:[David Clinton][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[SunWave](https://github.com/SunWave)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
|
||||
[a]: https://opensource.com/users/remyd
|
||||
[1]: https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&a_bid=4ca15fc9&chan=opensource
|
@ -0,0 +1,159 @@
|
||||
How To Force User To Change Password On Next Login In Linux
|
||||
======
|
||||
When you created the users account with a default password, you have to force the users to change their password on next login.
|
||||
|
||||
This option is mandatory when you were working in organization because old employees might know the default password and they may or may not try to malpractices.
|
||||
|
||||
This is one of the security complaint so, make sure you have to take care this in the proper way without any fail. Even your team members can do the same.
|
||||
|
||||
Most of the users are lazy and they don’t change their password until you force them to do so, make this practices.
|
||||
|
||||
For security reason you need to change your password frequently, or at-least once in a month.
|
||||
|
||||
Make sure you are using hard and guess password (The combination of Upper and Lower alphabets, Numbers, and Special characters) . It should be at-least 10-15 characters.
|
||||
|
||||
We have ran a shell script to create a user account in Linux server which automatically append a password for user, with combination of actual username followed by few numeric values.
|
||||
|
||||
We can achieve this by using the below two methods.
|
||||
|
||||
* passwd command
|
||||
* chage command
|
||||
|
||||
|
||||
|
||||
**Suggested Read :**
|
||||
**(#)** [How To Check Which Groups A User Belongs To On Linux][1]
|
||||
**(#)** [How To Check User Created Date On Linux][2]
|
||||
**(#)** [How To Reset/Change User Password In Linux][3]
|
||||
**(#)** [How To Manage Password Expiration & Aging Using passwd Command][4]
|
||||
|
||||
### Method-1: Using passwd Command
|
||||
|
||||
passwd stands for password. It updates user’s authentication tokens. The passwd command/utility is used to set or modify or change users password.
|
||||
|
||||
Normal users are only allowed to change their own account but super users can change the password for any account.
|
||||
|
||||
Also, we can use an additional options which allows user to perform other activities such as deleting password for the user, lock/unlock the user account, set the password expiry for given user account, etc,.
|
||||
|
||||
This can be performed in Linux by calling the Linux-PAM and Libuser API.
|
||||
|
||||
Users details will be stored in /etc/passwd file when you created a user in Linux. The passwd file contain each/every user details as a single line with seven fields.
|
||||
|
||||
Also below four files will be updated while creating a new users in the Linux system.
|
||||
|
||||
* `/etc/passwd:` User details will be updated in this file.
|
||||
* `/etc/shadow:` User password info will be updated in this file.
|
||||
* `/etc/group:` Group details will be updated of the new user in this file.
|
||||
* `/etc/gshadow:` Group password info will be updated of the new user in the file.
|
||||
|
||||
|
||||
|
||||
#### How To Perform This With passwd Command
|
||||
|
||||
We can perform this with passwd command by adding the `-e` option.
|
||||
|
||||
To test this, let’s create a new user account and see how it’s working.
|
||||
```
|
||||
# useradd -c "2g Admin - Magesh M" magesh && passwd magesh
|
||||
Changing password for user magesh.
|
||||
New password:
|
||||
Retype new password:
|
||||
passwd: all authentication tokens updated successfully.
|
||||
|
||||
```
|
||||
|
||||
Expire the password for the given user account. The user will be forced to change the password during the next login attempt.
|
||||
```
|
||||
# passwd -e magesh
|
||||
Expiring password for user magesh.
|
||||
passwd: Success
|
||||
|
||||
```
|
||||
|
||||
It’s asking me to set a new password when i’m trying to login to the system at first time.
|
||||
```
|
||||
login as: magesh
|
||||
[email protected]'s password:
|
||||
You are required to change your password immediately (root enforced)
|
||||
WARNING: Your password has expired.
|
||||
You must change your password now and login again!
|
||||
Changing password for user magesh.
|
||||
Changing password for magesh.
|
||||
(current) UNIX password:
|
||||
New password:
|
||||
Retype new password:
|
||||
passwd: all authentication tokens updated successfully.
|
||||
Connection to localhost closed.
|
||||
|
||||
```
|
||||
|
||||
### Method-2: Using chage Command
|
||||
|
||||
chage stands for change age. It changes user password expiry information.
|
||||
|
||||
The chage command changes the number of days between password changes and the date of the last password change. This information is used by the system to determine when a user must change his/her password.
|
||||
|
||||
This allows user to perform other activities such as set account expiration date, set password inactive after expiration, show account aging information, set minimum & maximum number of days before password change and set expiration warning days.
|
||||
|
||||
#### How To Perform This With chage Command
|
||||
|
||||
Let’s perform this with help of chage command by adding the `-d` option.
|
||||
|
||||
To test this, let’s create a new user account and see how it’s working. We are going to create a user account called `thanu`.
|
||||
```
|
||||
# useradd -c "2g Editor - Thanisha M" thanu && passwd thanu
|
||||
Changing password for user thanu.
|
||||
New password:
|
||||
Retype new password:
|
||||
passwd: all authentication tokens updated successfully.
|
||||
|
||||
```
|
||||
|
||||
To achieve this, set a user’s date of last password change to “0” with the chage command.
|
||||
```
|
||||
# chage -d 0 thanu
|
||||
|
||||
# chage -l thanu
|
||||
Last password change : Jul 18, 2018
|
||||
Password expires : never
|
||||
Password inactive : never
|
||||
Account expires : never
|
||||
Minimum number of days between password change : 0
|
||||
Maximum number of days between password change : 99999
|
||||
Number of days of warning before password expires : 7
|
||||
|
||||
```
|
||||
|
||||
It’s asking me to set a new password when i’m trying to login to the system at first time.
|
||||
```
|
||||
login as: thanu
|
||||
[email protected]'s password:
|
||||
You are required to change your password immediately (root enforced)
|
||||
WARNING: Your password has expired.
|
||||
You must change your password now and login again!
|
||||
Changing password for user thanu.
|
||||
Changing password for thanu.
|
||||
(current) UNIX password:
|
||||
New password:
|
||||
Retype new password:
|
||||
passwd: all authentication tokens updated successfully.
|
||||
Connection to localhost closed.
|
||||
|
||||
```
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.2daygeek.com/how-to-force-user-to-change-password-on-next-login-in-linux/
|
||||
|
||||
作者:[Prakash Subramanian][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.2daygeek.com/author/prakash/
|
||||
[1]:https://www.2daygeek.com/how-to-check-which-groups-a-user-belongs-to-on-linux/
|
||||
[2]:https://www.2daygeek.com/how-to-check-user-created-date-on-linux/
|
||||
[3]:https://www.2daygeek.com/passwd-command-examples/
|
||||
[4]:https://www.2daygeek.com/passwd-command-examples-part-l/
|
@ -0,0 +1,64 @@
|
||||
How to check free disk space in Linux
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0)
|
||||
|
||||
Keeping track of disk utilization information is on system administrators' (and others') daily to-do list. Linux has a few built-in utilities that help provide that information.
|
||||
|
||||
### df
|
||||
|
||||
The `df` command stands for "disk-free," and shows available and used disk space on the Linux system.
|
||||
|
||||
`df -h` shows disk space in human-readable format
|
||||
|
||||
`df -a` shows the file system's complete disk usage even if the Available field is 0
|
||||
![](https://opensource.com/sites/default/files/uploads/df-ha.png)
|
||||
`df -T` shows the disk usage along with each block's filesystem type (e.g., xfs, ext2, ext3, btrfs, etc.)
|
||||
|
||||
`df -i` shows used and free inodes
|
||||
![](https://opensource.com/sites/default/files/uploads/df-ti.png)
|
||||
|
||||
### du
|
||||
|
||||
`du` shows the disk usage of files, folders, etc. in the default kilobyte size
|
||||
|
||||
`du -h` shows disk usage in human-readable format for all directories and subdirectories
|
||||
|
||||
`du -a` shows disk usage for all files
|
||||
|
||||
`du -s` provides total disk space used by a particular file or directory
|
||||
![](https://opensource.com/sites/default/files/uploads/du-has.png)
|
||||
|
||||
The following commands will check your total space and your utilized space.
|
||||
|
||||
### ls -al
|
||||
|
||||
`ls -al` lists the entire contents, along with their size, of a particular directory
|
||||
![](https://opensource.com/sites/default/files/uploads/ls-al.png)
|
||||
|
||||
### stat
|
||||
|
||||
`stat <file/directory> `displays the size and other stats of a file/directory or a filesystem.
|
||||
![](https://opensource.com/sites/default/files/uploads/stat.png)
|
||||
|
||||
### fdisk -l
|
||||
|
||||
`fdisk -l` shows disk size along with disk partitioning information
|
||||
![](https://opensource.com/sites/default/files/uploads/fdisk.png)
|
||||
|
||||
These are most of the built-in utilities for checking file space in Linux. There are many similar tools, like [Disks][1] (GUI), [Ncdu][2], etc., that also show disk space utilization. Do you have a favorite tool that's not on this list? Please share in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/7/how-check-free-disk-space-linux
|
||||
|
||||
作者:[Archit Modi][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/architmodi
|
||||
[1]:https://wiki.gnome.org/Apps/Disks
|
||||
[2]:https://dev.yorhel.nl/ncdu
|
@ -1,80 +0,0 @@
|
||||
## 如何在linux系统中使用dd命令而不会损毁你的磁盘
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_happy_sad_developer_programming.png?itok=72nkfSQ_)
|
||||
|
||||
这篇文章节选自 Manning 出版社出版的图书[Linux in Action](https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&a_bid=4ca15fc9&chan=opensource)的第4章.
|
||||
|
||||
你是否正在从一个即将损坏的存储驱动器挽救数据,把本地文件进行远程备份,或者把一个活动分区的数据完整的复制到别处,那么你需要懂得如何安全而可靠的复制驱动器和文件系统数据.幸运的是,dd 是一个可以使用的简单而又功能强大的镜像复制命令,从现在到未来很长的时间内,也许直到永远都不会出现比 dd 更好的工具了。
|
||||
|
||||
### 完整的复制驱动器和分区中的数据
|
||||
|
||||
仔细研究后,你会发现你可以使用 dd 做各种任务,但是它最重要的功能是处理磁盘分区。当然,你可以使用 tar 命令或者 scp 命令从一台计算机复制整个文件系统的文件, 然后把这些文件原样粘贴在另一台刚刚安装好 linux 操作系统的计算机中。但是,因为文件系统的文件不是映像文件,所以在复制文件的过程中需要计算机操作系统的运行作为基础。
|
||||
|
||||
另一方面,使用 dd 可以对任何数字信息完美的进行逐个字节的镜像。但是不论何时何地,当你要对分区进行操作时,我要告诉你早期的Unix管理员曾开过这样的玩笑: " dd 象征着磁盘毁灭者"。 在使用 dd 命令的时候,如果你输入了哪怕是一个字母,也可能立即永久性的擦除掉整个磁盘驱动器里的所有重要的数据。因此,一定要注意命令的拼写格式规范。
|
||||
|
||||
**记住:** 在按下 Enter 键执行 dd 命令之前,暂时停下来仔细的认真思考一下。
|
||||
|
||||
### dd 命令的基本操作
|
||||
|
||||
现在你已经得到了适当的提醒,我们将从简单的事情开始。假设你要对代号为 /dev/sda 的整个磁盘数据创建精确的映像,你已经插入了一张空的磁盘驱动器 (理想情况下具有与代号为 /dev/sda 的磁盘驱动器相同的容量)。语法很简单: if = 定义源驱动器 `of =` 定义你要将数据保存到的文件或位置:
|
||||
```
|
||||
# dd if=/dev/sda of=/dev/sdb
|
||||
```
|
||||
接下来的例子将要对 /dev/sda 驱动器创建一个 .img 的映像文件,然后把该文件保存的你的用户帐号家目录:
|
||||
```
|
||||
# dd if=/dev/sda of=/home/username/sdadisk.img
|
||||
```
|
||||
上面的命令针对整个驱动器创建映像文件,你也可以针对驱动器上的单个分区进行操作。 下面的例子针对驱动器的单个分区进行操作,同时使用了一个 bs 参数用于设置单次拷贝的字节数量 (此例中是 4096)。设定 bs 参数值可能会影响 dd 命令的整体操作速度,但理想的设置取决于你的硬件配置和其它考虑。
|
||||
```
|
||||
# dd if=/dev/sda2 of=/home/username/partition2.img bs=4096
|
||||
```
|
||||
数据的恢复非常简单:通过颠倒 if 和 of 参数可以有效的完成任务。在此例中,if = 使用你要恢复的映像,of = 使用你想要写入映像的目标驱动器:
|
||||
```
|
||||
# dd if=sdadisk.img of=/dev/sdb
|
||||
```
|
||||
你也可以在一条命令中同时完成创建和拷贝任务。下面的例子中将从支持 SSH 的远程驱动器创建一个压缩的映像文件并把该文件保存到你的本地计算机中:
|
||||
```
|
||||
# ssh username@54.98.132.10 "dd if=/dev/sda | gzip -1 -" | dd of=backup.gz
|
||||
```
|
||||
你应该经常测试你的档案,确保它们可正常使用。如果它是你创建的启动驱动器,将它粘贴到计算机中,看看它是否能够按预期启动。如果它是普通分区的数据,挂载该分区,确保文件都存在而且可以正常的访问。
|
||||
|
||||
### 使用 dd 擦除磁盘数据
|
||||
|
||||
多年以前,我的一个负责政府海外大使馆安全的朋友曾经告诉我,在他当时在任的时候, 政府会给每一个大使馆提供一个官方版的锤子。为什么呢? 一旦大使馆设施可能被不友善的人员侵占,就会使用这个锤子毁坏所有的硬盘.
|
||||
|
||||
为什么要那样做?为什么不仅仅删除数据?你在开玩笑,对吧?所有人都知道从存储设备中删除包含敏感信息的文件实际上并没有真正移除这些数据。除非使用锤子彻底的毁坏这些存储介质,否则,只要有足够的时间和动机, 几乎所有的内容都可以从几乎任何数字存储介质重新获取。
|
||||
|
||||
但是,你可以使用 dd 命令让坏人非常难以获得你的旧数据。这个命令需要花费一些时间在 `/dev/sda1` 分区的每个扇区写入数百万个 zero:
|
||||
```
|
||||
# dd if=/dev/zero of=/dev/sda1
|
||||
|
||||
```
|
||||
|
||||
还有更好的方法。通过使用 /dev/urandom 作为源文件,你可以在磁盘上写入随机字符:
|
||||
```
|
||||
# dd if=/dev/urandom of=/dev/sda1
|
||||
|
||||
```
|
||||
|
||||
### 监控 dd 的操作
|
||||
|
||||
由于磁盘或磁盘分区的存档可能需要很长的时间,因此你可能需要在命令中添加进度查看器。安装 Pipe Viewer(在Ubuntu系统上安装命令为 sudo apt install pv),然后把 pv 命令和 dd 命令结合在一起。使用 pv,最终的命令是这样的:
|
||||
```
|
||||
# dd if=/dev/urandom | pv | dd of=/dev/sda1
|
||||
|
||||
4,14MB 0:00:05 [ 98kB/s] [ <=> ]
|
||||
```
|
||||
想要推迟备份和磁盘管理工作?有了 dd 工具,你不会有太多的借口。它真的非常简单,但是要小心。祝你好运!
|
||||
|
||||
----------------
|
||||
|
||||
编译自:https://opensource.com/article/18/7/how-use-dd-linux
|
||||
|
||||
作者:[David Clinton](https://opensource.com/users/remyd)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[SunWave](https://github.com/SunWave)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
|
@ -1,17 +1,15 @@
|
||||
Translating by Auk7F7
|
||||
|
||||
Install Microsoft Windows Fonts In Ubuntu 18.04 LTS
|
||||
在 Ubuntu 18.04 LTS 上安装 Microsoft Windows 字体
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2016/07/Install-Microsoft-Windows-Fonts-in-Ubuntu-1-720x340.png)
|
||||
|
||||
Most of the educational institutions are still using Microsoft Fonts. I am not sure about other countries. But, in Tamilnadu (An Indian state), **Times New Roman** and **Arial** fonts are being mostly used by almost all sorts of documentation works, projects, and assignments in colleges and schools. Not only the educational institutions, some small organizations, offices, and shops are still using MS Windows Fonts. Just in case, if you are in a situation where you need to use Microsoft fonts in your Ubuntu Linux desktop, here is how to do it.
|
||||
大多数教育机构仍在使用 Microsoft 字体, 我不清楚其他国家是什么情况。但在泰米尔纳德邦(印度的一个州), **Times New Roman** 和 **Arial** 字体主要被用于大学和学校的几乎所有文档工作,项目和作业。不仅是教育机构,而且一些小型组织,办公室和商店仍在使用 MS Windows 字体。以防万一,如果你需要在 Ubuntu 桌面版上使用 Microsoft 字体,请按照以下步骤安装。
|
||||
|
||||
**Disclaimer:** Microsoft has released its core fonts for free. However, **Please be aware that usage of Microsoft fonts is prohibited in other operating systems**. Read the EULA carefully before installing MS Fonts in any Linux operating system. We (OSTechNix) are not responsible for any kind of piracy act.
|
||||
**免责声明**: Microsoft 已免费发布其核心字体。 但**请不要在其他操作系统中禁止使用 Microsoft 字体**。在任何 Linux 操作系统中安装 MS 字体之前请仔细阅读 EULA 。我们(OSTechNix)不负责这种任何种类的盗版行为。
|
||||
|
||||
### Install MS Fonts in Ubuntu 18.04 LTS desktop
|
||||
### 在 Ubuntu 18.04 LTS 桌面版上安装 MS 字体
|
||||
|
||||
Install MS TrueType Fonts as shown below:
|
||||
如下所示安装 MS TrueType 字体:
|
||||
```
|
||||
$ sudo apt update
|
||||
|
||||
@ -19,21 +17,21 @@ $ sudo apt install ttf-mscorefonts-installer
|
||||
|
||||
```
|
||||
|
||||
Microsoft’s End user agreement wizard will appear. Click **OK** to continue.
|
||||
然后将会出现 Microsoft 的最终用户协议向导,点击 **OK** 以继续。
|
||||
|
||||
![][2]
|
||||
|
||||
Click **Yes** to accept the Microsoft agreement:
|
||||
点击 **Yes** 已接受 Microsoft 的协议:
|
||||
|
||||
![][3]
|
||||
|
||||
After installing the fonts, we need to update the font cache using command:
|
||||
安装字体之后, 我们需要使用命令行来更新字体缓存:
|
||||
```
|
||||
$ sudo fc-cache -f -v
|
||||
|
||||
```
|
||||
|
||||
**Sample output:**
|
||||
**示例输出:**
|
||||
```
|
||||
/usr/share/fonts: caching, new cache contents: 0 fonts, 6 dirs
|
||||
/usr/share/fonts/X11: caching, new cache contents: 0 fonts, 4 dirs
|
||||
@ -111,25 +109,26 @@ fc-cache: succeeded
|
||||
|
||||
```
|
||||
|
||||
### Install MS Fonts in Dual boot with Linux and Windows
|
||||
### 在 Linux 和 Windows 双启动的机器上安装 MS 字体
|
||||
|
||||
If you have dual boot system with Linux and Windows operating system, you can easily install the MS fonts from Windows C drive. All you have to do is mount the Windows partition (C:/Windows).
|
||||
如果你有 Linux 和 Windows 的双启动系统,你可以轻松地从 Windows C 驱动器上安装 MS 字体。
|
||||
你所要做的就是挂载 Windows 分区(C:/windows)。
|
||||
|
||||
I assume you have mounted the **C:\Windows** partition at **/Windowsdrive** directory in linux.
|
||||
我假设你已经在 Linux 中将 **C:\Windows** 分区挂载在了 **/Windowsdrive** 目录下。
|
||||
|
||||
Now, link the fonts location to your Linux system’s fonts folder as shown below.
|
||||
现在,将字体位置链接到你的 Linux 系统的字体文件夹,如下所示。
|
||||
```
|
||||
ln -s /Windowsdrive/Windows/Fonts /usr/share/fonts/WindowsFonts
|
||||
|
||||
```
|
||||
|
||||
After linking the fonts folder, regenerate the fontconfig cache using command:
|
||||
链接字体文件之后,使用命令行重新生成 fontconfig 缓存::
|
||||
```
|
||||
fc-cache
|
||||
|
||||
```
|
||||
|
||||
Alternatively, copy all Windows fonts to **/usr/share/fonts** directory and install the fonts using the following commands:
|
||||
或者,将所有的 Windows 字体复制到 **/usr/share/fonts** 目录下并使用一下命令安装字体:
|
||||
```
|
||||
mkdir /usr/share/fonts/WindowsFonts
|
||||
|
||||
@ -139,23 +138,25 @@ chmod 755 /usr/share/fonts/WindowsFonts/*
|
||||
|
||||
```
|
||||
|
||||
Finally, regenerate the fontconfig cache using command:
|
||||
最后,使用命令行重新生成 fontconfig 缓存:
|
||||
```
|
||||
fc-cache
|
||||
|
||||
```
|
||||
|
||||
### Test Windows font
|
||||
|
||||
Open LibreOffice or GIMP after installing MS Fonts. Now, you will see there the Microsoft coretype fonts.
|
||||
### 测试 Windows 字体
|
||||
|
||||
|
||||
安装 MS 字体后打开 LibreOffice 或 GIMP。 现在,你将会看到 Microsoft coretype 字体。
|
||||
|
||||
![][4]
|
||||
|
||||
That’s it. Hope this guide useful. Again, I warn you usage of MS fonts in other operating system is prohibited. Please read the Microsoft License agreement before installing the MS fonts.
|
||||
就是这样, 希望这本指南有用。我再次警告你,在其他操作系统中使用 MS 字体是被禁止的。在安装 MS 字体之前请先阅读 Microsoft 许可协议。
|
||||
|
||||
If you find our guides useful, please share them on your social, professional networks and support OSTechNix. More good stuffs to come. Keep visiting!
|
||||
如果你觉得我们的指南有用,请在你的社区、专业网络上分享并支持 OSTechNix。还有更多好东西在等着我们。持续访问!
|
||||
|
||||
Cheers!!
|
||||
庆祝吧!!
|
||||
|
||||
|
||||
|
||||
@ -165,7 +166,7 @@ via: https://www.ostechnix.com/install-microsoft-windows-fonts-ubuntu-16-04/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[Auk7F7](https://github.com/Auk7F7)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user