Linux Basics (v)

Source: Internet
Author: User
Tags bz2 gpg unpack

Add the previous chapter about alias, the method of canceling alias is, Unalias + alias
User Login Process
1. When logged in, the user will call some files (note here, is the user login, not boot)
/etc/profile
/etc/profile.d/
~/.bash_profile
~/.bashrc
/etc/bashrc
where profile,profile.d/
, BASHRC are global variables (all users can read them)
. BASHRC and. Bash_profile (local variables, typically placed under the user's home directory)

The reading order (which is the order of the files listed above, if the defined variable conflicts with the last file being read as the main)

Path variable (can simplify command length)

  [[email protected] boke]# echo $PATH (read sequentially when reading the PATH variable)/usr/local/sbin:/usr/local/bin:/sbin:/bin:/ Usr/sbin:/usr/bin:/usr/local/mysql/bin/mysql:/root/bin[[email protected] boke]# which touch/bin/touch[[email  protected] boke]#/bin/touch 1 (You can touch the file directly because of the variable) [[email protected] boke]# Touch 2[[email  Protected] boke]# LS1 2[[email protected] boke]# echo "Bie xiang Chuang Jian" >/sbin/touch (we're creating an identical file in front of the/bin) [[email protected] boke]# chmod a+x/sbin/touch (give permission) [[email protected] boke]# export PATH (refresh variable) [email  protected] boke]# Touch 3 (meaning completely changed, because the things read in sequence/sbin the following touch) [[email protected] boke]#/bin/touch 3 (You can only manually specify this time) [[email protected] boke]# LS1 2 3/sbin/touch:line 1:bie:command not found  
[[email protected] boke]# rm -f /sbin/touch [[email protected] boke]# touch 4(光删除文件是第一步)-bash: /sbin/touch: No such file or directory[[email protected] boke]# export PATH(刷新变量,完成复原)[[email protected] boke]# touch 4[[email protected] boke]# ls1  2  3  4
[[email protected] boke]# alias touch=‘echo hello‘(别名也能影响PATH)[[email protected] boke]# alias touchalias touch=‘echo hello‘[[email protected] boke]# touch 5hello 5[[email protected] boke]# unalias touch[[email protected] boke]# touch 5[[email protected] boke]# ls1  2  3  4  5

Compressed packaging
Https://iask.sina.com.cn/b/17713465.html (Here's the principle, I don't understand.) )
There are four types of compression in Linux

Create a large file
DD If=/dev/zero (extract of=/path/file name bs=1m from the remaining space count=30

  [[email protected] boke]# dd if=/dev/zero of=/usr/local/boke/large file bs=1m count=3030+0 records in30+0  Records out31457280 bytes (MB) copied, 0.144625 s, 218 mb/s[[email protected] boke]# stat Large file: ' Large file ' size: 31457280 blocks:61440 IO block:4096 regular filedevice:802h/2050d inode:937638 links:1access: (0644/ -rw-r--r--) Uid: (0/root) Gid: (0/root) access:2018-04-24 13:10:02.272290603 +0800modify:2018-04-24 13 : 10:02.413290814 +0800change:2018-04-24 13:10:02.413290814 +0800[[email protected] boke]#  
  [[email protected] boke]# zip large file. zip large file adding: Large file (deflated 100%) [[email protected] boke]# LS1 2 3 4 5 large file large file. zip[[email protected] boke]# lltotal 30752-rw-r--r--. 1 root root 0 Apr 12:21 1-rw-r--r--. 1 root root 0 Apr 12:21 2-rw-r--r--. 1 root root 0 Apr 12:26 3-rw-r--r--. 1 root root 0 Apr 12:29 4-rw-r--r--. 1 root root 0 Apr 12:32 5-rw-r--r--. 1 root root 31457280 Apr 24 13:10 large file-rw-r--r--. 1 root root 30704 Apr 24 13:12 large files. zip[[email protected] boke]# ll-htotal 31m-rw-r--r--. 1 root root 0 Apr 12:21 1-rw-r--r--. 1 root root 0 Apr 12:21 2-rw-r--r--. 1 root root 0 Apr 12:26 3-rw-r--r--. 1 root root 0 Apr 12:29 4-rw-r--r--. 1 root root 0 Apr 12:32 5-rw-r--r--. 1 root root 30M Apr 24 13:10 large file-rw-r--r--. 1 root root 30K Apr 24 13:12 large file. zip (because it is an empty file, so the compression is very high)  
[[email protected] boke]# unzip -l 大文件.zip (查看zip里的文件有哪些)Archive:  大文件.zip  Length      Date    Time    Name---------  ---------- -----   ---- 31457280  04-24-2018 13:10   ???---------                     ------- 31457280                     

ZIP-R + compressed file filename (if the compressed file does not exist, for the file is recursive compression, if it already exists, for the file is added to the compressed file)

[[email protected] boke]# zip -r 大文件.zip 1   adding: 1 (stored 0%)[[email protected] boke]# unzip -l 大文件.zip Archive:  大文件.zip  Length      Date    Time    Name---------  ---------- -----   ---- 31457280  04-24-2018 13:10   ???        0  04-24-2018 12:21   1---------                     ------- 31457280                     2 files

zip-d + ZIP file name (delete file)

[[email protected] boke]# zip -d 大文件.zip 1deleting: 1[[email protected] boke]# unzip -l 大文件.zip Archive:  大文件.zip  Length      Date    Time    Name---------  ---------- -----   ---- 31457280  04-24-2018 13:10   ???---------                     ------- 31457280                     1 file

* (Zip is able to compress the directory, also said you unzip and the directory will also be extracted to you)

Unzip + compressed file-d/path (specify extract to go there)

The notes are directly quoted.
gzip files that need to be compressed
Gzip Bigfile//Compress the file, delete the source file
Gzip-l bigfile.gz//Viewing the contents of a compressed file
Gzip-d bigfile.gz//Unzip the file
Gunzip bigfile.gz//Unzip the file and gzip-d no difference

bzip2 files that need to be compressed
BZIP2 bigfile//Compress the file, delete the source file
Bzip2-k bigfile//compress the file and keep the source file
Bzip2-d bigfile.bz2//Unzip the file
BUNZIP2 bigfile.bz2//Unzip the file and bunzip2-d no difference

XZ needs to compress the files
XZ bigfile//Compress the file, delete the source file
Xz-k bigfile//compress the file and keep the source file
Xz-d BIGFILE.XZ//Unzip the file
UNXZ BIGFILE.XZ//Unzip the file and xz-d no difference

Packaged
TAR-CVF The package name requires a packaged file or directory
-c//On behalf of Create packaging
-V//Display procedure
-F//package name, note F must follow the package name after
-Z//gzip compression
-j//BZIP2 Compression
-j//XZ Compression
-X//unpacking
-t//Query
-r//Add a file to the package
--delete//Delete a file in the package

Example: TAR-CVF root.tar/root//Packaging/root
Tar-r install.log-f Root.tar//Append Install.log file to Root.tar package
Tar--delete install.log-f root.tar//delete install.log file from Root.tar package
TAR-TF Root.tar//See what's in the package
TAR-XVF Root.tar//Unpack the bag

TAR-ZCF root.tar.gz/root///root packaged and compressed into gzip format
TAR-JCF root.tar.bz2/root///root packaged and compressed into bzip2 format
TAR-JCF root.tar.xz/root///root packaged and compressed into XZ format
TAR-ZXF root.tar.gz//Unzip and unpack the Root.tar
TAR-JXF root.tar.bz2//Unzip and unpack the Root.tar
* (added, after the decompression to follow the C/path can be extracted to the specified/path below)

Standard input and standard output

Standard output redirection
>//Standard output Append redirect

2>//Error Output redirection
2>>//Error Output append redirect

&>//Full output redirection
&>>//Full output Append redirect

Ll/etc >/tmp/shadow 2>/tmp/out//correct and incorrect use of two files saved

Ll/etc &>/tmp/out
Ll/etc >/tmp/out 2>&1//two type results

<//Standard input
Example: Cat </etc/hosts//view/etc/hosts file

Cat >/tmp/file </etc/hosts//input/etc/hosts file to cat and output to/tmp/file file
Cat/etc/hosts >/tmp/file//The effect of this command is as above

<<//followed by a Terminator (Terminator any), all data before the Terminator becomes input

Cases:
Cat << END

Lkasdfuiouqwe
Zc,mvnlasdkjf
Qweoriu,mcnva
End
END
Lkasdfuiouqwe
Zc,mvnlasdkjf
Qweoriu,mcnva
End

Cat >/tmp/file << out

echo Hello
Out

Software Installation
1. Source Package Installation
2. Binary installation
3.RPM
4.YUM

SOURCE Package
Advantages: Can be developed
Cons: Complex operation, long compilation time, very prone to problems or errors
Installation:
1. Download and unzip the source package
2. Enter the extracted directory and execute the "./configure" command to configure the local environment before compiling.
3. After the configuration is successful, execute the "make" command to compile the software.
4. After the compilation is successful, execute the "make install" command to complete the installation.
5. Finally, execute the "make clean" command to remove the temporary files generated during installation
Unloading:
Go to the installed directory and execute the uninstall command "make uninstall" to uninstall
Note: Not all packages offer uninstall functionality and can only be removed manually if not provided.
"./configure--prefix=/usr/local/dir" Installs the software in the specified directory, which is usually installed by default in/usr/local

Binary installation
Direct decompression for use

Rpm:redhat Package Management
Command syntax
RPM option Parameters
RPM packages are required, usually ending with. rpm
RPM Package named structure

ntfsprogs-2.0.0-13.el6.x86_64.rpm
Software Name-version number-operating system platform. rpm

Using the RPM command, the software can be installed, queried, uninstalled, upgraded, and shown the required dependencies.

Dependencies: A software dependency with other software.

Steps to install the software in rpm
1. Download RPM Package
2. Use the RPM command to install the "full name of the RPM-IVH software package"
Rpm
-I//installation
-V//Display procedure
-H//Show list tags at installation

Inquire
-A//query all packages
-Q//Inquiry mode
-F//file name to see which software generated the file
-L//Show Package list
-I//software package details

Upgrade
-U//upgrade, install if the file is not installed
-F//upgrade, if the piece is not installed then discard (do not install)

Unloading
-E//Uninstall the software
--NODEPS-E//Do not uninstall dependencies

Yum
Yum Features
1. Automatic resolution of dependencies
2. Package, you can group the RPM package, in the form of a package to install
3.yum introduces the concept of warehouse, Yum source. Support for multiple warehouses.
4. Simple Configuration

/etc/yum.repos.d///This directory stores the directory for the configuration file of the Yum Repository, note that the configuration file must end with a. Repo
Vim/etc/yum.repos.d/server.repo
[Server]//warehouse Name
Name = rhel6.5 Repos//Warehouse description information
BaseURL = Location of http://classroom.example.com/content/rhel6.5/x86_64/dvd///Warehouse
Enable=1//Warehouse enabled (0 means not enabled, 1 is enabled)
Gpgcheck=0//Whether detection is enabled (0 means not enabled, 1 means enabled)

Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-redhat-release//If the detection is 1, you must have the corresponding key parameters.

Location of warehouse:
Local: file:///mnt///local use format file after the first two slash represents the format the third slash represents "root"
Remote: ftp://
nfs://
HTTP///See what protocol is used

After the configuration is complete, the Yum cache needs to be cleared, and the cache will be established after cleanup is complete
Yum Clean all//clear cache
Yum Makecache//Build Cache

Create a local Yum repository
1. Download the system image file
wget Http://classroom.example.com/content/rhel6.5/x86_64/isos/rhel-server-6.5-x86_64-dvd.iso
2. Mount the image to a local directory
Mount-o loop/root/rhel-server-6.5-x86_64-dvd.iso/mnt
3. Create a warehouse configuration file (must end with. Repo)
Vim/etc/yum.repos.d/iso.repo
4. Modify the configuration file
[ISO]
Name = File Repos
BaseURL = file:///mnt
Enable=1
Gpgcheck=0

5. Clear the cache and set up the cache
Yum Clean All
Yum Makecache
6. Installation Verification

Vim Advanced Use
Normal mode insert mode (edit mode) End mode

Normal mode
YY Copy one line (cursor location)
P Paste
3yy copy three rows
DD Deletes a row or moves a row using p to move
G jumps to the last line of the document
GG jumps to the first line of the document
5gg Jump To line 5th
U undo
Ctrl+r Anti-revocation (recovery)
0 move to the beginning of the line
$ move to end of line
/keyword search under the cursor
? keyword search cursor above
ZZ Save and exit

I cursor current position insert
I Insert the beginning of the cursor position
o Insert a new line below the line where the cursor is located
O Insert a new line above the line where the cursor is located
A the next character position of the cursor is inserted
A end of line insertion of the cursor

: Set nu//Display line number
: Set Nonu//Turn off line number display
: Nohl//Turn off highlighting
:! command//temporary switch to bash using command (does not recognize command alias), any key to return the document
.! Command//Insert the result of the execution of the command into the edited file
: 3//Jump to line 3rd
: s/w/o//The first occurrence of "w" in the line of the cursor is replaced by "O"
: s/w/o/g//All "w" in the line where the cursor is located is replaced with "O", and G represents the entire line substitution
:%s/w/o/g//Ignore cursor location for full text substitution, all "w" replaced with "O"
:%//Represents the subsequent substitution action to all rows
: w absolute path//Save as this file
: R file name//read another document in the document, where the cursor is located
: e! Discard modification and reload the original file

Process
Pstree//view process Tree

Parent Process PPID
Child process PID

RHEL6: The parent of all processes Init
Rhel7: The father of all processes Systemd

PS aux//static view, a for all, u on behalf of user, X for the process without control terminal

Status of the process
S: Sleep state
R: Waiting to run
I: Idle state
Z: Zombie Status
<: High priority for processes
N: Process has lower priority
S: Leader of the process
L: Multithreading
+: In the foreground process group

Daemon process

PS-EF//Static view,-E on behalf of all processes,-F for full format listing

Ps-le//View the priority of the process, focusing on NI this column represents the priority level

PGREP init//Show only the process ID (PID) of the Init process
-l//Show process name
-u username//Displays the process ID generated by the user
-T Ttyid//Displays the process ID generated by the terminal

PIDOF process name//show process ID only

Dynamic View Process
Top//Dynamic View process
The default is 3 seconds to refresh, the space can be refreshed immediately, enter "D" in the number of seconds to change the default refresh time

"P" is sorted according to CPU occupancy rate
"M" is sorted according to the memory occupancy rate
"N" is sorted based on startup time
"N" input to show the number of processes on a page
"<" ">" page left and right
"C" command name switch, detailed path, command name. Details also include the parameters
"K" ends the process, using 15 signals by default

CTRL + C terminates viewing dynamic processes

End Process
Kill signal Process ID (PID)
-1 reset signal, typically used to let the service reload its own configuration file, let the process reload the new configuration information including the configuration file
-9 forcing a process to close
-15 waits for the process to exit normally, and the difference between the 9 signal is the write-back of the data stream.

Killall process name//end all processes with the same name

Pkill//According to the conditions to end the corresponding process
-T Terminal number
-U user Name

Xkill//Point who die, where do not move the point where

Priority of the process
Ps-le//View priority NI
The smaller the priority number, the higher the priority level.
Priority number range: 20-19

1. Assign a priority when creating a process
2. Modify the priority of an existing process

Nice-n ping 127.0.0.1//Assign priority when creating a process
Renice-n 0 PID
Example: Renice-n 0 26715//Modify the priority of an existing process

Note: The root user can be modified at will within the priority range,
Ordinary users can only lower the priority level, ordinary users can not specify less than 0 priority

Foreground job Background Job
Create a background job after command followed by "&"
Jobs//View background jobs
FG Background Job number//Send background job to foreground
CTRL + Z//Set the triggered foreground job to the background and the background job is paused
BG//Let background jobs continue to run

Cases:
Ping 127.0.0.1 >/dev/null &//Create
Jobs//view
FG 3//Transfer to the front desk of Job No. 3rd
CTRL + Z//Transfer already 3rd front desk work to the background and suspend the operation
Jobs//View the status of the run
BG//Let background jobs continue to run
Jobs//View running status

Continue tomorrow ...

Linux Basics (v)

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.