Debian Reference Manual Chapter 8 - Debian Tips

xiaoxiao2021-03-06  24

[Previous] [Table] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [A] [Next]

Debian Reference Manual Chapter 8 - Debian Tips

8.1 Start System

See LDP Bootprompt-Howto to get detailed information about the system prompt.

8.1.1 "I forgot the root password!" (1)

As long as you can access the console keyboard, you can start the system to log in to the root account without the root password. (Assuming that the boot guide and launch boot and LILO are not required when starting.)

The entire process does not require additional boot discs or modify the BIOS settings. Here, "Linux" is only a label, which represents the Linux kernel installed by defaults to Debian.

In the LILO boot screen, one but boot: (for some systems, you must press the SHIFT button to block the automatic start), enter:

Boot: Linux Init = / BIN / SH

It will indicate that the system starts the kernel run / bin / sh instead of init. Now you have received root privileges and root shells. Since the current / is mounted in a read-only mode, the other hard disk partitions are not mounted, so you have to complete the following steps to get a proper functionality.

INIT-2.03 # mount -n -o remount, rw /

INIT-2.03 # mount-AVT NONFS, NOPROC, NOSMBFS

INIT-2.03 # CD / ETC

INIT-2.03 # vi passwd

INIT-2.03 # vi Shadow

(If the data of all users in the / etc / passwd file is "x", it indicates that the system uses the shadow password, and must edit / etc / shadow.) To delete the root password, please edit the password file Two data fields, set it to blank. Restart the system You can log in to root without password. When the system starts entering Runlevel 1, Debian (at least the version after Potato) requires a password, and some older versions do not need.

It is a good habit where it is a small editor under / bin because sometimes / usr is unacceptable (see Emergency Editor, Section 11.2).

If the SASH package is installed, it can be performed when the system cannot start:

Boot: Linux Init = / Bin / Sash

When / bin / sh is unavailable, Sash can be used as an interactive alternative to SH, which is a static link, built a number of standard tools (enter "Help" in the system prompt to get a reference list).

8.1.2 "I forgot the root password!" (2)

Start the system from the first aid disk. Suppose / dev / hda3 is the original root partition, and the password file can be edited by the following method, which is as easy as the above method.

# mkdir fixit

# mount / dev / hda3 fixit

# cd fixit / etc

# vi shadow

# vi passwd

The advantage of this method is that it does not need to know the LILO password (if any). However, if the system is not pre-set to start from a floppy disk or CD, it is necessary to access the BIOS permission.

8.1.3 Unable to start the system

Didn't make a boot disk during the installation process? It's ok. If LILO is damaged, the boot disk is taken from the Debian installation kit and use it to start the system. Suppose your root partition is in / dev / hda12, you want to enter Runlevel 3, entered after starting the prompt:

Boot: Rescue root = / dev / hda12 3

Next, the system is started using the kernel on the floppy disk, and you can log in to a system that almost all features. (There may be a small amount of characteristics or modules are not available.)

If the system crashes, please also refer to the system installation package that cannot be activated, Section 6.3.6.

If you want to do a custom boot disk, see the Readme.txt document in the first aid disk.

8.1.4 "I don't want to start directly to X!"

Play unsteable / sid is very interesting, but in the startup process, unstable XDM, GDM, KDM, and WDM will make you focused.

First, enter the following instructions after starting the prompt to get the root shell:

Boot: Linux VGA = Normal S

Among them, Linux represents the kernel image you want to start, "VGA = Normal" tells LILO to run, "S" (or "S") under the normal VGA screen is the parameter passed to the init, telling it to enter the single user mode. Enter the root password after the prompt.

There are a variety of ways to disable x to start deaemons:

Run Update-rc.d? DM STOP 99 1 2 3 4 5 6.

INSERT "exit 0" at the start of all /etc/init.d/?dm files.

Rename all /etc/rc2.d/s99?dm files to /etc/rc2.d/k99?dm.

REMOVE All /etc/rc2.d/s99?dm files.

Run:> / etc / x11 / default-display-manager

Among them, RC2.D must match the Runlevel specified in / etc / inittab. • DM represents all XDM, GDM, KDM, and WDM.

There is only the first method "most correct" under Debian. The last method is relatively simple but only for Debian, but also needs to reset once with DPKG-Reconfigure. Other methods are generally suspended daemons.

You can still enter STARTX starting X in any console shell.

8.1.5 Other techniques for starting prompts

Use the LILO boot prompt to specify the system to start to a specific RunLvel and configuration. See Bootprompt-HowTo (LDP) for details.

If you want the system to start to RUNLVEL 4, you can start the prompt after LILO:

Boot: linux 4

If you want the system to start a single user mode of normal function, and you know the root password, you can enter the following parameters after the LILO boot prompt.

Boot: Linux S

Boot: linux 1

Boot: Linux -s

If the system is desired to start with less than the actual memory number (that is, the machine has 64MB of memory, only 48MB to the system), after the LILO starts the prompt post:

Boot: Linux Mem = 48M

Note that do not specify the memory larger than the actual memory number, otherwise the kernel will crash. If you have more than 64MB of memory, such as 128MB, you should execute MEM = 128M when the system is started, or add a similar command line in /etc/lilo.conf, otherwise the old kernel or the old BIOS will not be able to use greater than 64MB. Memory.

8.1.6 How to set the startup parameter (GRUB)

GRUB is a new start manager developed by Hurd project, more flexible than Lilo, but the startup parameters are also slightly different.

GRUB> Find / Vmlinuz

GRUB> root (HD0, 0)

GRUB> kernel / vmlinuz root = / dev / hda1

GRUB> Initrd / Initrdgrub> Boot

Please note the device name in Hurd:

Hurd / Grub Linux MSDoS / Windows

(fd0) / dev / fd0 A:

(HD0, 0) / DEV / HDA1 C: (USUALLY)

(HD0, 3) / DEV / HDA4 F: (USUALLY)

(HD1, 3) / DEV / HDB4?

See /usr/share/doc/grub/readme.debian and / usr / share / doc / grub-doc / html /.

8.2 Activity Record

8.2.1 Record shell activity

System management of UNIX environments contains more meticulous tasks than ordinary personal computer environments. All basic configuration methods must be grasped for system failure recovery. X-based GUI configuration tools look good and convenient, but not applicable to emergencies.

Record shell activities is a good habit, especially root users.

Emacs: Use the m-x shell to start recording in the buffer, write the record in the buffer into the file using C-X C-W.

Shell: Use the Screen Command and "^ a H", see SCREEN to customize the console, Section 8.6.26 or Script command:

$ Script

Script Started, File Is TypeScript

... do wherever ...

Control-d

$ COL -BX Savefile

$ vi savefile

You can also use the following method:

$ Bash -i 2> & 1 | Tee TypeScript

8.2.2 Recording X activity

If the XTERM screen is required, GIMP (GUI) can be used if you need XTERM screen. It can take photos of each window or throughout the screen. You can also use XWD (XBase-Clients), Import (ImageMagick), or Scrot (Scrot).

8.3 Copy and Create subdirectory

8.3.1 Basic orders for copying the entire subdirectory

If you want to rearrange the file organization structure, you can use the following method to move files and file links:

Standard method:

# CP -A / Source / Directory / Dest / Directory # Requires GNU CP

# (CD / Source / Directory && Tar CF -.) | /

(CD / DEST / DIRECTORY & & TAR XVFP -)

If you contain hard links, you need more rigorous methods:

# cd / path / to / old / Directory

# Find. -Depth -print0 | AFIO -P -XV -0A / MOUNT / POINT / OF / New / DIRECTORY

If it is a remote operation:

# (CD / Source / Directory && Tar CF -.) | /

SSH user@host.dom (CD / DEST / DIRECTORY && TAR XVFP -)

If there is no link file:

# SCP -PR User1@host1.dom: / Source / Directory /

User2@host2.dom: / dest / Directory

Among them, SCP <==> RCP, SSH <==> RSH. The following information is published by Manoj Srivastava published in Debian-user@lists.debian.org.

8.3.2 CP

Traditionally, CP does not really complete this task because it does not take differences to the symbolic link and cannot save hard links. Another thing to note is that the sparse file (with a hole file).

The GNU CP overcomes this defect, but for non-GNU systems, there is still a problem. And using CP unable to generate a small and lightweight document package.

% cp -a. newdir

8.3.3 Tar

The TAR overcomes the problem that CP appears during processing symbolic links, however, CPIO can handle special files, but the traditional TAR is not.

For a file with multiple hard links, the TAR processing method is to copy one of the links to the tape, so you can only retrieve the files referred to in the copy in the copy; CPIO will be a link Be a copy, you can find the file referred to in any link.

In Potato and Woody, the TAR command parameters of the .bz2 file have changed, so please use -bzip2 in the script and not to be -i (Potato) or -j (Woody).

8.3.4 PAX

Brand new, in line with POSIX (IEEE STD 1003.2-1992, Pages 380-388 (Section 4.48) and Pages 936-940 (Section E.4.48)) Standard, in-house, lightweight document package interactive tools. PAX can read, write, and list members of the document package and copy the file directory level. The PAX operates independently in a specific document package format, supports a variety of different documentation package formats.

The Pax tool has just been formed and is very new.

# APT-GET Install Pax

$ pax -rw -p e. newdir

oral

$ FIND. -Depth | pax -rw -p e newdir

8.3.5 CPIO

CPIO extracts / puts the file from the CPIO or TAR documentation package. This document package can be another file on the hard disk, or a tape or pipe.

$ FIND. -Depth -print0 | CPIO - Null --SPARSE -PVD New-Dir

8.3.6 AFIO

AFIO is more good at handling documentation in CPIO format. Usually it is faster than the CPIO and provides more tape options, and more friendly processing has false input data. It supports interactive processing multi-volume document package. Making a compressed document package with AFIO is safer than compressed tar or cpio document package. AFIO is a better "Document Processing Engine" in the backup processing script.

$ FIND. -Depth -Print0 | AFIO -PX-0A New-Dir

I use AFIO for all tape backups.

8.4 Difference backup and data synchronization

To make differential backups and data synchronization, you can use the following methods:

RCS: Backup and make history only support text.

RDIFF-Backup: Backup and historical records. Support link.

PDUMPFS: Backup and history of the file system. Support link.

Rsync: Synchronization.

Unison: Dual Synchronization.

CVS: Multi-channel synchronization server backup and historical records, only support text, technology maturation. See CVS, Section 12.1.

Arch: Multi-channel synchronization server backup and history, but includes "directory in work".

Subversion: Multi-channel synchronization server backup and performs history, dedicated to Apache. For discussion of these methods and document package operations, see Copy and Create subdirectories, Section 8.3, and discussions on automatic backups (CRON, AT), Section 8.6.25.

I only explain three more easily used tools.

8.4.1 Difference backup using RDIFF

Rdiff-backup provides a simple way to make historical differences for any files including links. For example, back up all files in the / directory to / mnt / backup:

$ RDIFF-backup - Include ~ / TMP / Keep --ExClude ~ / TMP ~ / / MNT / BACKUP

Remove the old data from 3 days ago from this document package to ~ / ild directory:

$ rdiff-backup -r 3D / mnt / backup ~ / ild

See RDIFF-backup (1).

8.4.2 Make a daily backup using PDUMPFS

PDumpfs is a simple daily backup system that saves system snapshots every day, like DumpFs of Plan9. It can be used to recover to a certain day. Please use pdumpfs and cron to back up your home directory.

In the target directory, PDUMPFS organizes system snapshots in YYYY / MM / DD. For the first time, it copies all source files to the snapshot directory. From each twice, PDUMPFS only copies updated or newly built files, and the hard-linking method for no change is used to save the previous day system snapshot to save the hard disk space.

$ PDUMPFS SRC-DIR DEST-DIR [DEST-BaseName]

See pdumpfs (8).

8.4.3 Using RCS for regular differential backup

ChangeTrack regularly records changes in the text format in the RCS document package. See ChangeTrack (1).

# APT-GET Install ChangeTrack

# vi changetrack.conf

8.5 system freezing recovery

8.5.1 trouble a process

Take a look at what process is abnormal. Press "P" Sort by CPU usage, "M" is sorted by memory usage, "K" can stop a process. There is also a method that uses BSD-style PS AUX | Less or System V-style PS-EFH | Less. The SYSTEM V style will display the parent process ID PPID, which is useful to abort the error (dead) child process.

If you know the ID of the process, you can use KILL to abort (or signal) a process, and KILLALL's role is as named. Regularly used signals are:

1: HUP, restart daemon

15: Term, ordinary stop

9: kill, tone

8.5.2 Alt-SysRQ

The kernel compilation option "Magic Sysrq Key" provides systemic strong needles. After pressing the Alt-sysrq combination key on the i386 machine, try the following key R 0 k e i s u b, the miracle is generated:

Un'r'aw allows the keyboard to reborn from the X crash. Change the console logvel to '0' to reduce the error message. Sa'K '(System Attention Key) aborts all processes in the current virtual console. T'E'rminate aborts all processes outside of INIT. K'I'll suspended all processes outside of IIT.

'S'Ync,' U'mount and RE'B'oot help you escape the real dangers.

When writing this article, the DEBIAN defaults the kernel installed does not compile the option and needs to recompile the kernel to activate the function. Details See /usr/share/doc/kernel-doc-version/documentation/sysrq.txt.gz or /usr/src/kernel-version/documentation/sysrq.txt.gz. 8.6 Remember these lovely small orders

8.6.1 Pager

LESS is Pager (File Content Browser). Press "H" to get help. It is more useful than more. Running Eval $ (LessPipe) or Eval $ (LessFile) in the shell boot script allows LESS vitality. See / USR / Share / Doc / Lessf / Lessopen for details. Use the -R option to output a homophobi and enables ANSI Color Escape Sequences. See LESS (1).

For some coding systems (EUC) W3M may be a better choice.

8.6.2 Release Memory

Free and TOP let you know many useful information for memory resources. Don't worry about "MEM:" in the "Used" size, look at the numbers below (this example is 38792).

$ free -k # for 256MB Machine

Total Used Free Shared Buffers Cached

MEM: 257136 230456 26680 45736 116136 75528

- / buffers / cache: 38792 218344

SWAP: 264996 0 264996

The accurate size of physical memory can be obtained via GREP '^ Memory' / VAR / LOG / DMESG, this example will be displayed "Memory: 256984k / 262144k Available (1652K Kernel Code, 412K RESERVED, 2944K DATA, 152K INIT".

Total = 262144k = 256M (1K = 1024, 1M = 1024K)

Free to dmesg = 256984k = Total - kernel - reserved - data - init

Free to shell = 257136k = Total - kernel - reserved - data

About 5MB memory systems cannot be used because the kernel needs it.

8.6.3 Setting Time (BIOS)

# Date MMDDHMMCCYY

# hwclock --utc --systohc

# hwclock --show

Set the system time and hardware time for mm / dd hh: mm, ccyy. The display time is local time and the hardware time uses UTC.

8.6.4 Setting Time (NTP)

Reference: Managing Accurate Date and Time HowTo.

8.6.4.1 System setting time with permanent Internet connection

Setting the system clock automatically pair by remote servers:

# NTPDATE SERVER

If your system has a permanent Internet connection, you should add this command to /etc/cron.daily.

8.6.4.2 Internet connection system setting time occasionally

Use the Chrony package.

8.6.5 How to Disable Screen Sales

For the Linux console:

# setterm -powersave off

Start the KON2 (Kanji) console executable:

# kon -savetime 0

Run x can be executed: # xset s OFF

or

# xset -dpms

or

# xscreensaver-command -prefs

See the relevant help page.

8.6.6 Search System Management Database

GLIBC provides Getnt (1) search management databases. For example, Passwd, Group, Hosts, Services, Protocols, Networks.

GeTENT DATABASE [Key ...]

8.6.7 Disabled Sound (Bell)

The most direct way is to unplug the PC speaker ;-), for the Bash Shell:

Echo "Set Bell-Style None" >> ~ / .inputrc

8.6.8 Error Information on the Console

Do not want to see the error message displayed by the screen, the preferred method is to check /etc/init.d/klogd, set Klogd = "- C 3" in this script and then run /etc/init.d/klogd restart. Another method is to perform DMESG-N3.

Here are the meaning of various false levels:

0: kern_emerg, the system is not available 1: Kern_Rert, must be executed immediately 2: kern_crit, emergency state 3: kern_err, error status 4: kern_warning, warning status 5: kern_notice, normal status and very important 6: Kern_Info, report 7: kern_debug, Debug-Level Information

If you are disgusted with detailed and useless error messages, you can try this small patch Shutup-Abit-BP6 (in the sample script subdirectory).

Another place to see is /etc/syslog.conf; check whether there is information record to be sent to the console device.

8.6.9 Correct Settings Console Types

In the class UNIX system, the Access Console screen typically wants to call the library routine, which provides the user with a screen update process that optimizes characters independently of the terminal. See NCURSES (3X) and Terminfo (5).

In the Debian system, there is a large number of predefined items:

$ TOE | Less # All items

$ TOE / ETC / TERMINFO / | Less # User Repair Project

Your choice can be exported to the environment variable Term.

When logging in to the remote DEBIAN system, if the Terminfo project of xterm is invalidated in non-debian's xterm, change the terminal type to support less features such as "XTERM-R6". See / USR / Share / Doc / Libncurses5 / FAQ. "DUMB" is the minimum boremi of Terminfo.

8.6.10 restoration console's robustness

If the screen is executed after the $ cat some-binary-file, the screen is chaotic (the return value of the command is in the middle of your input):

$ RESET

8.6.11 Converting the text file under DOS to UNIX type

Convert DOS text files (行 = ^ m ^ j) into UNIX text files (行 = ^ j).

# apt-get install sysutils

$ DOS2UNIX DOSFILE

8.6.12 Replacement of Regular Expression

Replace all from_regex fields in all files for Files ... with a To_Regex field.

$ perl -i -p -e 's / from_regex / to_regex / g;' Files ...

-i means "editing in the ground", -p means "circulating in Files ...." If the replacement is complicated, parameter -i.bak is used instead, which helps error recovery; it saves each original file as a backup file that is a suffix by .bak.

8.6.13 Using the script to edit the script below the file will delete 5-10 rows and 16-20 lines.

#! / bin / bash

ED $ 1 << EOF

16,20d

5,10d

w

Qi

EOF

Here, the ED command is the same as the VI command mode, which makes it more suitable for scriptization from the external editing file.

8.6.14 Extracting the source file modification part merged into the update package

The following operation will extract the modification section of the source file and create a unified DIFF file file.patch0 or file.patch1:

$ DIFF -U file.old file.new1> file.patch0

$ DIFF -U Old / File New1 / File> File.Patch1

DIFF files (also known as patch files) are often used to send program updates. Received patch files Update another file using the following method:

$ PATCH -P0 FILE

$ PATCH -P1 FILE

If there are 3 versions of the source code, use DIFF3 to consolidate more efficient:

$ DIFF3 -M file.mine file.old file.yours> file

8.6.15 Split a big file

$ SPLIT -B 650M File # Pieces large files into multiple 650MB small files

$ CAT X *> Largefile # Mrien all small files into a big file

8.6.16 Extracting data from the table in the text format

Suppose there is a text file named DPL, where all the names of the front Debian project leader and their last day, the table format is separated by spaces.

Ian murdock august 1993

Bruce Peens April 1996

Ian Jackson January 1998

Wichert Akkerman January 1999

Ben Collins April 2001

Bdale Garbee April 2002

Martin Michlmayr March 2003

AWK is often used to extract data from such data.

$ awk '{print $ 3}'

August

April

January

January

April

April

March

$ awk '($ 1 == "Ian") {print}'

Ian murdock august 1993

Ian Jackson January 1998

$ awk '($ 2 == "perens") {Print $ 3, $ 4}'

April 1996

8.6.17 Exquisite Pipe Command Auxiliary Script

The following scripts are very useful as part of the pipeline.

Find / usr | egrep -v "/ usr / var | / usr / tmp | / usr / local"

# Find all Files in / usr excluding some files

Xargs -n 1 Command # Run Command for All Items from stdin

Xargs -n 1 echo | # split white-space-Separated items Into Lines

Xargs echo | # Merge All Lines Into a line

GREP -E Pattern | # extract lines containing patterncut -d: -f3 - |

# xtract third field Separated by: (Passwd File ETC.)

AWK '{Print $ 3}' | # xtract third Field Separated by Whitespaces

AWK -F '/ T' '{Print $ 3}' |

# xtract third Field Separated by Tab

Col -BX | # Remove Backspace and Expand Tabs to Spaces

Expand - | # expand tabs

Sort -u | # sort and remove duplicates

Tr '/ n' '| # Concatenate Lines Into One Line

Tr '/ r' '' | # Remove CR

Tr 'A-Z' 'A-Z' | # Convert Uppercase To Lowercase

Sed 's / ^ / # /' | # make each line a comment

Sed 's //. ext // g' | # remove .ext

Sed -n -e 2p | # Print The Second Line

HEAD-N 2 - | # Print The First 2 Lines

Tail -n 2 - | # Print The Last 2 Lines

8.6.18 Short Perl script

Any AWK script can be rewritten using Perl, such as

awk '($ 2 == "1957") {Print $ 3}' |

You can use any of the following lines:

Perl -ne '@ f = split; if ($ f [1] EQ "1957") {print "$ f [2] / n"}' |

Perl -ne 'IF ((@ f = split) [1] EQ "1957") {Print "$ f [2] / n"}' |

Perl -ne '@ f = split; Print $ f [2] IF ($ f [1] == 1957)' |

Perl -lane 'Print $ F [2] if $ f [1] EQ "1957" |

In fact, the spaces in all perl parameters in the above lines can be removed, which is benefited from the digital string auto conversion function of Perl.

Perl -lane 'Print $ F [2] if $ f [1] EQ 1957' |

Refer to Perlrun (1) for information on command line parameters, there is more fascinating Perl scripts at http://perlgolf.sourceforge.net, you will be interested.

8.6.19 Get text or mailing list document from the web page

The following operations transform the web page into text files. It is useful when copying the configuration file online.

$ lynx -dump http://www.remote-site.com/help-info.html> TextFile

Links and W3M can also be used, but the text style generated may be slightly different.

If it is a mailing list document, you can use Munpack to get MIME content from text.

8.6.20 The operation below the Print web page Printed the web content into a PostScript file or sent to the printer.

$ APT-GET INSTALL HTML2PS

$ HTML2PS URL | LPR

See LPR / LPD, Section 3.6.1. You can also generate a PostScript file using the A2PS and MPAGE packages.

8.6.21 Print Help Page

The following operations print the help page into a PostScript file or send it to the printer.

$ man -tps some-man-point | LPR

$ man -tps some-man-point | mpage -2 | LPR

8.6.22 combining two PostScript or PDF files

Two PostScript files or PDF files can be merged.

$ gs -q -dnopause -dbatch -sdevice = pswrite /

-SoutputFile = Bla.ps -f foo1.ps foo2.ps

$ gs -q -dnopause -dbatch -sdevice = pdfwrite /

-SoutputFile = Bla.pdf -f foo1.pdf foo2.pdf

8.6.23 When the command consumes

Show the time consumption of a process

# Time Some-Command> / Dev / Null

Real 0m0.035s # time on Wall Clock (Elapsed Real Time)

User 0m0.000s # time in User Mode

SYS 0M0.020S # time in keNel Mode

8.6.24 nice command

Use the Nice (from the GNU ShellUtils package) to set the NICE value at the time of startup. Renic (BSDUTILS) or TOP can reset the NICE value of the process. The NICE value is 19 represents the slowest (lowest priority) process; negative value is "not-nice", such as the -20 represents a very fast (high priority) process. Only super users can set a negative NICE value.

# Nice -19 Top # VERY NICE

# nice --20 cdrecord -v -eject speted = 2 dev = 0, 0 disk.img # Very Fast

Sometimes extreme nice values ​​are more harmful to system, so use this command to be careful.

8.6.25 Schedule (CRON, AT)

Use CRON and AT under Linux to make a task schedule. See AT (1), crontab (5), crontab (8).

Execute the crontab -e creation or edit the crontab file, schedule the schedule for the regular transaction (by a cycle cycle). A crontab file below:

# u / BIN / SH To Run Commands, No Matter What / etc / Passwd Says

Shell = / bin / sh

# Mail any output to `Paul ', No Matter Whose Crtab this is IS

Mailto = Paul

# Min Hour dayofmonth Month Dayofweek command (day ... all or'ed)

# Run at 00:05, Every Day

5 0 * * $ homen / bin / daily.job >> $ HOME / TMP / OUT 2> & 1

# Run at 14:15 on The First of Every Month - Output MAILED TO Paul15 14 1 * * $ Home / bin / Monthly

# Run at 22:00 on WeekDays (1-5), Annoy Joe.% for newline, last% for cc:

0 22 * ​​* 1-5 Mail -s "It's 10pm" Joe% Joe, %% WHERE Are Your Kids?%. %%

23 * / 2 1 2 * Echo "Run 23 Minutes After 0AM, 2AM, 4AM ..., ON Feb 1"

5 4 * * Sun echo "Run at 04:05 Every Sunday"

# Run at 03:40 on The First Monday of Each Month

40 3 1-7 * * ["$ (DATE % a) ==" MON "] && command -args

Execute the AT command to schedule the schedule for an accidental task (only a task only):

$ Echo 'Command -Args' | at 3:40 Monday

8.6.26 Use Screen to customize the console

The Screen program allows multiple pseudo terminals to be run in a single physical terminal or terminal analog window, each with its own interactive shell. Even if you can use Linux pseudo terminal or multiple XTERM windows, study how to set up Screen rich features is still very beneficial, including:

Retrospect history showing, copying and paste, output to the log, graphics port, separating the terminal with the entire Screen session, later connected.

8.6.26.1 Remote Access Scheme

If you frequently log on to a Linux machine If you register from the remote terminal to the Linux machine or use the VT100 terminal program, Screen's Detach features will simplify your life.

Log in by the coamentation connection, run a very complex Screen talk, open several windows, have editors and other programs. Suddenly, you need to leave the terminal, but you don't want to hang up the connection to stop working. Enter ^ a d Leave the session and log out the system. (Or easier, enter the ^ A DD leave the session and automatically log out the system) When you come back, you need to log in again. You can enter the command screen -r, and Screen will reconnect all open windows like magic.

8.6.26.2 Typical Screen Command

One, open the Screen program, in addition to the command button (default ^ a) All keyboard inputs are sent to the current window, all Screen commands are entered in a specific way: ^ A plus a single button command [plus some parameters] . Commonly used orders are:

^ A? Display help screen (display command set)

^ A c creates and switches to a new window

^ A n jumps to the next window

^ A p jumps to the previous window

^ A 0 jumps to the window

^ A W Display window list

^ A a Use Ctrl-A as a keyboard input to the current window

^ A h writes to the file on the current window

^ A h Start / abort the current window event to file

^ A ^ x lock terminal (password protection)

^ A d from the terminal separation screen session

^ A DD Separate the screen session and exit login

The above is just a small subset of the Screen command. As long as you think SCREEN can do, you can really! See Screen (1) for details. 8.6.26.3 Retrans and Ctrl-h in Screen Session

When running Screen, if you find that the retracter and / or Ctrl-H cannot work properly, edit / etc / screenrc, find this line:

Bindkey -k kb stuff "/ 177"

Release this (for example, add "#" in the sentence).

8.6.26.4 x with Screen equivalents

Look for Xmove. See XMOVE (1).

8.6.27 Network Test Foundation

Install Netkit-Ping, Traceroute, DNSUTILS, IPChains, IPTables (for version 2.4 kernel) and NET-Tools package, then execute:

$ ping yahoo.com # Check the Internet connection

$ traceroute yahoo.com # Track IP packets

$ IFCONFIG # Check host settings

$ route -n # Check routing settings

$ DIG [@ DNS-SERVER.com] host.dom [{a | mx | any}] | Less

# Check the Host.DOM DNS record of DNS-SERVER.com

# 查 m | any} record

$ ipchains -l -n | less # Check Pack Filter (2.2 Kernel)

$ iptables -l -n | less # Check Pack Filter (2.4 kernel)

$ NetStat -a # Find all open ports on the system

$ NetStat -l - IT # Find the port of the system listener

$ NetStat -ln --TCP # Find the TCP port of the system listener (port number)

8.6.28 Clearing from the local buffer pool (FLUSH) mail

Email the email from the local buffer pool:

# EXIM -Q # Empty to read mail

# ei -qf # Clear all mail

# EXIM -QFF # Empty freeze email

The -QFF option is better in the /etc/ppp/ip-up.d/exim script.

8.6.29 Deleting Frozen Mail in Local Buffet Pool

Delete the frozen email in the local buffer pool and return an error message:

# EXIM -MG `Mailq | grep frozen | awk '{print $ 3}'` `

8.6.30 Reissue letters in MBOX

If the Home directory does not have a space to continue to process the message, you need to expand the disk space. After the expansion is complete, you need to manually distribute the mailbox in the / var / mail / username directory to the home directory, execute:

# /etc/init.d/EXIM STOP

# formail -s procmail

# /etc/init.d/exim start

8.6.31 Empty Document Content

To empty some files such as log files, don't use RM to delete files and create a new empty file because the system may need to access the file. Below is a safety method for emptying the content:

$: file-to-be-cleared

8.6.32 empty file

The following command can create an empty file:

$ dd if = / dev / zero of = filename BS = 1K count = 5 # 5kb of zero content $ dd if = / dev / urandom of = filename BS = 1M count = 7 # 7MB of Random Content

$ Touch FileName # Create 0b File (if File EXISTS, UPDATES MTIME)

For example, the most practical usage is to perform the following commands from the Shell of the Debian boot floppy disk to complete the content of the hard disk / dev / hda.

# DD if = / dev / urandom of = / dev / hda; DD if = / dev / zero of = / dev / hda

8.6.33 Chroot

Chroot programs, Chroot (8), do not need to restart the system, you can run multiple different GNU / Linux environments simultaneously on separate systems.

You can also run some programs such as APT-GET and DSELEC to run at the changing host's Chroot, and mounted the hard disk of the slower machine to the host through the NFS method, open read / write permission. The host operator is operated in a chroot.

8.6.33.1 Use Chroot to run different versions of Debian

Use the debootstrap command in Woody to easily construct the Chroot Debian system. For example, create a sid chroot under a machine with a speed Internet connection:

Main # cd /; mkdir / sid-root

Main # debootstrap Sid / Sid-root http://ftp.debian.org/debian/

... Watch It Download The Whole System

Main # echo "proc-sid / sid-root / proc none 0 0" >> / etc / fstab

Main # mount proc-sid / sid-root / proc -t proc

Main # cp / etc / hosts / sid-root / etc / hosts

Main # chroot / sid-root / bin / bash

Chroot # apt-setup # set-up /etc/apt/sources.list

Chroot # vi /etc/apt/sources.list # Point The Source To Unstable

Chroot # dselect # You may use aptitude, install mc and vim :-)

Now you have a full-featured Debian subsystem, you can enjoy it without having to worry about the adverse effects of the main Debian.

The Debootstrap application skills can also be installed under another GNU / Linux release without a debian installation disk. See http://www.debian.org/releases/stable/i386/ch-preparing#s-linux-upgrade.

8.6.33.2 Set Chroot Login

Enter chroot / sid-root / bin / bash is very simple, but this will take all current environment variables, you may not want this and sometimes problems. A better way is to perform another login process on other virtual terminals, log in to the chroot directory.

Run the Linux console from TTY1 to TTY6 in the Debian system, TTY7 runs the X WINDOW system, in this case, we set TTY8 to the Chroot console. After running different versions of Debian, sections in Section 8.6.33.1, you can enter: Main # echo "8: 23: Respawn: / usr / sbin / Chroot / Sid-root "/

"/ sbin / getty 38400 tty8" >> / etc / inittab

Main # init Q # reload init

8.6.33.3 Configuring x under Chroot

Want to run the latest version of X and GNOME safely under Chroot? absolutely okay! The following example will implement the GDM under the virtual terminal VT9.

First, install the Chroot system according to the method described in Section 8.6.33.1 in Section 8.6.33.1 in accordance with Chroot, copy the key configuration file to the Chroot system under the ROOT system.

Main # cp / etc / x11 / xf86config-4 / sid-root / etc / x11 / xf86config-4

Main # chroot / sid-root # or usch chroot console

Chroot # Apt-Get Install GDM GNOME X-WINDOW-SYSTEM

Chroot # vi /etc/gdm/gdm.conf # DO S / VT7 / VT9 / IN [Servers] Section

Chroot # /etc/init.d/gdm start

Here, edit /etc/gdm/gdm.conf to create a virtual terminal on VT7 to VT9.

You can now easily switch Linux virtual terminals to transform between the X environment of the primary system and the X environment of the ChrooT system, such as Ctrl-AlT-F7 and Ctrl-Alt-F9. Cool!

[FixMe] Add a comment and a link to the init script of GDM under the Chroot System.

8.6.33.4 Use Chroot to run other release

It is easy to create a Chroot environment that contains other releases. Install them into separate hard disk partitions using other releases. For example, the root partition is located in / dev / hda9.

Main # cd /; mkdir / other-dist

Main # mount -t ext3 / dev / hda9 / other-dist

Main # chroot / other-dist / bin / bash

The next work is running with Chroot to run different versions of Debian, Section 8.6.33.1, setting Chroot Login, Section 8.6.33.2 and configuring the contents described in Section 8.6.33.3, which are basically similar.

8.6.33.5 Using Chroot to compile the package

There is a very special chroot package PBUilder, which constructs a chroot system and compiles the package. The system can be used to check if the association relationship is correct when the software package is compiled, and ensure that there is no unnecessary or error associated relationship in the bundled package.

8.6.34 How to check hard links

Check if two files are two hard links to the same file:

$ ls -li file1 file2

8.6.35 mouns file on the mount hard disk

If the file.img file is the mirror file of the hard disk content, and the original hard disk configuration parameter is xxxx = (bytes / sector), then the following command is mounted to / mnt:

# mount -o loop, offset = xxxx file.img / mnt

Note that most of the hard drives are 512 Bytes / Se. 8.6.36 Samba

Get the basic method of the Windows file:

# mount -t smbfs -o username = myname, uid = my_uid, gid = my_gid /

// Server / Share / MNT / SMB # mount windows files to Linux

# SMBMOUNT / / SERVER / Share / MNT / SMB /

-o "username = myname, uid = my_uid, gid = my_gID"

# SMBCLIENT -L 192.168.1.2 # List the share on a class

Samba online neighbors can be checked from Linux:

# SMBCLIENT-N -L IP_ADDRESS_OF_YOUR_PC | LESS

# nmblookup -t "*"

8.6.37 Operating Tools of Foreign File System

The Linux kernel supports a variety of foreign file systems, and wants to access them just under the appropriate file system. For some file systems, special tools are also providing mount, relying on programs that rely on user space, and do not require the kernel to provide file system support, access.

Mtools: for MSDOS FileSystem (MS-DOS, Windows) CPMTools: for cp-m FileSystem Hfsutils: for HFS FileSystem (Native Macintosh) HFSPLUS: For HFS FileSystem (Modern Macintosh)

It is very useful for creating and checking the MS-DOS FAT file system DOSFSTools.

[Previous] [Table] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [A] [Next]

Debian reference manual

CVS, Saturday, Jan 14 23:05:59 Utc 2005osamu Aoki Osamu@debian.orgtranslator: hao "lyoo" liu iamlyoo@163.net author, para 1.1

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

New Post(0)