Linux Operating Skills-general Linux technology-Linux technology and application information. For more information, see the following section. 1. view the man file...
Nroff-man/libnet.3 | less
Sometimes man files are not in the system directory. At this time, you can use the following method to view non-standard man files.
2. Run the program as a different user...
Su-username-c "where/is/command/line"
Sometimes you need to run a program with a special identity to let su do it...
3. decompress the bz File
Tar-jvxf some. bz
Change zvxf of tar to jvxf.
4. Edit the/etc/inittab and the method takes effect directly ..
Run init q
5. Let linux Execute several commands consecutively and stop when an error occurs.
Command1 & command2 & command3 ....
6. bg and fg Management in linux
When we press ctrl + z, a task is suspended (that is, paused), and a number is returned on the screen, at this time, you can use "bg % Number" to put this process into the background for execution... this is a perfect remedy when you forget to add... similarly, "fg % Number" allows this process to be executed on the frontend...
The job command is used to view the current bg process...
7. ctrl + s and ctrl + q
Ctrl-s is like a thing inherited from the terminal era, traffic control, used to suspend sending data to the terminal. ctrl-q is used to restore recovery
8. Directory statistics tutorial
Save it as total. sh, and then use the absolute path "total. sh" to calculate the directory size under the path.
#! /Bin/sh
Du 1 -- max-depth = 1 | sort-n | awk '{printf "% 7.2fM ----> % s \ n", 1/1024, 2}' | sed's :/. */\ ([^/] \ {1, \} \): \ 1: G'
9. grep does not display its own process
Ps-aux | grep httpd | grep-v grep
You can use grep-v grep again to cancel displaying the grep process you are executing. The-v parameter does not display the listed process name.
10. A script used to count httpd
#! /Bin/sh
While (true)
Do
Pstree | grep "* \ [httpd \]" | sed's /. *-\ ([0-9] [0-9] * \) \ * \ [httpd \]/\ 1 /'
Sleep 3
Done
11. decompress the files in the rpm package
Cat gnome-libs-1.4.1.2.90.22.i386.rpm | rpm2cpio | pax-r
12. Remove the suffix of all. en in the manual directory of apache.
Go to the manual directory
Find. /-regex. *\. en | awk-F. '{printf "mv % s. % s. % s. % s. % s. % s \ n ", 1, 2, 3, 3} '| sh
13. How to map hard disks in windows in linux
Mount-t smbfs-o username = xxx, password = xxx // winxp_ip_or_hostname/sharename/local_path
-T smbfs is no longer required in fc2.
14. How to view available hard disk devices in linux
Fdisk-l
15. Create ISO under the command line
Usage: mkisofs-a-I-J-r-o filename. iso/directory
Purpose: Make all files in a directory in linux into an iso image. in addition, I have added parameters to ensure that the disc you created can also be used in windows (iso has file size restrictions...)
16. Virtual Methods of ISO in Linux
The procedure is as follows:
1. delete/dev/cdrom and run ln-s/dev/loop7/dev/cdrom.
2. losetup/dev/loop7 xxx. iso
3. mount/mnt/cdrom
How to change Disk:
1. losetup-d/dev/loop7; to cancel this device
2. losetup/dev/loop7 yyy. iso; new iso file
17. hosts usage
Host can be used to query domain names, but it can get more information. host-t mx linux.com can query the MX record of linux.com and the host Name of the mail processing host. host-l linux.com will return all domain names registered under linux.com. host-a linux.com will display all Domain Name Information of this host.
18. *. How to decompress the bz2 File
You can use the tar-I or bunzip2 command.
19. Common RPM usage
Displays the progress when installing the rpm package and verifies the correctness of the package.
Use the-VL parameter:
For example, rpm-ivh ipchains-1.3.6-1.i386.rpm is not required if glint or xrpm is used.
Install rpm packages such as rpm-I ftp://ftp.xxx.xxx directly through ftp
Verify all rpm packages and find the missing file rpm-Va
Find the rpm package of a file, such as rpm-qf/usr/bin/who
Lists descriptions of an rpm package, such as the rpm-qpi mon-0.37j-1.i386.rpm
Listing file information for an rpm package, such as the rpm-qpl mon-0.37j-1.i386.rpm
20. view the services monitored by the System
Usage: netstat-ln
Explanation: "l" indicates the port information of the current system listener; "n" indicates that the port is displayed according to the port number without being converted to the port name defined in the service file; if you want to know which processes listen on each port, you can use the p parameter.
21. view the processes running by the System
Usage: ps-auxw
Description: The parameter "a" indicates that processes of all users in the system are displayed; "u" indicates the information of the output process user; and "x" indicates that there are no processes in the console; if the displayed row is truncated because it is too long, the f parameter can be used.
22. Migration of Linux accounts
For a new account->
Are you sure you want to add the new account to the system in the new location? You can modify the HOME value in the/etc/default/useradd file, for example, HOME =/home2.
Move an existing account to a new location? ->
First, copy the home directory and associated directory attributes of an existing account to the new location ?, Run the following command:
Cp-a/home/home2 or cp-rpd/home/home2
Then, modify the home_directory domain of the corresponding record in the/etc/passwd file to/home2/username.
In these two steps, the old account has been moved to the new location ?. After the preceding settings are correct, delete the old main directory of the old account to free up the space of the original file system.
23. information displayed on the screen at startup
When Linux is started, the information displayed on the screen is too late to be visible. If you are interested in the information, you can run the dmesg command to view it after it is started.
24. GRUB boot recovery tips
Linux rescue
Sh # grub
Grub> root (hdx, y)
Grub> setup (hd0)
Restart
NOTE: If it succeeds, there will be a successful ...... here, if x is a disk, It is 0. if the linux Root partition you install is on the second hard disk, x is 1, and y is the root partition where the linux system is installed. setup (hd0) is to write GRUB to the hard disk MBR. if I know that my linux is installed on the first hard disk, but I don't know which partition It is installed on, I can enter root (hd0, and then use the [TAB] key to complete it, then you will understand.
25. Test disk Performance
Usage: hdparm-tT/dev/hd?
Example: hdparm-tT/dev/hda (test the speed of the first physical hard disk)
26. Open Intranet services to the outside world
Map port 8888 on 192.168.1.2 to port 8888 on 192.168.1.3
# Iptables-t nat-a prerouting-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 (add as appropriate)
27. Disable the "annoying" Linux button Beep
Vi/etc/. inputrc Add the following line
Set bell-style none
28. Graphic/text login Mode
Vi/etc/inittab
Id: x: initdefault:
X = 3: text mode x = 5: graphic mode
29. limit the amount of memory available to the system in GRUB
Linux can only use MB of memory
Title Red Hat Linux (2.4.19)
Root (hd0, 1)
Kernel/boot/vmlinuz-2.4.19 ro root =/dev/hda2 mem = 120 M
Initrd/boot/initrd-2.4.18-14.img
30. How to Find the related library files of a command
Run the ldd command in Linux and run the following command on the console:
Ldd/bin/ls
You can get the list of related library files of the/bin/ls command.
31. Only column sub-directories (files)
Ls-F | grep/
You can also. in bashrc (for bash), this command is used as alias. You only need to input sub to implement the column-only sub-directory function. alias sub = "ls-F | grep/" Similarly, ls-l | grep ^-only columns common files.
32. Files and subdirectories under the computing directory
Ls-al | wc-l
33. display the color directory list under RedHat
Ls-color displays the color directory list, in which: Blue → directory green → Executable File red → compressed file light blue → linked file gray → other files
Similarly, you can try ls -- color (more than above-) to see the difference between the two.
34. display the Chinese file name in the column directory
In a Linux system without patching, we used the ls column directory to find that all Chinese file names have become? No. We can make
Use the -- show-control-chars Command Option to display.
Ls -- show-control-chars
35. Change the ownership of all directories and files in the current path.
Chown-R owner [. group] *
You can also use the find command to implement: find.-exec chown owner [. group] {};
36. Change the attributes of all subdirectories and files
In the directory where you want to change the attributes, enter the command: chmod-R 777 *
You can change the attributes of all the subdirectories and files below, but you should be very careful when using this command. If you enter this command in the root directory, the attributes of all your files will be changed, this will cause a lot of security problems.
37. Use the nohup command
If you want the process to be executed after you exit the system, you can use the nohup command.
For example: nohup tar cf/dev/tape/home &
If you log out and log on again, you can use the ps command to find that the process is still running.
38. Restart
Ctrl + Alt + Del or init 6 or shutdown-r now
39. Quick file search
You can use find to find files, but it is best to use locate. The speed is fast and the number of parameters is small.
Locate filename
It is searched in a database. Therefore, remember to often use the updatedb command to update the database. Generally, we add a sentence in the crontab to let the machine update the database late at night every day.
In addition, you can use whereis to quickly find the command file.
Example: whereis rpm
40. Search for Linux commands
If you want to implement a certain function, but do not know what command to use, you can try the apropos command, it may
You can find the command you want. For example, if you want to "Search" the file and do not know what command to use, you can run the following command:
Apropos search
41. Execute multiple commands simultaneously on the same command line
Separated by semicolons. For example, compile a source file:
#./Configure; make install
42. Use gzip to compress (decompress) multiple files in the same directory
Gzip * or gunzip *
43. When using less or more, directly start vi
Press the v Key in less or more to immediately start the vi editor and edit the file.
44. Start vi in mail
If you think it is inconvenient to use mail to send and edit emails, you can enter ~ V, start vi to edit, exit vi after editing, and return to mail.
45. Observe file size changes
The watch command can be used repeatedly to execute commands. It can work with ls to observe the changes in the size of a file.
Watch ls-| file. name
46. View strings in binary files
Strings binaryfile
47. After Windows 9x is reinstalled, lilo cannot start Linux.
You only need to start Linux with a floppy disk and run lilo once. For RedHat, run mkbootdisk to create a boot disk, for example, mkbootdisk -- device/dev/fd0 2.4.20.
2.4.20 is a directory under/lib/modules.
48. Remove lilo information in the boot Zone
After lilo is installed, if the number or partition of the hard disk changes, the hard disk cannot be started. In this case, you only need to use a floppy disk to start DOS and then run fdisk/mbr.
49. Change DOS/Windows to the default Operating System
RedHat uses Linux as the default Operating System of lilo, that is, boot: After the prompt is displayed, press enter to start Linux. if you want to change to DOS/Windows, modify the file/etc/lilo. conf, put the DOS Startup part in front, and run lilo again. you can also. conf configuration? Add Default = dos before the file, where DOS is the DOS/Windows label.
50. How to Use the. iso file
Many Linux versions are available. iso CD image file, which can be used to burn a CD. we can also directly use it in Linux. mount-t iso9660 xxxxx. iso/any/path/if/u/like-o loop
51. display file type
The command file can help you know whether a file is an executable file in ELF format, a shell script file, or another format. file filename
52. decompress the .tar.gz File
The xxxx.tar.gz file uses tar with the zxvf parameter. You can unzip the. tar zxvf xxxx.tar.gz file at a time.
53. Run the program in the background
You can add the "&" symbol after the program to run the program in the background. For example, you want to use updatedb to update the file path database without affecting other work. You can: updatedb &
54. Force exit X
Sometimes in X, the mouse and keyboard do not work due to program errors. In this case, don't worry, because in Linux, there is almost no vicious crash like in Win 95, you only need to press Ctrl + Alt + BackSpace at the same time to return to the character interface.
55. Compress executable files
You can use gzexe to compress executable files, and the compressed executable files can still be directly executed. This method can be used to save disk space (if you really need it). gzexe gawk
56. process files with special characters in the file name
If a file name is-file, if you want to delete it, typing rm-file will display invalid option, because the first character of the file name is "-", linux regards the file name as an option. You can add -- to solve this problem, such as rm ---file. if it is another special character, you can add a \ before the special character, or enclose the entire file name with double quotation marks.
57. quick access to the Directory
Type cd ~ Enter the user's home directory; Type cd to enter the previous directory.
What do you do when you want to delete all files or dir starting?
Wrong-> rm-r/tmp /.*
Correct-> rm-r/tmp /\.*
58. Modify the MAC address of the NIC
Ifconfig eth0 down
Ifconfig eth0 hw ether 00: AA: BB: CCD: EE
Ifconfig eth0 up
The above is temporary. You can add rc. local to enable it to run automatically upon startup.
59. view the NIC working 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
60. How to solve the problem of slow startup of sendmail and sm-client!
Sendmail and sm-client are slow to start because of resolution issues. The solution is to add your host name to/etc/hosts. For example, my host name is linuxbox. localdomain, there should be one in/etc/hosts
192.168.100.1 linuxbox. localdomain linuxbox
61. Add the sed syntax marked in blue to the information...
Sed-e "s/^-. */&/g" tip>./new
62. Add a service to the self-starting running level
Chkconfig -- add httpd
Chkconfig -- level 3 httpd on
Is to add httpd to the chkconfig management and add it to the layer-3 startup.
63. decrease the volume on the terminal
Aumix
64. Export the man file as a file and remove the control operator
Man command | col-B> col.txt
65. col-B removes the control operator.
66. view the folder size
Du./-- max-depth = 1
-- Max-depth = 1 is used to control the display depth.
67. The optical drive pops up and pops up.
Eject-r pop-up
Eject-t
68. Display recent login users
Last
69. Can chkconfig be set? System startup configuration?
Chkconfig httpd on
Chkconfig vsftpd on
.......
70. The service can control the service's Start and Stop
Service vsftpd restart
Service sendmail stop
......
71. prohibit file writing (including root)
Chattr + I filename
72. view the system syslog in real-time scrolling Mode
Tail-f/var/log/messages
73. Clear logs:
Cat/dev/null> *. log
Logs can be cleared in the crontab.
74. Kill all processes with specified names
Killall processname
75. Search for files containing specific strings
For example, find the file containing the "the string you want find..." string in the current directory.
Find <路径> [-Name xxx] | xargs grep "string "...
76. View Processes
Ps-e
Ps-ef
They are different. You will find different names of the current run. If they are different, it means someone may have performed some actions on your machine.
77. Use xargs to process the information output by the pipeline using specific programs
Find ~ Root | xargs chmod a-x
78. List shared directories of remote hosts (windows)
Smbclient-l x. X (IP)-U User Name
79. Mount the shared directory temp of the remote host to/mnt
Mount-t smbfs-o username = user name // X. X (IP)/temp/mnt
80. View win32 (fat) Partitions
Fdisk-l (list partitions) (example)/dev/hda6 5000000 fat32
We want to see this partition, then:
Mkdir win_fat
Mount-t vfat/dev/hda6/win_fat
81. Search
Folder
Find/path/\ (-type d-name ". *"-exec mv {}./path \;\)
File
Find/path/\ (-type f-name ". *"-exec mv {}/path /\;\)
82. Display files opened by the Process
Lsof-p pid
83. display the files opened by the connection
Lsof-I ◎ [ip | hostname] port
84. display the files that open this directory
Lsof directory
(You can check whether another file has been opened when you want umount to fail a directory)
85. display the process of opening the file
Lsof file
86. Use vi in ksh to edit all executed commands
Run set-o vi in ksh
Or run ksh-o vi in another shell.
87. You can directly use some operations in vi when using more or man.
For example, j, k, CTRL + f CTRL + B,/, etc.
88. Do you want to export man's content to text?
Man ls | col-B> a.txt
89. A small usage of "^" under csh
% Touch 11
% ^ 11 ^ 22
Touch 22
%
However, only the first matched string can be replaced, and the second string cannot be matched.
90. tar + compress
Tar cvf-./dir | compress-c> dir.tar. Z
Uncompress-c dir.tar. Z | tar xvf-
91. There are too many files in the current directory. Using grep will report that the parameter is too long...
Ls-al | wc-l
12323
Grep 123123123 *
Arguments too long.
Find.-name "*" | xargs grep 123123123
92. It is easy to search for two strings (AAA and BBB ).
Grep AAA file | grep BBB = cat file | grep AAA | grep BBB
Search for two strings (AAA or BBB). You can perform grep AAA file and grep BBB file twice.
It can also be in one breath: cat file | fgrep 'aaa (Press ENTER !)
Grep-E 'aaa | BBB 'file-name
93. view existing users in the system
Cut-f1-d:/etc/passwd
94. touch filename
If filename already exists, the date and time of the file are changed;
If filename does not exist, a new empty file is created.
95. du-sm View directory size
96. num-lock default on
Any of/etc/rc. d /*
For t in 1 2 3 4 5 6 7 8
Do
Setleds + num </dev/ttyt>/dev/null
Done
% %
122 the origin of some strange Unix Commands
Awk = "Aho Weinberger and Kernighan"
This language is named by the authors Al Aho, Peter Weinberger, and Brian Kernighan.
Grep = "Global Regular Expression Print"
Grep from ed print all entries that comply with a certain pattern command
G/re/p
"Re" stands for regular expression
Fgrep = "Fixed GREP ".
Fgrep □find a fixed string. "F" does not mean "fast"-in fact, "fgrep foobar *. c "usually better than" egrep foobar *. c "it's slow (it's an accident. If you don't believe it, try it yourself ).
Even so, Fgrep still has merits. When searching strings in an archive, Fgrep can process more strings than egrep.
Egrep = "Extended GREP"
Egrep uses a regular rexpression that is more fancy than grep. Many people always only use egrep because algorithm is more advanced than grep or fgrep, and is usually the fastest among the three programs.
Cat = "CATenate"
Catenate is a difficult and difficult word, which means "connecting it into a string". This is how the "cat" command processes one or more files.
Do not confuse C/A/T. C/A/T refers to Computer Aided Typesetter ).
Gecos = "General Electric Comprehensive Operating Supervisor"
However, when GE's large System Department was sold to Honeywell, Honeywell took off gecos e.
Currently, the Unix Password File still contains the "pw_gecos" field. This name is from the Early Years
The replacement is used.
Dennis Ritchie once said:
"Sometimes we will drop the printed table output or the whole batch of work to the GCOS machine. The gcos field in the password file is used to hide information on the $ IDENT card. This is not elegant enough ".
Nroff = "New ROFF"
Troff = "Typesetter new ROFF"
These words are derived from "roff", and roff is obtained by rewriting the runoff program on Multics (runoff means "print file ").
Tee = T
This is the term of the pipeline worker, representing the T-type pipeline forks.
Bss = "Block Started by Symbol" (Block starting from the Symbol)
Dennis Ritchie once said:
This abbreviation may have other words, but in fact we use this abbreviation to mean "Block Started by Symbol ". It is a virtual instruction on FAP, FAP (Fortran Assembly [-er?] Program) refers to IBM 704-709-7090-7094
The Group interpreter of this model. This command defines your own labels and reserves a certain number of word group spaces. There is another virtual command BES, which is "Block Ended by Symbol", which is almost the same as BSS commands. The difference is that labels are defined in reserved word groups.
The location at the end of the space plus 1. On these machines, the Fortran array is stored in the reverse direction, and the index of the array is counted from 1.
This usage is reasonable, because it is the same as the standard program loader on UNIX, the Code is not really put into this entire reserved space, but expressed with a number, the required reserved space is determined only during loading.
Biff = "BIFF"
Rc (for example, the rc letters in ". cshrc" or "/etc/rc") = "RunCom"
"Rc" is also the name of Plan 9 job system shell.
Perl = "Practical Extraction and Report Language"
Perl = "Pathologically Eclectic Rubbish Lister"
Perl is a very popular language developed by Larry Wall,
Process and file are very convenient. It can be said that both shell and C are good.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.