Linux operation notes

xiaoxiao2021-03-06  39

Ln -s src dust, connection

LINUX operation notes **************************************************************** ***********************************************1. Compact all files below a folder under Windows, then linux, UNZIP XXX.zip files can be 2. TAR Xzvf xxx.tar.gz decompressed in the current directory. *********************************************************** ******************************************** Compression such as a world file The clip is used to compress it into a TAR package with tar -cf libbak.tar world / *. It seems that you can use such a TAR package. Then gzip libbak.tar compresses it to .tar.gz packages and then use tar xzvf libbak.tar.gz to decompress this package.

Unnormal multiple compressed files) for files ending for .tar

There are many options for tar -xf all.tar // tar command (you can see it), but it is common to use as many options, hereby explanation:

# tar -cf all.tar * .jpg This command is to packet all .jpg's files into a package called all.tar. -c is a file name that represents a new package, -f specified package.

# tar -rf all.tar * .gif This command is to add all the .gif's files to all. Tar's bag. -r is the meaning of increasing files. # TAR -UF all.tar logo.gif This command is an update original TAR package all.tar logo.gif file, -u is the meaning of the update file.

# tar -tf all.tar This command is listed in all files in all.tar packages, -t is the meaning of the file

# tar -xf all.tar This command is all files in the all.tar package, -t is the meaning of unopened

The above is the most basic usage of TAR. In order to facilitate the user to compress or decompress files /// 1) TAR call Gzip while packaging unpacking

Gzip is a compression program developed by the GNU, and the file ended in .GZ is the result of Gzip compression. The decompression program with Gzip is gunzip. Use the -z parameter in TAR to call Gzip. Let's take a look at:

# tar -czf all.tar.gz * .jpg This command is a TAR package that puts all .jpg's files, and compresses it with Gzip to generate a Gzip compressed package, which is namely all.tar. GZ

# tar -xzf all.tar.gz This command is open to the package. /// 1) For .zip

The ZIP and UNZIP programs are provided under Linux, and ZIP is a compressed program. Unzip is a decompression program. Their parameter options are a lot, here is only a brief introduction, still explaining the usage:

# zip all.zip * .jpg This command is compressed into all .jpg files into a zip package # unzip all.zip This command is extracting all the files in all.zip out /// 2) For .rar

To process .rar files under Linux, you need to install Rar for Linux, you can download it from the Internet, but remember that rar for Linux is not free; you can download rar for from http://www.rarsoft.com/download.htm Linux 3.2.0, then install:

# TAR -XZPVF RARLINUXUX-3.2.0.tar.gz # cd rar # make

This is installed, there are two programs of RAR and UnRar after installation, and RAR is a compression program, unRrink is a decompression program. Their parameter options are available here. Here is a brief introduction, and it is still an example of its usage: # RAR a all * .jpg This command is compressed into a RAR package, named all.rar, the program Will automatically attach the .rar extension.

# unrar e all.rar This command is extracting all the files in all.rar out / ************************************ *********************************************************** ************ ------------------------------------- ----------- Linux: TOP lists the current process, and the CPU usage, Q exit. Netstat -an | grep list List the current listening port ********************************************** *********************************************************** **** [root @ backup01 called] # Date 4 September 16 09:33:14 CST 2004

Execute the Date command to get the current date, time, and year. ---------------------------------------------- [Root @ backup01 CHONGQING] # whoroot PTS / 4 Sep 16 09:07 (210.78.136.34) Root PTS / 8 SEP 16 09:29 (210.78.136.34)

The who command shows the list of people or users currently being using the UNIX system

[root @ backup01 root] # Whoroot PTS / 4 SEP 16 09:07 (210.78.136.34) root PTS / 8 SEP 16 09:29 (210.78.136.34) Root PTS / 10 SEP 16 09:43 (210.78.136.34) Root @ backup01 root] # WHO am Iroot PTS / 10 SEP 16 09:43 (210.78.136.34)

-------------------------------------------------- ----- SHELL provides an interactive interface between our users and UNIX systems. It reads our input and performs a specific program. When the program is executed, the output of the command is also displayed. Moreover, the shell is more than just a command parser or a powerful programming language. Includes conditional statements, cycles, and functions. -------------------------------------------------- ------ *********************************************************** ********************************************************* / How to find files under Linux?

1. Find file named * .sql file in the current path, the code is as follows: $ find. -Name "* .sql" 2. Find a file greater than 100MB, the code is as follows: $ find. -Size 100000 behind the numbers The unit is KB. 3. Find the file containing the print, the code is as follows: $ find. -Name "*" -exec grep -l "print" {} / 4. Find and delete the TMP * file, the code is as follows: $ find. -Name "TMP * "-exec rm {} / 5. Find no modified files in 7 days, the code is as follows: $ find. -mtime 7: // How to back up file backup, package?

1. Use the TAR package to package the specified file (directory), you can use the following code: $ TAR CVF Packet Name File (or Directory) list, for example, package the / usr / local / var directory to var.tar, you can operate as follows: $ tar cvf var.tar / usr / local / var If you want to view the contents of the file in the package, you can use the following code: $ tar tvf var.tar will list the contents of the content exhibition of files in Var.Tar, the operation is as follows : $ TAR XVF VAR.TAR When adding a file to a packet, you can do the following: $ TAR RF Package Name The list of files to be added, for example, add all the .sql files in the current directory to var.tar, available Code Implementation: $ TAR RF VAR.TAR * .SQL2. When packaging compressed files with Gzip (such as a var.tar compressed), you can use the following command: $ gzip var.tar compressed package named var.tar.gz. Decompression can be used as follows: $ GZIP -D VAR.TAR.GZ or: $ GUNZIP VAR.TAR.GZTAR Call GZIP to extract the compressed file and expand. For example, extract var.tar.gz and expand to the current directory, you can use the following command: $ TAR ZXVF VAR.TAR.GZ's z option indicates call Gzip.

/// How to get command help under Linux?

A: You can use Man, Info implementation. Save the information of the Man information to the file: $ man command | col -b> saved file name, for example, save the CP command to file cp.txt, the code is as follows: $ man cp | col -b> cp.txt

How to view hard disk usage?

A: You can use the DF command, the code is as follows: $ df -m where m means that each partition usage is displayed in m. You can use DU to view space occupied by a directory. The code is as follows: $ du -sm or the space occupied by the / usr directory (unit is MB), the code is as follows: $ du -sm / usr

// A: More commonly used text editing tools are Vim, default installation in Linux. Some of Vim is as follows. 1. Open / turn the syntax color, set the following: SYN ON / SYN OFF2. Copy the specified area content to the beginning: MK. Copy to the end: "AY'K. The specified content has been pressed to the buffer A. Copy to the target:" AP. Here, "The contents of" A are pasted into the current position. 3. Find the replacement of all ABCs of the file to D, the code is as follows:% s / ABC / DEF will replace the first line to 30, and do not distinguish the case of ABC, The code is as follows: 1, 30s / abc / def / i4. Edit two files at the same time, the code is as follows: vi file1 file2 Switch between two files between two files. 5. Fast moving cursor W, B implement Move a word before / after; use Ctrl D and Ctrl U to be reusable / front. How to make text editing work under Linux? How to set color? A: Modify $ home / .bashrc file, add the following Code: Alias ​​ls = "ls --color" Then use the following code to make changes to the modification immediately: $ source .Bashrclinux FAQ: Blue Representation Directory; green represents executable file; red represents compressed files; light blue Represents a link file; gray represents other files.

*********************************************************** ******************************************* Experience: GREP View $ (LS -F | GREP / / / | GREP -VU) * -r can search for the keywords in a directory ********************** *********************************************************** ************************ 2004-09-21 Note: 1. Shell's initialization process: Some parameters needed for some shell commands are defined through a process of initialization. First check if the / ect / profile file exists 2. If there is, the shell reads the file. 3. Then the shell checks if the .profile (.bash_profile ,.profile) file below the primary directory exists. 4. If there is, the shell reads the file, otherwise, after skipping the above steps, the prompt is displayed. Bourne shell default prompt is $ 2. Startup file .profile full contains all settings for the shell initialization process: mainly include: Play the list of directory lists for the command manual list. 3. Interaction and non-interactive shell: shell can only run, interactive, and non-interactive mutual interactions in two ways: read input and execute the specified command non-interaction: read the command, store the file, then execute, the file is over, drop out. *********************************************************** *************************************************************** 2004-09- 221. input Output:. Output Redirection: Capture the output of a command and store it in the file. $ {date; uptime; who;}> mylog $ cat mylog Three September 22 11:37:03 Up 4 min, 1 User, Load average: 0.04, 0.12, 0.06root PTS / 0 Sep 22 11:36 (192.168.0.62). Add to the file: Output to file, operator >>

. Output Redirection to Files and Screens: CMD | Tee File As: $ DATE | TEE NOW will enter Date results on the screen and write to file now.

2, enter:. Enter the input redirection from the file:. Read input from the user:. Redirect the output of a command to another command:

* Enter the redirection: cmd

Standard error: The special type of error is used to output the error message. The file descriptor is 2 standard input: the user usually read input information from the standard input, its file descriptor is 0 standard output: script usually outputs normal information to the standard Output, its file descriptor is 1, often omitted by default

* Redirect standard output and standard errors to separate files: Ln -s ch05.doc ./docs >> /tmp/ln.log 2> / dev / null ln STDOUT is appended to file / TMP / LN. Log, stderr is redirected to file / dev / null, and the error message is discarded. Note The standard output file descriptor 1 here is omitted. -------------------------------------------------- ----------------------------- Will the use of streamlined Linux system efficiency will increase? 1. According to your own needs, reconfigure the compiled kernel, remove it, this will increase efficiency 2. Follow! ! ! How to customize your system is important. If you can do a simple database server. The necessary kernel shell (as long as a shell) the necessary library and compiler database (mysql or oracle is the target) 3. It turned out to be a Windows as a Windows, thinking that there is a lot of things, it is slow, deleted Oh, huh, this is not necessarily connected 4. It is estimated that the problem is still in the thread library of the thread library RH FC2 is NPTL, and you do it yourself or old LinuXThreadsnPTL compared to LinuXThreads compared to LinuXthreads compared to LinuXthreads compared to LinuXthreads 600% improvement ---------------------------------------------------------------------------------------------------------------------- --------------------------------- * Operate file properties: - General file L symbol Connection C character device file B block Device file P Named pipe D directory files such as: $ ls -ld / xxx / xxx $ file xxxxfile instruction can get the details of this file, as follows: [Root @ localhost pikenv] # file startup.shstartup.sh: Bourne-Again Shell Spript text executable [root @ localhost pikenv] # file pikev.jsppikenv.jsp: ISO-8859 C Program Text *************************************** *********************************************************** ********** 2004-09-23: Seventh chapter: Process, such as the LS command lists the contents of the directory, the system starts a process. Unix traces a process through a 5-digit process label, each process in the same system has a unique process marker from 1 to 32767, and the week. The same system cannot appear two identical process markers. You don't have to wait for a process to start the next process, UNIX is convenient through the background process. The background process can be suspended at the same time, and switch between the front and back reasons.

* Backstage Process: Enter the front command, then &, switch to the background, or the front command, then CTRL Z, switch to the background. BG, switch to the background to continue the process, FG, switch to the front desk. FG, the default is the most recent background switching, and the task number can be added after the FG will be called out.

* See those processes hanging, those processes run in the background, with the jobs command. Or use the PS command.

* Close process: Killkill Task or Kill Process Mogue

* Parent process and sub-process ps -cf

******* SHELL programming ************************************************* ***************************************** Chapter 8: Variables * shell In programming, two variables are used: Scalar variables: one value array variable can be given at a time: can be given multiple value 1. Scalar variable: defined format: Name = value * Access variable: Use Dollar Symbol $ to access the value of the variable, but cannot define or assign variables. 2. Array variables: ----------------------------------------------- --------------------- See the shell version:

[root @ localhost xiakexing] # Echo $ bash $ bash $ bash_env $ bash_versinfo $ bash_version [root @ localhost xiakexing] # echo $ bash_version 2.05b.0 (1) -release [root @ localhost xiakexing] #

-------------------------------------------------- ---------------- Bash version is below 2.0, and the array variable is not supported.

* Establish an array variable: Name [index] = value initialization: Name = (Value1 ... Valuen);

* Set a multi-group element in BASH, you need to create an array index before the value: like: myarray = ([0] = derri [3] = gene [2] = mike [1] = TERRY) Array index No need to follow the order .

* Visit array: $ {name [index]} Access array All items: $ {name [*]} $ {name [@]}

* Read-only variable: Note that the value of a variable is defined, it cannot be changed. Such as: $ fuit = kiwi $ r l * Delete variable: unset name read-only variable can not be deleted, wait for the shell to exit after disappear

*********************************************************** ******************************* Environment and shell variables

Output environment variable: Export Name Standard Syntax Output Variable: Name = Value; Export Name

SHELL variable: ************************************************************** ******************************** Replacement: Wi-Cycle mean * Match 0 or more characters? Match 1 arbitrary Character [Characters] matches any character in the given Characters

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

New Post(0)