博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
freebsd看内存使用率_如何开始使用FreeBSD
阅读量:2505 次
发布时间:2019-05-11

本文共 12383 字,大约阅读时间需要 41 分钟。

freebsd看内存使用率

介绍 (Introduction)

is a secure, high performance operating system that is suitable for a variety of server roles. In this guide, we will cover some basic information about how to get started with a FreeBSD server.

是一种安全的高性能操作系统,适用于各种服务器角色。 在本指南中,我们将介绍有关如何开始使用FreeBSD服务器的一些基本信息。

This guide is intended to provide a general setup for FreeBSD servers, but please be aware that different versions of FreeBSD may have different functionalities. Depending on which version of FreeBSD your server is running, the instructions provided here may not work as described.

本指南旨在为FreeBSD服务器提供常规设置,但是请注意,不同版本的FreeBSD可能具有不同的功能。 根据您的服务器运行的FreeBSD版本,此处提供的说明可能无法按照说明进行操作。

使用SSH登录 (Logging in with SSH)

The first step you need to take to begin configuring your FreeBSD server is to log in.

开始配置FreeBSD服务器所需的第一步是登录。

On DigitalOcean, you must provide a public SSH key when creating a FreeBSD server. This key is added to the server instance, allowing you to securely log in from your local machine using the associated private key. To learn more about how to use SSH keys with FreeBSD on DigitalOcean, .

在DigitalOcean上,创建FreeBSD服务器时必须提供公共SSH密钥。 此密钥已添加到服务器实例中,使您可以使用关联的私钥从本地计算机安全地登录。 要了解有关如何在DigitalOcean上的FreeBSD中使用SSH密钥的更多信息,请 。

To log in to your server, you will need to know your server’s public IP address. For DigitalOcean Droplets, you can find this information in the control panel. The main user account available on FreeBSD servers created through DigitalOcean is called freebsd. This user account is configured with sudo privileges, allowing you to complete administrative tasks.

要登录到服务器,您将需要知道服务器的公共IP地址。 对于DigitalOcean Droplet,可以在控制面板中找到此信息。 通过DigitalOcean创建的FreeBSD服务器上可用的主要用户帐户称为freebsd 。 此用户帐户配置有sudo特权,使您可以完成管理任务。

To log in to your FreeBSD server, use the ssh command. You will need to specify the freebsd user account along with your server’s public IP address:

要登录您的FreeBSD服务器,请使用ssh命令。 您将需要指定freebsd用户帐户以及服务器的公共IP地址:

  • ssh freebsd@your_server_ip

    ssh freebsd @ your_server_ip

You should be automatically authenticated and logged in. You will be dropped into a command line interface.

您应该自动进行身份验证并登录。您将进入命令行界面。

将默认Shell更改为tcsh(可选) (Changing the Default Shell to tcsh (Optional))

If you logged into a DigitalOcean Droplet running FreeBSD 11, you will be presented with a very minimal command prompt that looks like this:

如果您登录运行FreeBSD 11的DigitalOcean Droplet,将看到一个非常小的命令提示符,如下所示:

If you’re new to working with FreeBSD, this prompt may look somewhat unfamiliar to you. Let’s get some clarity on what kind of environment we’re working in. Run the following command to see what the default shell for your freebsd user is:

如果您是不熟悉FreeBSD的新手,这个提示可能会让您有些陌生。 让我们弄清楚我们正在使用哪种环境。运行以下命令以查看您的freebsd用户的默认外壳程序是:

  • echo $SHELL

    回声$ SHELL
Output   
/bin/sh

In this output, you can see that the default shell for the freebsd user is sh (also known as the Bourne shell). On Linux systems, sh is often an alias for bash, a free software replacement for the Bourne shell that includes a few extra features. In FreeBSD, however, it’s actually the classic sh shell program, rather than an alias.

在此输出中,您可以看到freebsd用户的默认外壳程序是sh (也称为Bourne shell )。 在Linux系统上, sh通常是bash的别名, bash是Bourne shell的免费替代软件,其中包括一些额外的功能。 但是,在FreeBSD中,它实际上是经典的sh shell程序,而不是别名。

The default command line shell for FreeBSD is tcsh, but DigitalOcean Droplets running FreeBSD use sh by default. If you’d like to set tcsh as your freebsd user’s default shell, run the following command:

FreeBSD的默认命令行shell是tcsh ,但是运行FreeBSD的DigitalOcean Droplet默认使用sh 。 如果您想将tcsh设置为您的freebsd用户的默认shell,请运行以下命令:

  • sudo chsh -s /bin/tcsh freebsd

    须藤chsh -s / bin / tcsh freebsd

The next time you log in to your server, you will see the tcsh prompt instead of the sh prompt. You can invoke the tcsh shell for the current session by running:

下次登录服务器时,将看到tcsh提示符,而不是sh提示符。 您可以通过运行以下命令为当前会话调用tcsh shell:

  • tcsh

    tcsh

Your prompt should immediately change to the following:

您的提示应立即更改为以下内容:

If you ever want to return to the Bourne shell you can do so with the sh command.

如果您想返回到Bourne shell,可以使用sh命令。

Although tcsh is typically the default shell for FreeBSD systems, it has a few default settings that users tend to tweak on their own, such as the default pager and editor, as well as the behaviors of certain keys. To illustrate how to change some of these defaults, we will modify the shell’s configuration file.

尽管tcsh通常是FreeBSD系统的默认外壳,但是它具有一些用户倾向于自行调整的默认设置,例如默认的寻呼机和编辑器,以及某些键的行为。 为了说明如何更改其中一些默认值,我们将修改Shell的配置文件。

An example configuration file is already included in the filesystem. Copy it into your home directory so that you can modify it as you wish:

示例配置文件已包含在文件系统中。 将其复制到您的主目录中,以便您可以根据需要对其进行修改:

  • cp /usr/share/skel/dot.cshrc ~/.cshrc

    cp /usr/share/skel/dot.cshrc〜/ .cshrc

After the file has been copied into your home directory, you can edit it. The vi editor is included on the system by default, but if you want a simpler editor, you can try the ee editor instead:

将文件复制到主目录后,即可对其进行编辑。 vi编辑器默认包含在系统中,但是如果您想要一个更简单的编辑器,则可以尝试使用ee编辑器:

  • ee ~/.cshrc

    ee〜/ .cshrc

As you go through this file, you can decide what entries you may want to modify. In particular, you may want to change the setenv entries to have specific defaults that you may be more familiar with.

浏览该文件时,可以决定要修改哪些条目。 特别是,您可能希望将setenv条目更改为您可能更熟悉的特定默认值。

~/.cshrc
〜/ .cshrc
. . .setenv  EDITOR  visetenv  PAGER   more. . .

If you are not familiar with the vi editor and would like a more basic editing environment, you could change the EDITOR environment variable to something like ee. Most users will want to change the PAGER to less instead of more. This will allow you to scroll up and down in man pages without exiting the pager:

如果您不熟悉vi编辑器,但想要一个更基本的编辑环境,则可以将EDITOR环境变量更改为ee 。 大多数用户希望将PAGER更改为less而不是more 。 这将允许您在手册页中上下滚动而无需退出寻呼机:

~/.cshrc
〜/ .cshrc
. . .setenv  EDITOR  eesetenv  PAGER   less. . .

Another thing that you will likely want to add to this configuration file is a block of code that will correctly map some of your keyboard keys inside the tcsh session. At the bottom of the file, add the following code. Without these lines, DELETE and other keys will not work correctly:

您可能想要添加到此配置文件中的另一件事是一块代码,它将在tcsh会话内正确映射一些键盘键。 在文件的底部,添加以下代码。 没有这些行, DELETE和其他键将无法正常工作:

~/.cshrc
〜/ .cshrc
. . .if ($term == "xterm" || $term == "vt100" \            || $term == "vt102" || $term !~ "con*") then          # bind keypad keys for console, vt100, vt102, xterm          bindkey "\e[1~" beginning-of-line  # Home          bindkey "\e[7~" beginning-of-line  # Home rxvt          bindkey "\e[2~" overwrite-mode     # Ins          bindkey "\e[3~" delete-char        # Delete          bindkey "\e[4~" end-of-line        # End          bindkey "\e[8~" end-of-line        # End rxvtendif

When you are finished, save and close the file by pressing CTRL+C, typing exit, and then pressing ENTER. If you instead edited the file with vi, save and close the file by pressing ESC, typing :wq, and then pressing ENTER.

完成后,通过按CTRL+C并键入exit ,然后按ENTER来保存并关闭文件。 如果改用vi编辑文件,请按ESC ,键入:wq ,然后按ENTER ,以保存并关闭文件。

To make your current session reflect these changes immediately, source the configuration file:

要使您的当前会话立即反映这些更改,请提供配置文件:

  • source ~/.cshrc

    源〜/ .cshrc

It might not be immediately apparent, but the Home, Insert, Delete, and End keys will work as expected now.

可能不会立即显现出来,但是HomeInsertDeleteEnd键现在将按预期工作。

One thing to note at this point is that if you are using the tcsh or csh shells, you will need to execute the rehash command whenever any changes are made that may affect the executable path. Common scenarios where this may happen occur when you are installing or uninstalling applications.

此时要注意的一件事是,如果您使用的是tcshcsh shell,则只要进行任何可能影响可执行路径的更改,就都需要执行rehash命令。 在安装或卸载应用程序时,可能会发生这种情况。

After installing programs, you may need to type this in order for the shell to find the new application files:

安装程序之后,您可能需要键入以下内容,以使Shell找到新的应用程序文件:

  • rehash

    重新整理

With that, the tcsh shell is not only set as your freebsd user’s default, but it is also much more usable.

这样,不仅将tcsh shell设置为您的freebsd用户的默认值,而且还更加有用。

将bash设置为默认Shell(可选) (Setting bash as the Default Shell (Optional))

If you are more familiar with the bash shell and would prefer to use that as your default shell, you can make that adjustment in a few short steps.

如果您对bash shell更为熟悉,并且希望将其用作默认shell,则可以通过几个简短的步骤进行调整。

Note: bash is not supported on FreeBSD 11.1, and the instructions in this section will not work for that particular version.

注意: FreeBSD 11.1不支持bash ,本节中的说明不适用于该特定版本。

First, you need to install the bash shell by typing:

首先,您需要输入以下内容来安装bash shell:

  • sudo pkg install bash

    sudo pkg安装bash

You will be prompted to confirm that you want to download the package. Do so by pressing y and then ENTER.

系统将提示您确认要下载软件包。 通过按y ,然后按ENTER

After the installation is complete, you can start bash by running:

安装完成后,可以通过运行以下命令启动bash

  • bash

    重击

This will update your shell prompt to look like this:

这将更新您的shell提示符,如下所示:

To change freebsd’s default shell to bash, you can type:

要将freebsd的默认shell更改为bash ,您可以输入:

  • sudo chsh -s /usr/local/bin/bash freebsd

    须藤chsh -s / usr / local / bin / bash freebsd

The next time you log in, the bash shell will be started automatically instead of the current default.

下次登录时, bash shell将自动启动,而不是当前的默认启动。

If you wish to change the default pager or editor in the bash shell, you can do so in a file called ~/.bash_profile. This will not exist by default, so you will need to create it:

如果您希望在bash shell中更改默认的寻呼机或编辑器,则可以在名为~/.bash_profile的文件中进行。 默认情况下将不存在,因此您需要创建它:

  • ee ~/.bash_profile

    ee〜/ .bash_profile

Inside, to change the default pager or editor, add your selections like this:

在内部,要更改默认的寻呼机或编辑器,请添加以下选择:

~/.bash_profile
〜/ .bash_profile
export PAGER=lessexport EDITOR=ee

Save and close the file when you are finished by pressing CTRL+C, typing exit, and then pressing ENTER.

完成后,保存并关闭文件,方法是按CTRL+C ,键入exit ,然后按ENTER

To implement your changes immediately, source the file:

要立即实施更改,请提供文件source

  • source ~/.bash_profile

    来源〜/ .bash_profile

If you’d like to make further changes to your shell environment, like setting up special command aliases or setting environment variables, you can reopen that file and add your new changes to it.

如果您想对Shell环境进行进一步的更改(例如设置特殊的命令别名或设置环境变量),则可以重新打开该文件并向其中添加新的更改。

设置root密码(可选) (Setting a Root Password (Optional))

By default, FreeBSD servers do not allow ssh logins for the root account using a password. Although the public key authentication would work, On DigitalOcean, this policy has been supplemented to tell users to log in with the freebsd account.

默认情况下,FreeBSD服务器不允许使用密码为帐户进行ssh登录。 尽管可以使用公钥身份验证,但在DigitalOcean上,此策略已得到补充,以告知用户使用freebsd帐户登录。

Because the root user account is inaccessible over SSH, it is relatively safe to set a root account password. While you will not be able to use this to log in through SSH, you can use this password to log in as root through the DigitalOcean web console.

由于无法通过SSH访问root用户帐户,因此设置root帐户密码相对安全。 虽然您将无法使用此密码通过SSH登录,但可以使用此密码通过DigitalOcean Web控制台以root用户身份登录。

To set a root password, type:

要设置root密码,请输入:

sudo passwd

You will be asked to select and confirm a password for the root account. As mentioned above, you still won’t be able to use this for SSH authentication (this is a security decision), but you will be able to use it to log in through the DigitalOcean console.

系统将要求您选择并确认root帐户的密码。 如上所述,您仍然无法将其用于SSH身份验证(这是一项安全性决定),但是您将能够使用它通过DigitalOcean控制台登录。

To do so, click the Console button in the upper-right corner of your Droplet’s page to bring up the web console:

为此,请单击Droplet页面右上角的“ 控制台”按钮以打开Web控制台:

If you choose not to set a password and you get locked out of your server (for instance if you accidentally set overly restrictive firewall rules), you can always set one later by booting your Droplet into single user mode. We have a guide that shows you how to do that .

如果您选择设置密码并且被锁定在服务器之外(例如,如果您不小心设置了过于严格的防火墙规则),则始终可以在以后通过将Droplet引导到单用户模式来进行设置。 我们有一个指南,向您展示如何做到这 。

结论 (Conclusion)

By now, you should know how to log into a FreeBSD server and how to set up a bash shell environment. A good next step is to familiarize yourself with some FreeBSD basics as well as what makes it different from Linux-based distributions.

现在,您应该知道如何登录FreeBSD服务器以及如何设置bash shell环境。 下一步是使自己熟悉一些FreeBSD基础知识以及使其与基于Linux的发行版有所不同的地方。

Once you become familiar with FreeBSD and configure it to your needs, you will be able to take greater advantage of its flexibility, security, and performance.

一旦熟悉了FreeBSD并根据需要对其进行了配置,您将能够更好地利用其灵活性,安全性和性能。

翻译自:

freebsd看内存使用率

转载地址:http://rshgb.baihongyu.com/

你可能感兴趣的文章
装箱和拆箱
查看>>
hdu1215 正整数唯一分解定理应用
查看>>
[BZOJ 3530] [Sdoi2014] 数数 【AC自动机+DP】
查看>>
JS调试debug
查看>>
JS 中的string.lastIndexOf()
查看>>
潜移默化学会WPF(技巧篇)--TextBox相关(一) - AYUI框架 - 博客园
查看>>
Quartz.Net进阶之七:QuartzNet其他的功能简述
查看>>
消息队列
查看>>
WPF进阶教程 - 使用Decorator自定义带三角形的边框
查看>>
SQLServer之FOREIGN KEY约束
查看>>
redis 系列2 知识点概述
查看>>
图像滤镜艺术---图像滤镜晕影调节算法研究
查看>>
Win8Metro(C#)数字图像处理--2.21二值图像腐蚀
查看>>
MVC5 + EF6 入门完整教程
查看>>
SQL Server如何在变长列上存储索引
查看>>
Replication的犄角旮旯(八)-- 订阅与发布异构的问题
查看>>
Sliverlight实例之 绘制扇形和环形图
查看>>
Visual Studio 2012使用水晶报表Crystal Report
查看>>
你不知道的 页面编码,浏览器选择编码,get,post各种乱码由来
查看>>
SQLSERVER PRINT语句的换行
查看>>