Http: // 10.1.1.35/ule_basic/ule07.txt

Source: Internet
Author: User
Tags uppercase letter
--


Linux packaging, compression, and decompression


Compression makes the file smaller, which is conducive to network transmission. When transferring a large number of small files, it is best to package and compress it at a faster speed.


WinRAR. rar in Windows
WinZip. Zip


Linux compression command:

. Zcompress -- obsolete, rarely seen
. Gzgzip compressed
. Bz2bzip2 compressed
. Tartar Packaging
.Tar.gz tar, Gzip
.Tar.bz2 tar, Bzip2





-- Compress old compression Tool

[Root @ Li ~] # Yum list | grep Compress
This system is not registered with RHN.
RHN support will be disabled.
Ncompress. i386 4.2.4-47 Server

[Root @ Li ~] # Yum install ncompress -- install this package and use the compress command

Compress grub. conf -- directly compress the file and the source file is missing
Compress-D grub. conf. Z -- Extract
Compress-C grub. conf> grub. conf. Z -- compress and keep the source file


-- Gzip is widely used to replace compress. It can decompress. Z. GZ. Zip and other compressed packages.
Gzip grub. conf -- Compression
Zcat grub.conf.gz -- view the content of the compressed package
Gzip-D grub.conf.gz -- Extract
Gzip-C grub. conf> grub.conf.gz -- compress and keep the source file
Gzip-D grub. conf. Z

Unzip discuz_6.1.0_ SC _gbk.zip-D/root/desktop/--.zip. Unzip is used to decompress the package. The-D parameter specifies the decompression location.


-- Bzip2 is used to replace gzip and has a better compression ratio.
Bzip2 grub. conf -- Compression
Bzcat grub.conf.bz2 -- view the content of the compressed package
Bzip2-D grub.conf.bz2 -- Extract
Bzip2-C grub. conf> grub.conf.bz2 -- compress and keep the source file

[Root @ Li test] # ll
-RW ------- 1 Root 810 Apr 24 grub. conf
-RW-r -- 1 Root 560 Apr 24 grub.conf.bz2
-RW-r -- 1 Root 493 Apr 24 grub.conf.gz
-RW-r -- 1 Root 614 Apr 24 grub. conf. Z



-- RAR
/Share/soft/rarlinux-3.7.1.tar.zip -- this package is processed by three layers, first tar, then GZ, then zip, so unzip first, then tar xvf
Unzip/share/soft/rarlinux-3.7.1.tar.zip-D/usr/src/
CD/usr/src/
Tar xvf rarlinux-3.7.1.tar.gz
CD/usr/src/RAR
Make -- this package can be made directly. If there is a MAKEFILE file, it indicates that it is already./configure

If the RAR command is available, the installation is complete.

This command does not have man page, because the man help file is not installed, you can use rar-H or RAR -- help to see

Rar a etc.tar.rar etc.tar -- Compression
RAR e etc.tar.rar -- Extract



-- Tar
-C Packaging
-V display process
-F: File Access
-J calls Bzip2 for compression or decompression
-Z calls gzip for compression or decompression
-C: Specifies the decompression path during decompression.
-T view the package content
-X Extract

Tar CVF etc.tar ETC/-- package, pay attention to the location of the Source and Destination
Tar xvf etc.tar -- decompress the package to the current path by default.
Tar xvf etc.tar-C/usr/src/-- use the-C parameter to specify the decompression path. Note that C is an uppercase letter.

Tar cjvf etc.tar.bz2 ETC/-- pack and Compress With Bzip2
Tar xjvf etc.tar.bz2 -- extract the corresponding package
Tar czvf etc.tar.gz ETC/-- pack and Compress With Gzip
Tar xzvf etc.tar.gz -- decompress the corresponding package

W can extract Parameters
Tar xvf etc.tar.gz -- the compression tool is automatically called for decompression.


[Root @ Li test] # ll
Total 116320
Drwxr-XR-x 106 Root 12288 Apr 24 etc
-RW-r -- 1 Root 100280320 Apr 24 etc.tar
-RW-r -- 1 Root 7427569 Apr 24 etc.tar.bz2
-RW-r -- 1 Root 11238367 Apr 24 etc.tar.gz
-RW ------- 1 Root 810 Apr 24 grub. conf
-RW-r -- 1 Root 560 Apr 24 grub.conf.bz2
-RW-r -- 1 Root 493 Apr 24 grub.conf.gz
-RW-r -- 1 Root 614 Apr 24 grub. conf. Z


Note:
-- Here we can see that Bzip2 has a better compression ratio than gzip, but it does not compress a small file.
-- The compressed directory is to compress every file in the directory. Generally, this method is not used. The correct method is to package the directory with tar and then compress it with gzip or Bzip2.



Special Application of tar:

Tar tvf etc.tar | grep fstab -- use the-t parameter to view the content of the compressed package
Tar xvf etc.tar etc/fstab -- specifies to decompress a single file
Tar CVF etc.3.tar ETC/-- exclude = etc/fstab exclude some files from Packaging
Tar CVF etc.5.tar ETC/-- exclude = etc/fstab -- exclude = ETC/inittab exclude multiple files
Tar CVF etc.6.tar ETC/-- exclude = ETC/*. conf supports wildcards to exclude a batch of files with Similarity


Tar CVF-ETC/| tar xvf--C/root/desktop/-- use pipelines to perform some special operations









--####################################### ######################################## #######


Job Management
In Linux, there are foreground and background concepts. Each bash terminal can run its own job. Note that it cannot be managed across bash terminals.

& -- Background running symbols. The running program will not occupy your terminal

[Root @ Li test] # firefox &
[1] 6003--1 indicates the job number, and 6003 indicates the PID (process identification)


[Root @ Li test] # Vim/etc/passwd -- press Ctrl + Z Here to pause the job to the background.

[2] + stopped Vim/etc/passwd


[Root @ Li test] # Vim/etc/shadow -- press Ctrl + Z to put it in the background, which is different from Ctrl + C (Interrupt ).

[3] + stopped Vim/etc/shadow

[Root @ Li test] # jobs -- list the job list in the background, which is invisible to other terminals
[1] running firefox &
[2]-stopped Vim/etc/passwd
[3] + stopped Vim/etc/shadow

Jobs-l -- also list PID numbers
Jobs-s -- only list paused jobs
Jobs-r -- only list running jobs

[Root @ Li test] # FG % 1 -- transfers Firefox of Job 1 to the foreground
Firefox



[Root @ Li test] # jobs-l
[1] + 6003 stopped Firefox
[2] 6036 stopped Vim/etc/passwd.
[3]-6074 stopped Vim/etc/shadow


[Root @ Li test] # BG % 1 -- put the Firefox of the-job from the stop status to the background for execution, that is, to the running status
[1] + firefox &
[Root @ Li test] # jobs-l
[1] 6003 running firefox &
[2]-6036 stopped Vim/etc/passwd
[3] + 6074 stopped Vim/etc/shadow

[Root @ Li ~] # Tar CVF root.tar/& -- do not add the V parameter here. It is a standard out. Even if the background symbol is added, it will always occupy the packaging information output by the foreground terminal.

[Root @ Li ~] # Tar CF root.tar/& -- you can put the V parameter in the background for execution.

[Root @ Li ~] # Tar CVF root.tar/>/root/tarroot. log 2> & 1 & -- run the logs in the background and save the logs.

Watch-N3 tail/root/tarroot. log -- package at the backend to view the log write status.

[Root @ Li/] # Kill-9% 1 -- kill job 1, or use a PID to kill job 1.




---------------------------
Exit and continue to suspend

Add nohup before the running script or command to stop the user.









--####################################### ######################################## ######



File Search


Whichwhereis locate find



-- Which
[Root @ Li ~] # Which ifconfig -- find binary executable files and use environment variables
/Sbin/ifconfig

[A @ Li ~] $ Which ifconifg -- the normal user environment variable does not have the/sbin/path, so which cannot find it.
/Usr/bin/which: No ifconifg in (/usr/Kerberos/bin:/usr/local/bin:/usr/bin:/home/A/bin)

-- Whereis
[Root @ Li ~] # Whereis ifconfig
Ifconfig:/sbin/ifconfig/usr/share/man/man8/ifconfig.8.gz

[A @ Li ~] $ Whereis ifconfig
Ifconfig:/sbin/ifconfig/usr/share/man/man8/ifconfig.8.gz


-- Locate
Fast, search through a database with the System
[Root @ Li ~] # Ls/var/lib/mlocate/
Mlocate. DB

[Root @ Li ~] # Touch abcd777 -- create a file
[Root @ Li ~] # Locate abcd777 -- locate cannot be found


[Root @ Li ~] # Updatedb-manually update the locate database. It takes a long time, but the system time Task Service will help you update the database at 4 o'clock.

[Root @ Li ~] # Locate abcd777 -- after updating the locate database, you can find it again.
/Root/abcd777


-- Find
Slow speed, because it is powerful to scan your disk
Find path [Option]
-Name -- search by name
-Type -- find by file type

-UID -- search by uid
-GID -- search by GID
-User -- search by username
-Group -- search by groupname

-Perm -- query by permission
+ N -- the permissions contained in N are also found.
-N -- Obtain the permissions that contain N.
-Size -- search by size
+ N -- Find Files greater than N
-N -- find files smaller than N


1. Search by name
Find/etc/-name grub. conf -- find the grub. conf file in the/etc directory
Find/etc/-name "*. conf" -- use wildcards to find files ending with. conf in the/etc/directory.
Find/test/-iname aaa -- ignore case sensitivity and-I
/Test/AAA
/Test/AAA
/Test/AAA
-- Define the directory level for searching
[Root @ Li a] # Find/test/-maxdepth 1-name aaa
/Test/AAA
[Root @ Li a] # Find/test/-maxdepth 2-name aaa
/Test/AAA
/Test/A/AAA


2. Search by type
Find/etc-type L | grep grub. conf
Find/etc-type L-name grub. conf -- write with the-name parameter

Find/-type B
Find/-type S
Find/-type C
Find/-type P


3. Search by user name, group name, uid, and GID
Find/-user
Find/-Group
Find/-UID 533
Find/-gid 533
Find/-nouser -- find out the system's headless files, that is, files with no owner
Find/-nogroup -- find out the system's files without groups
There are no owners and groups of files, system management is generally to pay attention


4. Search by permission
Find/-Perm 777 -- find all files with the 777 permission, which is also important to administrators.
Find.-Perm + 111
Find.-Perm-777


5. Search by size

Find/-size + 500 m -- unit: K, M, G, etc.
Find/-size + 1g
Find/etc-size + 50 K
Find/etc-size + 50B
Find/-size-1 m

6. Search by Time

[Root @ Li a] # stat 1
File: '1'
Size: 0 blocks: 0 Io block: 4096 regular empty file
Device: 808 H/2056d inode: 12177882 links: 1
Access: (0777/-rwxrwxrwx) uid: (0/root) gid: (0/root)
Access: 14:44:00. 000000000 + 0800 -- atime has been read, accessed with CAT, tail, head command, etc. or VI, but it has not been modified; execution will also change
Modify: 14:44:00. 000000000 + 0800 -- mtime modified the content, changed it with VI or echo a value redirection
Change: 14:44:14. 000000000 + 0800 -- ctime changed content, owner, group, permission, soft link creation, hard link, etc.

-Mtime n -- represents the 24 hours before n days
+ N -- represents n days ago (excluding the 24 hours of N days)
-N -- indicates n days


1234567
| -- 2 -- |
<--------2 | + 2 --------------->

Find/-mtime 0--0 represents the current 24 hours of the current day
Find/-mite + 1 -- modification time 1 day ago
Find.-mtime-1 -- the modification time is within one day.


Ctime atime usage is the same as mtime



Find.-newer 1 -- search for files newer than 1


-----------------------------
Find followed by-exec action
-Exec

Find/etc/-name "*. conf"-exec CP {}/test//;
Find/etc/-name grub-exec cat {}/;
--- Exec is followed by an action. {} indicates the previous result set /.





--####################################### ######################################## #####


Xwindows graphical desktop --> X protocol --> TCP/IP


MIT (MIT) X Windows
X11
Xfree86 plan
The Xorg organization took over and developed concurrency into the current X11 V7

Gnome kde twm (the simplest desktop) -- all belong to xwindows Client


Xwindows is also a C/S architecture (server/client)
X Server-driver hardware, mouse, keyboard, display, etc.
X client -- receives signals from the server, processes the program, and transmits the signals to the server for Pixel movement and plotting.

[Root @ Li a] # W
15:54:47 up, 4 Users, load average: 0.04, 0.06, 0.06
User tty from login @ idle jcpu pcpu what
Root: 0-09:21? Xdm? 10: 59 0.12 s/usr/bin/gnome-session



Example 1:
Automatic startup graphics
/Etc/X11/xinit/xinitrc. d/-- write the graphic program automatically started after the startup graph is started.

Vim/etc/X11/xinit/xinitrc. d/Firefox. Sh
#! /Bin/bash
/Usr/bin/Firefox & -- Firefox runs automatically after it is started



Example 2:
Remote Image Adjustment
SSH 10.1.1.104-x Firefox
SSH 10.1.1.104-y


[Root @ Li a] # Su-
[A @ Li ~] $ Firefox -- images cannot be run by common users
Xlib: connection to ": 0.0" refused by Server
Xlib: no protocol specified

Error: cannot open display: 0.0


Xhost + -- allows all common users to call graphics
Xhost + IP
X clinet: xhost + server_ip
X Server: Display = client_ip: 0 xeyes &



-- Graphics-related errors


It takes a very slow time to start the image at startup. Generally, the host does not match well.
Check

[Root @ Li a] # hostname
Li.cluster.com
[Root @ Li a] # Vim/etc/hosts
[Root @ Li a] # Cat/etc/sysconfig/Network
Networking = Yes
Networking_ipv6 = No
Hostname = li.cluster.com


Or try RM/root/. gnome/-RF again.
Rm/root/. gnome2/-RF
Ls/tmp/| grep root -- drop all found RM

After all the files are deleted, restart X Windows and recreate the files according to the default configuration.


Note that the/tmp directory permission is not enabled for graphics.
STAT/tmp
(1777/drwxrwxrwt)


System-config-display graphical desktop configuration




---------------------------------------------------


VNC (Virtual Network Computing) Virtual Network Computing
The earliest developed by at&t lab

Remote Control Software

Vncserver vncviewer

[Root @ Li a] # Yum list | grep VNC
This system is not registered with RHN.
RHN support will be disabled.
VNC. i386 4.1.2-14. el5_3.1 installed -- Client
Vnc-server.i386 4.1.2-14. el5_3.1 installed -- Server


[Root @ Li a] # vncserver

New 'Li .cluster.com: 1 (Root) 'desktop is li.cluster.com: 1

Starting applications specified in/root/. VNC/xstartup
Log File is/root/. VNC/li.cluster.com: 1.log

[Root @ Li a] # vncpasswd -- create a VNC Password
Password:
Password must be at least 6 Characters-try again
Password:
Verify:


/Root/. VNC/-- configure the Directory

Vim/root/. VNC/xstartup -- to display gnome-session, open the following two statements and comment out all the other statements.
Unset session_manager
Exec/etc/X11/xinit/xinitrc

# [-X/etc/VNC/xstartup] & exec/etc/VNC/xstartup
# [-R $ home/. Xresources] & xrdb $ home/. Xresources
# Xsetroot-solid gray
# Vncconfig-iconic &
# Xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop "&
# TWM &


Access Method
Vncviewer 10.1.1.35: 1

Vncviewer-viewonly-shared 10.1.1.35: 3


[Root @ Li a] # ls/root/. VNC/
Li.cluster.com: 1.log li.cluster.com: 2.log li.cluster.com: 3.log passwd
Li.cluster.com: 1.pid li.cluster.com: 2.pid li.cluster.com: 3.pid xstartup

[Root @ Li a] # vncserver-kill: 1
Killing xvnc process ID 11889.

[Root @ Li a] # ls/root/. VNC/
Li.cluster.com: 1.log li.cluster.com: 2.pid li.cluster.com: 3.pid xstartup
Li.cluster.com: 2.log li.cluster.com: 3.log passwd

[Root @ Li a] # netstat-NTL | grep 58
TCP 0 0 0.0.0.0: 5802 0.0.0.0: * listen
TCP 0 0 0.0.0.0: 5803 0.0.0.0: * listen



The VNC ports start from 5801 and start from 5901.
5800 + N is used for the browser. 5900 + N is used for the vncviewer.

Http: // 10.1.1.35: 5802/-- access with a browser

However, the Firefox browser in Linux requires a Java Plug-in.




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.