Linux Learning---(compression and decompression of files command zip unzip tar, shutdown and restart commands shutdown reboot ... )

Source: Internet
Author: User

1. Compress and Decompress commands
Common compression formats:. zip,. gz,. bz2,. tar.gz,. tar.bz2,. rar
. zip format compression and decompression commands
Zip compressed file name source files: Compressed files
Zip-r compressed file name Source directory: Compressed directory
Unzip compressed file name: Unzip. zip files
. gz format Compression and decompression
Gzip source files: Compressed files in. gz format, source files disappear
Gzip-c source Files > Compressed files: Compressed to. gz format, source files reserved
Gzip-r Directory: All sub-files in the compressed directory are compressed sequentially, but the directory cannot be compressed
gzip-d compressed Files: Extracting files
Gunzip compressed Files: Extracting files
Gunzip-r Directory: Unzip all the compressed files under the directory
The. rar format on Windows is not uncompressed on Linux
. bz2 format Compression and decompression
BZIP2 command cannot compress the directory directly, there is no-r option
bzip2 source file: Compressed to. bz2 format, without preserving source files
Bzip2-k source file: After compressing but preserving source files
bzip2-d compressed Files: Extracting files,-K preserving compressed files
BUNZIP2 compressed file: Unzip,-K reserved Compressed file
because gzip, bzip2 command cannot really compress the directory, so it is inconvenient, so Linux provides a solution: You can use the TAR command to package the directory into a single package called. Tar, and then you can use gzip, BZIP2 compresses the package (which also indirectly compresses the directory), so this is why you previously saw a compressed file in the. tar.gz,. tar.bz2 format
TAR-CVF package file name source file or directory
-C: Packaging;-V: Display process;-F: Specify the file name after packaging
Example: TAR-CVF Longzls.tar longzls
TAR-XVF Package file name: Unpack, for example: TAR-XVF Longzls.tar
In fact, the . tar.gz format is packaged in. tar format, compressed into. gz format, but first packed with tar, then compressed with gzip or bzip2, so it's inconvenient to introduce the following more convenient method
TAR-ZCVF compressed package name. tar.gz source file or directory:-ZC for. tar.gz format
TAR-ZXVF compressed package name. tar.gz source file or directory 1 source file or directory 2: Compress multiple source files or directories into a single compressed file
TAR-ZXVF compressed package name. TAR.GZ:-ZX represents decompression. tar.gz format
TAR-ZXVF compressed package name. tar.gz-c Destination Pathname: The compressed file can be extracted to the specified path
TAR-ZTVF compressed package name. tar.gz: Only look at. tar.gz the contents of the compressed file, but not the pressure

TAR-JCVF compressed package name. tar.bz2 source file or directory:-JC for. tar.bz2 format
TAR-JXVF compressed package name. TAR.BZ2:-JX represents decompression. tar.bz2 format
The others are ibid (unzip to the specified directory, compress multiple files, only look at uncompressed compressed files)

2. Shutdown and restart commands
shutdown [options] Time
Option:-C, cancel the previous shutdown command;-h, shutdown;-R, restart
Example: Shutdown-r 05:30, which means to restart at 05:30, but after this command is entered, there is no other input, this time there are two ways to solve
1) After entering Shutdown-r 05:30, use CTRL + C to force exit
2) input shutdown-r 05:30 &amp, which means that this command executes in the background, does not affect the command input of the shell, other commands such as lengthy commands can also be used & let it be executed in the background, will not affect the user at the command line to continue the other operations
Example: Shutdown-c that cancels the previous command to shut down or restart with the shutdown setting
In the real server environment, is not recommended remote shutdown, because if the remote shutdown, when you want to start the machine will be very difficult, remote restart is enough
Other shutdown and restart methods, we are not safe enough, when using them shut down or restart, do not properly save the system in the running services, only shutdown will be shutdown and restart when the right to save the running service, it is recommended to use the Shutdown command
There is a time to force shutdown on the PC ... Operation does not seem to have any problems, this is often because the PC is only you in use, often do not run at high speed, but on the server, often have millions or even more users to access, so the server will be high-speed operation, if the arbitrary shutdown, may lead to hard disk damage, operating system crashes and other issues, The most serious is causing the user's data to be corrupted or lost. So if you need to shut down, it is best to switch off the service you are currently using, such as many games tend to notice in advance: What time we will be in the maintenance, we do not log on, when the shutdown, what to do, it will be more secure. So the server and the PC are quite different in many ways.
So when it comes to Linux, it's best to change your thinking habits: Now I'm not working on my own PC, but a server that is used by a large number of users
other shutdown commands, but no shutdown the same as when shutdown and restart the correct storage of resources, so there is no shutdown security:
Halt: Shut down the machine
Poweroff: Shut down the machine
Init 0: Shutting down the machine
Other restart commands:
Reboot: Relatively safe, can be used
Init 6: Try not to use
system operating level:
0: shutdown, so init 0 is off
1: Single User
2: not fully multi-user, without NFS service (file sharing service)
3: Full Multi-user
4: For assigning
5: Graphical interface
6: Reboot: So init 6 is reboot
View the current operating level of the system with the RunLevel command (for example, Show N 2)
n indicates the level before entering this level, n refers to the empty level, so before entering this level is the empty level, which means I start on the level 2
2 indicates that the current level is 2
You can define the default operating level when the system starts up in the/etc/inittab profile, be careful not to set it to 0 or 6, or the system will shut down (0) when it is powered on, or it will restart (6) Once it is switched on, think how it should be used?? So please be careful (of course this is also can be repaired, but for beginners, hehe!) )
Logout: Log off User login
If using remote Tools to log on to the server, in the exit, do not simply close the remote tools, and should first execute the Logout tool, if not execute this command, this time the user did not exit, the next time the login has not exited, long time, too many users do not logout, Then there may be this situation, the system allows the number of users logged out, this time to log on can only restart the server, but in the real environment of the random restart of the server is a very impact on the user experience

Linux Learning---(compression and decompression of files command zip unzip tar, shutdown and restart commands shutdown reboot ... )

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.