Linux operation skills. (increasing)

xiaoxiao2021-03-06  15

Linux operation skills. (increasing)

-Tip1 View MAN files ... nroff -man man / libnet.3 | Less

Sometimes the MAN file is not in the system directory .. This time you can use the above way to view non-standard MAN files.

-Tip2 runs the program as different users ...

Su - username -c "where / is / command / line"

Sometimes you need to run a special identity ... you can let Su come ...

-Tip3 decompressed BZ file

Tar -jvxf some.bz

It is to change the ZVXF of Tar into JVXF.

-Tip4 is directly effective after editing / etc / inittab..

Implement init Q

-Tip5 allows Linux to perform several commands continuously, stop

Command1 && Command2 && Command3 ....

-Tip6 Linux BG and FG Management

When we play Ctrl Z, a task is hang (it is suspended), and a number is returned on the screen.

At this time, "BG%" can be used to put this process in the background ... this is very suitable for your forgetting

& Time to remedy ... The same "fg%" can make this process to the front desk to execute ...

Use the job command to see the current BG process ...

-Tip7 Ctrl S with Ctrl Q

Ctrl-s seems to be in Dongdong, traffic control from the terminal era, used to suspend data to the terminal. Ctrl-q is used to restore recovery

-Tip8 directory statistics

Save into total.sh, then use Total.SH absolute path, the size of the directory under the statistics path

Code:

#! / bin / sh

DU $ 1 --MAX-Depth = 1 | Sort -n | awk '{Printf "% 7.2FM ---->% S / N", $ 1/1024, $ 2}' | sed 's: /.*// ([^ /] / {1, /} /) $: / 1: g '

-Tip9 grep does not display its own process

Code:

PS -AUX | GREP HTTPD | GREP -V GREP

You can cancel the process of the Grep itself you executed again by again, and the -v parameter is not displayed.

-Tip10 uses a statistical httpd script

Code:

#! / bin / sh

While (True)

DO

PStree | grep "* / [httpd /] $" | sed 's /.*-/ ([0-9] [0-9] * /) / * / [httpd /] $ // 1 /'

Sleep 3

DONE

-Tip 11 decompress the file in the RPM package

Code:

Cat gnome-libs-1.4.1.2.90.22.i386.rpm | rpm2cpio | pax -r

-Tip12 Removes all of the apache's humanual directory, the suffix name

Enter into the manual directory

Code:

Find ./Regex. * /. En | awk -f. '{Printf "MV% S.% s.% s.% s.% s.% s / n", $ 1, $ 2,3, $ 4 $ 1, $ 2, $ 3} '| SH

-Tip 13 Linux How to map hard disk mount -t smbfs -o usrname = xxx, password = xxx // winxp_ip_or_hostname / shareName / local_pathfc2 is already required.-TIP 14 Linux How to view available Hard disk device fdisk -l

[zt] form rexhsu's bbshttp: //rexhsu.minidns.net/~irc/discuz/viewthread.php? TID = 13

Linux Useful Tips (Collected by Rexhsu @ CCF)

-Tip1 command line Make ISO usage: mkisofs -a -i -j -r-portname.iso / directory

Uses: Make all the files in a directory under Linux. And I added the parameters to ensure that the discs you have made are also available under Windows (ISO is file size restrictions ... How much is it forgotten?

-Tip2 Linux under the virtual method of ISO

Proceed as follows:

1. Delete / dev / cdrom, then run ln -s / dev / loop7 / dev / cdrom

2. Losetup / dev / loop7 xxx.iso

3. Mount / MNT / CDROM

How to change the disc:

1. Losetup -d / dev / loop7; purpose is to cancel this device

2. Losetup / dev / loop7 yyy.iso; new ISO file

-Tip3 hosts usage

Host can use to query domain names, but it can get more information. Host -t mx Linux.com can query Linux.com's MX records, and the name of HOST to handle Mail. Host -l Linux.com will return all Register the domain name under Linux.com. Host -a Linux.com displays all domain name information of this host.

-Tip4 * .bz2 file how to decompress

You can use the TAR -I or Bunzip2 command.

-Tip5 rpm common usage

Displays the progress and check the correctness when the RPM package is installed

Use -VH parameters:

RPM-IPChains-1.3.6-1.i386.rpm

If you use GLINT or XRPM, you don't have to.

Install the RPM package directly through FTP

Such as rpm -i ftp://ftp.xxx.xxx

Check all RPM packs to find lost files

RPM -VA

Find a file that belongs to which RPM package

RPM -QF / USR / BIN / WHO

List the description of an RPM package

RPM -QPI MON-0.37J-1.I386.RPM

List the file information of an RPM package

Such as RPM -QPL MON-0.37J-1.I386.rpm

-Tip6 View system listening service

Usage: netstat -ln

Explanation: "L" indicates the port information that displays the current system listener; "n" indicates that the port is displayed in the port number without converting the port name defined in the service file; if you want to know which process listeners can be listened by each port Use a P parameter.

-Tip7 View system running process

Usage: ps -auxw

Explanation: The parameter "a" represents the process of all users in the system; "U" indicates the information of the output process user; "X" means that there is no console process; if the display line is too long, it can be used. f Parameters.

-Tip8 Linux account moving

For new accounts ->

Ensure that the new account to be added to the new account is placed in a new location, which is implemented by modifying the Home value in the / etc / default / usradd file. For example, home = / home2 makes the new account's main catalog under / home2.

Move existing account to a new location ->

First, copy the main directory of the existing account to the new location, available below:

Cp -a / home / home2

or

cp -rpd / home / home2

Then, modify the HOME_DIRECTORY domain recorded in the / etc / passwd file is / home2 / username.

This two steps have moved the old account to a new location. Make sure you can delete the older directory of the old account to make the space for the original file system.

-Tip9

The information displayed when Linux is started. If you see it, you can view it if you are interested in this information, you can use the command dmesg to view after startup.

-Tip10 GRUB boot recovery small law

Enter Linux with boot disk or installation disk (Linux Rescue)

SH # grub

Grub> root (hdx, y)

GRUB> Setup (HD0)

Restart

Description: If there will be a successful ... here X, if it is a disk, it is 0. If you installed Linux root partitions on the second hard disk, then x is 1; Y is The root partition in the Linux system .Setup (HD0) is written on the MBR of the hard disk. If I know my Linux is put on the first hard disk, but I don't know which partition is installed, you can first Enter root (HD0, then use the [Tab] button to make up, then understand.-TIP11 test disk performance

Usage: HDPARM-TT / DEV / HD?

For example: hdparm -tt / dev / hda (testing the speed of the first physical hard disk)

-Tip12 opens the internal network service

The 8888 port on 192.168.1.2 is mapped to the 192.168.1.3 8888 port.

#iptables -t nat -a preloading -p tcp -m TCP - Dport 8888 -J DNAT - TO-DESTINATION 192.168.1.2:8888

#iptables -t nat -a postrouting -s 192.168.1.0/24 -d 192.168.1.2 -p TCP -M TCP - Dport 8888 -J Snat --to-Source 192.168.1.3

#iptables -a input -p tcp --dport 8888 -i eth0 -j accept (increased)

-Tip13 Close "Nasty" Linux button Beep

Vi /etc/.inputrc Adds the following line

Set Bell-Style None

-Tip14 boot into graphics / text login method

Vi / etc / inittab

ID: x: InitDefault:

X = 3: Text Way x = 5: Graphical mode

-Tip15 restricts the number of memory usable in GRUB

Limit Linux only 120MB of memory

Title Red Hat Linux (2.4.19)

root (HD0, 1)

KERNEL /BOOT/VMLINUZ-2.4.19 RO ROOT = / dev / hda2 MEM = 120M

Initrd /boot/initrd-2.4.18-14.img

-Tip16 How to find a library file for a command

Implement the LDD command in the Linux environment, execute in the console:

LDD / BIN / LS

You can get the list of library files for / bin / ls commands.

-Tip17 only listing (file)

LS -F | GREP / $

You can also make this command into Alias ​​in .Bashrc (for Bash), you can implement the only list of subdirectory as long as you type subdigue.

Alias ​​Sub = "LS -F | GREP / $"

Similarly, ls -l | grep ^ - is only a normal file.

-Tip18 calculate files and subdirectory in the directory

LS -AL | WC -L

-Tip19 redhat Displays a list of color directory

Ls -color can display a list of color directory, where:

Blue → catalog

Green → executable

Red → Compressed file

Light blue → linked file

Gray → Other files

Also you can also try LS - COLOR (more than before -), see the difference between the two.

-Tip20 column directory display Chinese file name

In the Linux system without patch, we use the LS column directory and found that the Chinese file name is it? We can use the --show-control-chars command option to display.

LS --SHOW-Control-Chars

-Tip21 changes all directories and files of the current path

chown -r owner [.group] *

You can also use the find command to implement:

Find. -exec chown owner [.group] {};

-Tip22 changes the properties of all subdirectories and files

Enter the command in the directory you want to change the property:

CHMOD -R 777 *

You can change the properties of all subdirectories and files below, but you must be particulartime when using this command. If you are in the root directory, you will change the properties of all your files, which will cause great security. Question.-TIP22 uses the NOHUP command

If you want the process, you can use the NOHUP command after you can exit the system.

Such as:

Nohup Tar CF / DEV / TAPE / HOME &

If you exit, log in again, use the PS command to find the process is still executing.

-Tip23 restart

CTRL Alt Del or Init 6 or Shutdown -R Now

-Tip24 Quick Find File

Find files can be used with Find, but it is best to use locate. Speed ​​fast and less parameter.

Locate FileName

It is looking for in a database. So, I have to remember to update the database frequently with the updatedb command. Generally, we add a sentence in crontab, let the machine update the database late at night.

Also, quickly find the command file, you can use whereis.

E.g:

WHEREIS rpm

-Tip25 look up Linux command

If you want to implement some feature, don't know what to use. You can try the apropos command, which may help you find the command you want. For example: You want to find a file, don't know what to use , You can knock into the following command:

Apropos Search

-Tip26 executes multiple commands at the same time on the same command line

Separate with a semicolon. Such as compiled a source file:

#. / configure; make; make install

-Tip27 uses Gzip (Gunzip) compressed (decompressed) multiple files in the same directory

Gzip * or gunzip *

-Tip28 Starts VI directly when using LESS or More

In the LESS or MORE to enter the V key, start the VI editor immediately and edit the file.

-Tip29 Starts VI in using Mail

If you feel that it is very inconvenient to send mail with Mail, you can enter ~ v, start the VI for editing, and return to Mail after editing.

-TIP30 observation file size change

Using the watch command, you can repeatedly execute the command. And the LS cooperation can achieve the effect of observing the size of a file size.

Watch ls - | file.name

-Tip31 looks for files with specific strings

For example, find the file containing the "The String You Want Find ..." string in the current directory:

-Tip32 Watch the string in the binary file

Strings binaryfile

-Tip33 reloading WIN 9X LILO failure unable to start Linux

You only have to start Linux with a floppy and then run a lilo. You can use the command mkbootdisk to make the boot disk with the command mkbootdisk, for example:

Mkbootdisk - DEVICE / DEV / FD0 2.4.20

2.4.20 is a directory under / lib / modules.

-Tip34 removes LILO information in the boot area

If you install LILO, if there is a change in the number of hard drives, the hard disk will cause the hard disk to be unable to start, then you only need to start the DOS with a floppy disk and then run the fdisk / MBR.

-Tip35 change DOS / Windows to the default operating system

Redhat as a LILO default operating system, which appears boot: The prompt is directly carried to start Linux. If you want to change to DOS / Windows, modify the file /etc/lilo.conf, put the part of the Start DOS in front, Run once again. You can also add default = DOS in front of the profile profile of lilo.conf, DOS is the Label of DOS / Windows.

-Tip36 how to use .iso file

Many Linux distributions have a .iso CD mirror file, which can be used to burn disc. We can also use them directly under Linux systems.

Mount -t ISO9660 XXXXX.ISO / ANY / PATH / IF / U / LIKE -O LOOP

-Tip37 Displays the type of file

Use the command file to make you know that a file is an executable file in the ELF format, or the shell script file or other format.

File filename

-Tip38 decompressed .tar.gz file xxxx.tar.gz file Using the TAR with ZXVF parameters, you can decompress once.

Tar zxvf xxxx.tar.gz

-Tip39 background running program

You can run the "&" symbol after the program, allowing the program to run in the background. For example: You want to update the file path database with UpdatedB, and do not affect your other work. Yes:

Updatedb &

-Tip40 forcibly exit X

Sometimes I don't work in X because the program is wrong, I don't have to worry about it, because it is almost like a malignant crash in Win 95, you only need to press the Ctrl Alt Backspace button at the same time. Go back to the character interface.

-Tip41 compressed executable

You can use GZEXE to compress the executable, and the compressed executable can still be executed directly. Use this method to achieve the purpose of saving disk space (if you really need it).

Gzexe gawk

-Tip42 Processes files with special characters in the file name

If there is a file name called -file, if you want to delete it, type the RM -File will display the Invalid Option. It is originally "Due to the first character of the file name" - ", Linux makes the file name as an option, you can add - Solve This problem, such as RM - -file. If you are other special characters, you can add one / in front of the special character, or enclose the entire file by double quotes.

-Tip43 quickly enter the directory

Type CD ~ You can enter the user's Home directory; type CD - to enter the previously entering directory.

-Tip44 wants all to delete. How will you do when the file or dir?

WRONG-> rm -r /tmp/.*

Correct-> rm -r /tmp//.

-Tip45 Modify NIC MAC Address

IFConfig Eth0 Down

IFCONFIG Eth0 HW Ether 00: AA: BB: CCD: EE

Ifconfig eth0 up

The above is temporary, you can join RC.Local to let it turn on automatically

-Tip46 View NIC Work Status

# mii-Tool -V

Eth0: No Link

Product Info: vendor 00:00:00, Model 0 Rev 0

Basic Mode: AutoNegotiation Enabled

Basic Status: No Link

Capabilities: 100BaseTX-FD 100BaseTX-HD 10BaseT-FD 10BaseT-HD

Advertising: 100BaseTX-FD 100BaseTX-HD 10BaseT-FD 10BaseT-HD

Siocgmiiphy on 'Eth1' Failed: Operation Not Supported

-Tip47 How to resolve Sendmail and SM-Client boot problems!

Slowness caused by Sendmail and SM-Client because of parsing problems, solutions to add their hostnames to / etc / hosts, for example, my host name is LinuxBox.localDomain / etc / hosts should have one

192.168.100.1 LinuxBox.localdomain Linuxbox

-Tip adds a service to CHKCONFIG - ADD HTTPD in Self-Start Run Level

Chkconfig --level 3 httpd on

That is to add HTTPD to ChkConfig management and add it in the third layer.

-Tip's Upset volume

AUMIX

-Tip exports the Man file as a file and remove the control

Man Command | Col -B> col.txt

COL -B is removed

-Tip view folder size

du ./max-defth = 1

--MAX-depth = 1 is the control display depth

-Tip drive pop-up, income

Eject -R pops up

Eject -T population

-Tip display recently logged in user

Last or above is useful under redhat 8. Didn't tried it in other systems?

1. Run VNC error, prompt xvnc: Error While Loading Shared Libraries: libstdc - libc6.2-2.so.3

Find a Compat-libstDC - 7.3-2.96.118.i386.rpm installed

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

New Post(0)