BSD tips

zhaozj2021-02-16  83

1. The archive structure in UNIX-Like is full, then how do you see the instructions for the relevant archive directory structure?

Is it a CD to each directory? In fact, there is a better way ..

That is to use a good man man:

#man hier

2, when operating under Console, because the screen is limited, sometimes you need to see the previously displayed information, then you can:

After pressing the PAUSE OR SCROLL LOCK button, you can use the PageUp PageDown Up Down Home End and the like to see the data displayed.

Press the PAUSE OR SCROLL LOCK, you can reply to wait for the input screen.

3, use PW to manage your account

Use adduser to add accounts in FreeBSD, sometimes annoying, available in the following ways:

PW useradd -n -g -m -s / bin / csh

=> -m represents the establishment of the user directory

● Set password at the same time

Echo | PW useradd -n -g -m -s / bin / csh -h 0

● Delete account

PW Userdel -n -r

=> -r represents the relevant information such as the home directory while deleting

● Modify account

PW Usermod -g -s / bin / csh

PS: Unable to modify account name

● Lock and UNLOCK user account

PW Lock

PW unlock

4, activate your Screensaver

Since FreeBSD is used for hosting, it is often not shut down, so the screen can be turned off, or the screensaver feature can be used.

Use ScreenSaver to add the following two lines in /etc/rc.conf:

Blanktime = "900"

=> In the second number, such as 15 minutes

Saver = "logo"

=> logo is the mascot of FreeBSD, and can also use "daemon", which is a text type

5, check your ports version and update

If you want to update all ports just to do the following instructions in / etc / ports / down:

# Make Update

Sometimes we may have to check the version of a ports, which has this line in Makefile in each ports.

Portversion = x.x.x

This can be seen in this ports, and you can use the following way (GREP), such as our version of MOD_PHP4.

# grep portversion = / usr / ports / www / mod_php4 / makefile

Portversion = 1.4.1 -> version message

If the version is too old, you can update a single ports using the following methods.

a. Use portupgrade or portinstall, please use the Man to view the method

b. Go to the FreeBSD website to query the latest Ports information, and catch the ports to update

Website:

http://www.freebsd.org/cgi/cvsweb.cgi/ports/

After caught back, update in the relevant directory, for example, we grab back MOD_PHP4.TAR.GZ, in the presence / usr / tmp / directory, the way to decompress is as follows: # CD / usr / ports / www / mod_php4

# tar xzvf /usr/tmp/mod_php4.tar.gz

This is OK ..

6, speed your button speed..

I believe that many people using freebsd are on console, sometimes, repeating a button speed is very slow ..

Another problem is that the location of CUSROR is not too obvious..

The following methods can be improved:

Add the following information in /etc/rc.conf..

KeyRate = "fast"

Cursor = "blink" or "destructive"

7, set the boot screen

People who use Windows know that the so-called boot screen, does this feature under FreeBSD? The answer is yes, and it is easier, please follow these steps:

First. First, a pattern file is made, the file format is logo.pcx or logo.bmp, you need to pay attention to whether it is. BMP archive storage, no compression, the resolution is within 640 x 480 (inclusive), the color order is 256 colors .

II. Put this archive COPY to / BOOT / this directory

III. Set /boot/loader.conf, add the following information

Splash_Bmp_Load = "YES" -> If you use .bmp format, this item needs to be set to Yes.

Splash_pcx_load = "YES" -> Use .pcx, set this to Yes

VERA_LOAD = "YES"

Bitmap_load = "yes"

Bitmap_name = "/ boot / logo.pcx" -> Please change according to your file format

Bitmap_type = "splash_image_data"

IV. Reactivate

PS: Please check if you have the following information in your kernel, usually in 4.x is an internal value .. As for the 3.x version, it has not been used. ^. ^

Preudo-Device Splash

If not, you need to add this row and re-add the core.

8, some quick keys used under Console..

I believe most users using UNIX-LIKE, or perform your daily maintenance work under Console, and those button combinations can help us improve efficiency ..

The following buttons are suitable for TCSH and Bash..

Fast moving cursor

Ctrl a -> to the forefront

Ctrl E -> to the end

2. Edit

Ctrl D -> Delete the cursor where the cursor is located

Ctrl W -> Delete characters in front of the word in the cursor

Ctrl U -> Bash: Delete all words and characters before the cursor, TCSH: Delete all words

Ctrl K -> Delete all characters after the cursor

Ctrl b -> Next character

Ctrl f -> Previous character

Ctrl m -> and the result of the ENTER

Ctrl h -> and press the DEL or Backspace key

DEL or backspace -> Delete the previous character

If you have a research interest in the button, you don't imitate the reference / usr / share / syscons / keymaps / this directory, where us.iso.kbd is usually the buttons we use ..9, fast switching directory

Switching the directory in FreeBSD, sometimes the directory name is longer, or case in case, or only remember the previous words, what to do ..

In fact, as long as the input part is added, it is possible.

If we want to switch to / usr / local / this directory, simply enter CD / USR / LO * is OK..

What will I do if I enter CD / USR / L *? Then go to the / usr / lib / this directory, because shell has stopped the first conformance condition.

10. Related time and time zone? # 123;

Most of FreeBSD is used to use the host. That time, the correctness is very important. How is the following introduction? # 123;

● Time? # 123; whole pepper? Br />

1. Use the DATE directive

Format Date [YYMMDD] hhmm

Description:

YY years, such as 02 representative 2002

MM Moon 01-12

DD Daily 01-31

HH hours 01-59

MM Minute 01-59

YY MM DD can be omitted

example:

? # 123; The whole date is 2002-03-25

# Date 022325

? # 123; whole time is 14:20

# Date 1420

2. Using the timing host

# ntpdate clock.stdtime.gov.tw

This need to connect to the network, where clock.stdtime.gov.tw is a standard time host

● Time zone setting

1. Use TZSetup

2. There is a file localtime in / etc /, which is the time zone setting file of this unit, so we can use it with a touch mode (not via tzsetup), as follows:

# cp / usr / share / zoneInfo / asia / Taipei / etc / localtime

This is not more fast ..

11, how to empty the file content..

Sometimes we need to empty a file content, but you need to retain this file ..

The general common usage is to use the text editor, such as VI, call this file, and then delete it, and then store ..

Is this not a bit annoying?

There is a better way to use True Directive..

If we want to empty / var/log/httpd-access.log, then the following instructions.

# CD / var / log /

# True> httpd-access.log

12, display directory and file => Tree

Sometimes you need to display all directories and files in a directory, although the use of LS can reach some function, but it is not very convenient ..

In DOS, there is a Tree directive, it is not full ..

In fact, there are similar instructions in FreeBSD => Tree ..

Let's install TREE through Ports

# cd / usr / ports / sysutils; make install

This will install the Tree in / usr / local / bin / this directory..

Example:

1. Display / usr / under directory and file

# tree / usr

2. Only the directory under / usr

# tree -d / usr

For details, please refer to Man Tree

PS: can be displayed through pipes | and more

Such as tree / usr | more ..

13, how to review file type

Since FreeBSD does not have the concept of DOS or Windows extension, how do you check the type of file?

Use File ..

Syntax: file

For details, please refer to Man File14, reuse the previously used instructions.

You can use the following methods to reuse the previously used instructions:

For example, let's display the previously entered instructions with HISTORY:

# history

.

.

...

10 CLEAR

11 CD / USR / LOCAL

12 ls

13 LS ETC

14 CD ~

15 Clear

1. Use UP Down to use the up and down one instruction, or Ctrl P Ctrl N is also available

2. Match! Usage, for example, (ps: in <...>) to enter Dongdong)

!!

# !! => Repeat the last one of the instructions

!

#! 11 => Perform CD / USR / LOCAL

! Enter a part word, but the previous part needs to match

#! cl

Execute 15 Clear Directive

! Enter a part character, partial anastomosis

#!? etc?

Perform 13 LS ETC

The above instructions can be used under TCSH and BASH, that is this, it can help you save a lot of time ..

15. How to print the archive of Man ..

Man is the best information source of FreeBSD, but it is not very convenient to see the bottom on the monitor, is there a way to transfer to a general file file?

Use the COL this instruction..

For example, we have to turn SSH2 to ssh2.txt, then use the following syntax:

#man ssh2 | col -b> ssh2.txt

16. Why can't I find the correct ports information..

There are thousands of ports installation materials in / usr / ports /, sometimes we can check the relevant ports in the following ways.

The following is performed in / usr / ports / this directory..

1. First convert the ports into a text file, such as index.txt

# make print-index> index.txt

2. Check using make search key = "...."

3. Convert the PORTS content to Readme.html

# make ready

With the above method, you can easily find the relevant Ports data, but it is very strange that after I update a ports (or ports trees), why can't I find it, I'm still old information. .

It turns out that there is an index file in / usr / ports /, the above query is queried in this index file. When you update the ports information, this index file will not be updated ..

So for the convenience of query, we need to do a manual way ..

# make index

After completing, update index.txt and readme.html..

However, the update of the index file requires some time, about 12-30 minutes .. (depending on the computer level).

17, replace NSLOOKUP with DIG and Host

Generally we use whether there is a problem with the network, mostly the following three instructions.

Nslookup

ping

Traceroute

Where nsllokup is used to check the relevant settings of the DNS, and ping is used to check if you and the other network is smooth, and Traceroute is used to check the line conditions passed by your computer to each other ..

However, in terms of nslookup, some people feel that it is not very practical. Sometimes we just want to check a host or MX record. It is a bit bit of using nslookup ..

Here, two good instructions Host and Dig are introduced, this two instructions are very similar, but efficiency is higher than NSLookup high # host -a or

=> Enter the host name Displays part of DNS forward parsing, input IP is display reverse (PTR)

# DIG

To display MX record

# DIG Host Name MX

Personally feel more convenient than nslookup, you think .. ^. ^

Of course, the function is not only these, please please man DIG or Host..

18, speed up your boot speed..

Strictly speaking, FreeBSD's boot speed is full, but there will be a 10 second delay time in the middle (so that you can enter boot's Command Prompt mode). If you are too much 10 seconds, it is too slow, then you can Time? # 123; Short some ..

FreeBSD will first go to the /boot/default/loader.conf file, then refer to /Boot/Loader.conf, usually we don't go? # 123; whole / Boot/defaults/loader.conf this file And directly? # 123; whole / boot/luadeer.conf ..

As long as you add the following lines in /boot/loader.conf

Autoboot_delay = "seconds", such as

Autoboot_delay = "7" represents 7 seconds

This is not faster so power..

Also recommend, have time to refer to the setting of /boot/default/loader.conf file, there are many practical settings..

19, forget the root password

If you have forgotten the password of the root, this is fully resolved in FreeBSD, please handle the following steps ..

1. Enter a single mode

After booting, when the appearance

Hit [Enter] to boot immediately, or any other key for Command Prompt.

Booting [kernel] in 10 seconds ...

Press Space (or bond other than ENTER) The key will enter Command Prompt Mode and an OK is displayed..

Please enter boot -s to enter the single mode.

2. Select SH

After entering the single mode, the system will ask you to use that SH, the internal default is / bin / sh, use this, press ENTER to skip directly

3. Segment all hard drives

# mount -a

4. Change your password

# Passwd

The length is more than 6 or more, enter secondary

5. Reactivate

# reboot

20, activation of Kernel..

Kernel is a very important ring for UNIX-Like systems. If kernel is damaged or compiled, it may lead to serious consequences..

FreeBSD has always been safely known, what is the protection measures in this regard?

FreeBSD's kernel is placed in / directory, there will be two

kernel

Kernel.Generic

If you have the core of the Kernel, the original kernel will be converted to kernel.old, and the new core will become kernel, that is, the Kernel file is as follows:

KERNEL => Newly compiled core

Kernel.Generic

Kernel.OLD => Original core

What is kernel.Generic, this is installed in the system installation, generally will not change, even if the core is compiled, this file can be said to be a life-saving core, it is best not to move, the reason is as follows. When .freeBSD is activated, use kernel this core, if this file does not exist, it will grab the kernel.old file..

If this two files are unfortunate, what should I do. At this time, I will enter the Command Prompt Mode, you must enter the name of the Kernel it yourself, such as

Boot such as

Boot kernel.Generic

After understanding the above, I believe how to deal with it when the compilation core is not possible.

21, FreeBSD in that activation program..

General FreeBSD will execute the program in the following positions in order..

1. /etc/rc.conf This program, such as Sendmail, sshd .. is executed here, and it should be noted that before performing this file, you will refer to /etc/defaults/rc.conf set up

2. Some of the .SH files under the .SH file, the permissions of these files are set to X, such as Apache Samba ..

3. /etc/rc.local can also be set here. If I want to set the postfix, just add a line in this file, as follows

/ USE / LOCAL / SBIN / Postfix Start &

Plus &, will not display a message

4. Some files controlled by cron, when it is time, will be automated ..

The person who is fine may ask, /etc/inetd.conf is set? These will be implemented in item 1..

Learn about whether or not there is an unknown program, it is also an important task of the daily viewing system ..

22, speed up your host name query speed ..

UNIX-Like system, the initial use of Hosts set files to do host queries, so some programs will refer to this setting file when checking the master name, like Sendmail is a good example ..

The system has the first one to check the / etc / hosts file, so if there is a problem inside, it will affect the execution of some programs ..

Typical HOSTS file is set as follows .. Take my own host

127.0.0.1 localhost.cmlab.idv.tw localhost

61.219.230.5 cmlab.idv.tw cmlab

61.219.230.5 CmLab.idv.tw.

The last item of the first and second lines is the AliaseS name (host alias), such as we are in the host

ping cmlab.idv.tw

with

Ping Cmlab

Is the same result..

You can add some commonly used hosts to this project, if there is a mail.cmlab.idv.tw, assume that IP is 61.219.230.8

Then add the following in this Hosts

61.219.230.8 mail.cmlab.idv.tw mail

61.219.230.8 Mail.cmlab.idv.tw.

This should be okay..

In addition, if there is a self-operated DNS Server, please note that in /etc/host.conf file, the typical file is as follows:

# $ Freebsd: src / etc / host.conf, v 1.6 1999/08/27 23:23:41 Peter EXP $

# First try the / etc / hosts file

Hosts

# Now Try The nameserver next.

bind

# If you have yp / nis configured, uncomment the next line

# nis

It can be seen from the above, in the order of the host name, first check Hosts and check BIND is DNS, you can modify its order ..

In addition, you should pay attention to the /etc/resolv.conf file, this is the order of the DNS host Search, such as with my setting as follows:

Domain cmlab.idv.tw

Nameserver 61.219.230.5

Nameserver 168.95.1.1

Nameserver 168.95.192.1

The first line is to set my domain name. The second-4 line is the setting of the DNS host. It is recommended to set at least two, so as not to hang, there is a spare ..

The second line is my DNS host, 3-4 line is the Hinet's DNS host ..

Understand the above and correct settings, which helps improve the inquiry of the host and the speed of speed..

23, how do I split the hard drive ..

The file directory is quite important for FreeBSD (or all UNIX-Like systems). If the start is not very appropriate, it will encounter some trouble in the future, such as the space is not enough ..

So how do we split more appropriate?

This is about your use and FreeBSD directory architecture..

The general person is suggesting that you are so split:

1. / Root Catalog, generally in the absolute use of 250 ~ 500 mb, in my root catalog, more than 66 MB is used for more than a year. Because this directory is just some of the kernel modules sbin bin etc ..

2. SWAP file, the average person does not know how to set up a compassion, this is not a standard, the most important thing to see your RAM and hard drive, generally set to 1-2.5 times (relative to your RAM). If your RAM is more than 256 MB or more, it is doubled; if it is 64-128 MB, it is recommended to set it twice.

To check your SWAP usage, you can use the following instructions..

# pstat -t

44/4044 Files

0M / 127M SWAP SPACE

From the above, it can be seen that the SWAP currently used is 0, and the set size is 128 m.

3. / var directory and / usr directory

These two catalogs generally account for a relatively large space, and the changes in Var are smaller. In my individual, it is set to 8 GB a year ago, and only 2GB is only used.

But pay attention to the general Mail software, all of which exists / var / mail / in your letter, if your letters are much or very big, this part may wish to increase some ..

And / usr can give it a big space, because the programs installed, or Hone is in this directory (if you don't set the Home directory into a split)..

How do these two do you assign, my suggestion is that USR and VAR are 3: 1, or 2: 1

4. Some host users are more, such as school units. If you don't set home into a partition, FreeBSD will install Home in the / usr directory, if you manage and security, you may wish to split the Home into a single directory..

As for the size, I think there should be about 3-5 gb, it is absolutely enough.

Let's give an actual example, assume you have a 40-GB hard drive, using memory 128 MB RAM, then I suggest your hard disk so split ..1. / => 250 MB

2. Swap => Take 2 times, 256 MB

3. / Home is to be independent, give it 3-5 GB

4. The remaining 3: 1 or 2: 1 ratio is set to / usr and / var

The above is only general recommendations, the most important thing is to understand the nature of the catalogs and the actual use of the actual use, and the information about this, you may wish to refer to Man Hier..

25. Simple edit your file file..

In UNIX-LIKE, the standard text editor is VI, but VI is not very easy to get started for beginners.

And in FreeBSD is EE, this text editor, although the function is not VI, but it is easy to use .. Novice can use an editor in the early days ..

Its use is simple, as long as you take EE under Command Line

# EE

After entering the EE screen, it is some button description. If you want to obtain the relevant EE instructions, press the CTRL C button first, then enter the HELP, will display a detailed description

Sometimes I only want to add a small part of the information in a file, which uses the text editor to handle it, it is inefficient, in fact, we can use the CAT> [Document Name] and CAT >> [Document Name]. .

What is the difference in these two ways?

When the file does not exist if the file does not exist, it will automatically generate a file; if the file exists, the file will be emptied ..

CAT >> [Document], the file does not exist, automatically establish this file, if there is, the data edited is added to the file ..

For example, if we want to edit / etc / mail / access this is the Relay setting file of Sendmail ..

Want to join 192.168.88.5 relay in this archive

This method can be used (assuming that the Access file already exists, so using cat >> ..) ..

# cat >> / etc / mail / access

192.168.88.5 relay

Press CTRL D storage

In this way, 192.168.88.5 Relay can be added to the last line of Access..

However, it is recommended that everyone, UNIX-LIKE's common text editor is VI, there is time you may wish to learn vi ..

26, FreeBSD account and password

After standing FreeBSD, it is the information of new people (users)..

When setting your account, please note the following:

1. The length needs to be in 1-16 characters

2. Use English lowercase letters, numbers and - _ symbols

When setting the password, please pay attention to the following

1. The password can be set, but it is recommended that you have to set up

2. The length is preferably 6 words, you know that according to safety experts, crack a length 6 and length 4 password, at least 10 times more time

3. Do not use your birthday, relevant certificate number, phone .. and other materials, use the case of the upper and lower English letters and mix special symbols, such as CT! Home-12 is a password that is fairly difficult to crack

4. The longest length I have set to 16 digits (how much is the maximum length, the interester can try it yourself)

27. Some activation issues related to the system ..

Sometimes it will modify some of FreeBSD, such as some network parameters, software .conf settings, or /etc/r.conf files, how to make the set value take effect, do you have to reboot? This can be divided into three aspects.

1. Network-related settings, such as network adaptation cards, hostname .., etc., you can reload your network settings as long as you do the following instructions..

# SH / ETC / NETSTART

NetStart is a Script file that will be referred to /etc/rc.network when executed. Therefore, you can reactivate the network settings as long as this instruction is executed..

Interesteders can refer to the two files of NetStart and RC.Network, and the study shows what is done ..

2. Modify other settings in rc.conf

Refer to the following three STEPs..

Enter a single mode

# shutdown now

Select SH, to create the value, ie / bin / sh

Leave single mode

# exit

This will reactivate the system ..

3. Software settings, such as some * .conf files, like Apache Sendmail ..

Usually there will be related .SH files in /etc/local/rc.d/ this directory, directly execution, pay attention to usually add parameters, general parameters have the following (depending on software) )..

START activation

STOP stops

Reload or restart reactivated

The second method is to use Killall directly. If we want to reactivate inetd, the following methods are available:

# killall -1 inetd

Or

# KILLALL-HUP inetd

This will reactivate this daemon.

28, protect your file

In the system, there are many files or some set files that are very important. Plus the FreeBSD (or the general unix-like) system does not have a function similar to MS's garbage collection bucket, in case unfortunate (or modify) An important file may cause a small trouble ..

Although, FreeBSD is very strict for the permissions of the file, but sometimes we work as root, there will be this risk..

How do you avoid this situation or protect certain important files?

We can use Chflags to achieve this purpose, as the name suggestions, chflags is composed of two words, namely Change and Flags (flags of files) ..

For example, we have to protect the file of /etc/inetd.conf, so as not to accidentally delete or modified, the instructions are as follows:

# chflags schg /etc/inetd.conf

This can protect these files, such as the flag (FLAG) of these files, can be used in LS..

# ls -lo /etc/inetd.conf => L is lower-written L

-rw ------- 1 root wheel schg 47 mar 28 21:29 inetd.conf

To unlock the flag setting, you can use unschg, which is before SCHG, such as:

# chflags unschg /etc/inetd.conf

Most of us have entered the host as root, so it is not careful, it may be .. Therefore, it is recommended to set some important files and set files to Schg Flags to protect the file ..

Such as / bin, / sbin, /etc/.conf ,/usr/lcaol/etc/*.conf .. These files are the best to set a SCHG flag ..

CHFLAGS Please refer to Man Chflags for details.

29, talk about the software installation path ..freebsd is very heavy for the concept of the file directory, what kind of file must be placed in that directory, which is different from other UNIX-LIKE systems ..

Generally, we divide the software installation into two parts. Here to discuss the software until the software is installed..

When installing the software, you usually install, such as execution file, setting file, man file, doc file ..

1. Install the software installed when installing the system

Executive files are usually installed / bin, / sbin, / usr / bin, / usr / sbin, / usr / libexec

Setting the file in / etc directory

Man file is usually in / usr / man or / usr / share / man

DOC files are usually under / usr / share / doc

2. Software installed via package or port

Executive files are usually installed / usr / local / bin, / usr / local / sbin, / usr / local / libexec

Setting the file in / use / local / etc directory

Man File is usually in / usr / local / man..

DOC files are usually under / usr / share / doc

The above is not absolute (so I usually use usually. ^. ^), Because some special circumstances are required.

This may sometimes cause a little bit, because such as SSH, Bind .. Most of them are installed when systematic, then what if you upgrade the new version ..

Since FreeBSD finds the executive file, it will be found in the $ PATH environment variable, because / bin, / sbin, / usr / bin, / usr / sbin ratio / usr / local / bin or / usr / local / sbin first, Execute .. that is, first caught the old version of the executive file ..

So pay attention to this situation when updating, so as not to update or execute old programs..

So how do you see the installation path of the relevant file when you have a procedure? Usually there is a method

1. See the PKG-PLIST file

2. Sometimes the location of some important files can be seen with the MAN [Enforcement Name]

3. View instruction file, usually in / usr / local / share / doc directory

30, how to add an IP address in FreeBSD

Sometimes, you need to add IP on the same network card to achieve some special requirements..

This is very simple in FreeBSD, assuming that the original network card IP is 211.211.211.211, I want to add 211.211.211.212, using the RL0 network card, the practice is as follows ..

1. Plus this line in /etc/rc.conf

ifconfig_rl0_alias0 = "INET 211.211.211.212 Netmask 255.255.255.255"

The alias0 is the first IP of the installed, and if you want to set a plurality of ALIAS1, Alias2 .. AliaSn

2. Reactivate the network card, execute / etc / netstart

# / etc / netstart

31. Simple encrypted your information

In practice, we often need to encrypt certain sensitive information, usually we can use the PGP or Crypt here to achieve this function..

Crypt is a function of encryption through | this pipe conversion function and password setting, that is, the password you set as the number of seed randhes generated by encryption.

First explain the method of use of CRYPT:

Crypt [-s] [-k] [Password]

General -s and -k parameters do not pay attention, password is a cryptographic encryption or decryption.

Here, we must first generate a Test.txt file, content is Test, then encrypt with 1234 this password

# cat> Test.txt

Test

Press CTRL D storage

Let's take a look at Test.txt content # more test.txt

Test

Encrypt Test.txt file with 1234 password, need to match the pipe | and turn symbols, encrypted file names TEST2.txt

# cat test.txt | Crypt 1234> Test2.txt

In this way, a encrypted archive TEST2.TXT is generated, and the other password can be not entered first, and the Enter key will be displayed after pressing the ENTER: Let you enter the password

Let's take a look at the content of the encrypted file, it was originally Test results to become:

# more test2.txt

E & h => is no longer TEST

Then then unspeak the test2.txt, as follows, assume that the unwrapping file is TEST3.TXT:

# cyrpt 1234 test3.txt

The above means

1234 password when encrypted

> TEST3.TXT Decryption Decryption Turn to Test3.txt

Did the contents of Test3.txt are the same as the original, namely TEST

# More test3.txt

Test

PS:

1. Encrypt or decrypt the file, like the source file, will replace the original file

2. Another instruction enigma and Crypt usage are exactly the same

Reference Man Crypt

32. Simplify your server (Server) with Telnet

Sometimes you can test your Server with Telnet has normal Run

For example: I want to see if ftpd is running

Can be tied: # telnet localhost 21

If you run a message similar to the following, it means there is running

--------------------------------

Trying 127.0.0.1 ...

Connected to Localhost.ahkun.

Escape Character is '^]'.

220 - = (<*>) = -.:. (Welcome to PureftPD 1.0.11)).: .- = (<*>) = -

220-you are user number 1 of 50 allowed

220-local time is now 18:52 and the load is 0.06. Server port: 21.

220 you will be disconnected after 15 minutes of inactivity.

If you run the following message, it means not running.

------------------------------------------------

Trying 127.0.0.1 ...

Telnet: Connect to Address 127.0.0.1: Connection Refused

Telnet: Unable to connect to Remote Host

You can also use:

Telnet localhost 25 test stmpd

Telnet localhost 110 measurement POP3D

in conclusion:

Correctly use Telnet to measure Port ~

33, how to prevent someone from logging in to your computer

Sometimes we don't want others to log in directly to our host or just want to limit some people to use, such as telnet, ssh ..

Or open some services, such as ftp, smtpd .., etc., because these must have an account in the host, it is very important to prevent people from logging in to your host. It is also a safe consideration ..

However, the generally limited mode is the way IP or Domain, then there is a way to solve this problem? The answer is to start from /etc/login.access, this file is limited to Login ..

A typical setting is as follows, for example, we want to limit only root and user John to log in to the host (including local and remote):

-: ALL EXCEPT ROOT JOHN: ALL

It can be divided into three projects, each project is: separated, described below:

1. or - representation allows or prohibits

2. Setting the user or group, can use all Except to enhance the defined range

3. Limited sources, such as all, 61.219.230., Local, console, .bad.com .., etc.

Appropriate settings allow your system more secure..

Detailed usage can be man login.access..

34, one ./ skill

As is well known, when performing executables in the current directory in Nix-Like, it is necessary to add ./ These two symbols, many unix-like beginners will feel uncomfortable because in DOS or Windows DOS window and Not like this ..

In fact, in Unix-Like, there is a safe consideration. When using instructions or execution files, it is generally recommended to use a complete directory, for example, to use LS, as follows:

# / bin / ls

Of course, you can directly enter your LS, you can implement correctly because of the factors of environmental variable $ PATH in the shell you use ..

You can type Echo $ PATH to see the current $ PATH settings. When we perform an instruction, the system will search for this execution in accordance with this environment variable.

The internal SHELL will not put the current directory. Add to $ PATH, so if you want to execute the execution file in this directory instead of plus ./, you can take it in your shell. ..

If you usually use TCSH in FreeBSD, you can edit the .cshrc file set path = (........, please click here ..

Remember to re-exit the shell and log in so that your new settings take effect.

35. In the prompt column show [user] current working directory (you can play a lot of PWDs)

# cd / root

Edit .cshrc

# set prompt = "'Hostname -s' #" ### Find this line and MARK

Set proMpt = "[% n]% / #" ### Add this row and departs the disk

# Logout

Login: root .... Re-login

PS. Is other USER ID to be taken? I haven't tried it yet .. Just install FreeBSD

36, RM is a file

Rm -r is Del's entire directory

37. Introduce some useful parameters (note case)..

% B represents high brightness

% N representative user name

% M host name

% / Current catalog

Generally we have more than a few points, as I want to manage several FreeBSD hosts, then the above parameters are very important ..

For example, if I want to change my Prompt to this, and high brightness display:

User name @ host name [directory name]>

Then the PROMPT setting should be like this..

Set prompt = "% b% n @% m [% /]>"

Note that there must be a blank left and right, otherwise it will be wrong, resulting in the unable to log in, and if you want to unify all users' Prompt, except for the change / home / user /.cshrc, it is best in /etc/csh.cshrc This line is set, and if you want to add new users, use this tip, please add (or changed) in /usr/share/skel/dot.cshrc, because: tcsh Refer to the file of /etc/csh.cshrc before use, and then grasp the .cshrc under its home directory, and set usr/share/skel/dot.cshrc is automatically Set its Prompt = "% b% n @% m [% /]>"

This way, when you manage multiple hosts and switch directory, it is not easy to make a misfortune.

转载请注明原文地址:https://www.9cbs.com/read-12767.html

New Post(0)