Linux system (I) file system, compression, packaging operation summary, linux Packaging

Source: Internet
Author: User
Tags gz file

Linux system (I) file system, compression, packaging operation summary, linux Packaging
Preface

The current situation is that. Net is already open-source, and. Net Core is cross-platform. It can be seen that Microsoft is working hard, changing, making progress, and moving towards spring. Once upon a time, Microsoft was a god-oriented. Net practitioner. If you don't open your mind to open source and change yourself, then it is very likely that in the near future, the fear of heroes will be useless. Sadly, you can sigh and cry!

Nowadays, Linux is already one of the essential skills for developers. If we want to know about it and go deep into it, we cannot be lazy. We only need to operate the icon button on the perfect interface. I want to change, progress, go deep, and fly like Microsoft, side by side with the sun.

Then those who are interested will install B with their brother, and the rising posture will increase. Just as hackers will understand this in the TV series, just give them commands in the black background. One day, let's focus on accumulation. In fact, the learning of Linux is also a process of building up a tower. The associations between the two sides are not very large. Learn a little bit, and work hard.

My Linux goals

My goal is to use commands to operate a Linux system, which is as simple and intuitive as operating a Windows system.

Note: 0. If you do not know what Linux is, click X in the upper right corner of the page. 1. Install a Linux system. I installed CentOS7. if the system is not installed, click X in the upper-right corner of the page. 2. You have to be able to log on to the system by yourself. Do not log on to the system by yourself. You cannot connect to the system (so embarrassing, too )!

Next, I will write a few blog posts about linux. I suggest that beginners not only read the commands but do not practice them. They should read the commands and remember them carefully. If they cannot remember them, they will always come back.

Started with cd and ls commands

Now, let's get to the point. The linux Connection Tool I used is xshell and mRemoteNG. I will not introduce the two tools. You can Baidu, but it will not be in the upper-left group.

After entering the page, the interface is dark. For Beginners, it may be like a dog taking a hedgehog. So don't worry. Let's take a look at the first linux Command in our life: ls and cd.

First, use the following cd command:

[Root @ localhost ~] # This is the Home Directory of the user folder of the current user.
[Root @ localhost/] # This is the root directory of the entire system

Then enter the ls command to display the result.

So what are these files loaded? Why should they be placed in the root directory? Let's look at this in detail.

Ls, cd command syntax and parameter use method: http://man.linuxde.net, can not be lazy Oh, to knock, you can learn well, multiple knock to remember.

File Types and extensions in Linux

In linux, any device is a file, and even the data communication interface has a dedicated file. So we need to figure out what files are in linux? What are the functions?

First, enter the command as follows:

What is a mess? I take the dev folder as an example to break it down:

1. File Type

Common files: these are general files. In linux, there are roughly three types of files.

  • Plain text file (ASCII): The content is directly read by us, such as numbers and letters. We can almost set this type of file to read and write. It can be opened using the cat command, view the content directly.
  • Binary: The only file that can be recognized and executed in linux. the executable file in the system is in this format. For example, the cat just executed is a binary file.
  • Data: The specific format file that the program reads during running, that is, the data file, for example: user Login User data is recorded in the/var/log/wtmp data format file. The obvious features can be read from the last, and the cat reading is garbled.

Block Device Files: these are interface devices that are randomly accessed by the system, such as hard disks and floppy disks, check out/dev/sda.

Character (character) Device Files: interfaces for some serial ports, such as keyboards and mouse. The features of these devices are "one-time read" and cannot be truncated. For example, the mouse can only slide to one place rather than to another place.

ETS: This type of file is used for data connections on the network.

Pipeline (FIFO, pipe): fifo, first-in-first-out, mainly solves the problem caused by multiple program colleagues accessing a file.

Directory: directory.

Link: similar to the shortcut key in windows.

2. File Permission r-xr-x

  • Meaning of the abbreviation: x: executable, r: readable, w: writeable,-placeholder.
  • 123: owner permission, 456: user permission of the user group, 789: permissions of other users.
  • The feature order is rwx.

3. Connections: number of file names connected to the node.

4. File Name

  • In linux, there is no such extension as in windows. However, for convenience, you still need to have the habit of writing extensions.
  • The file length limit. Generally, it should not exceed 255 characters.

  • File naming restrictions. It is best to avoid *?> <; & | ,\'"(){}
File directory structure

After you open the linux system, enter the command: cd \ to enter the root directory, and then ls will display the following directory structure

So what files are stored in these directories, and what specifications should our files be stored?

Linux directory structure Standard: FHS (Filesystem Hierarchy Standard) Standard

Why should we use a standard? It is very simple, that is, to let users and vendors have a common understanding and constraints, so as not to separate themselves from each other, to mess up the linux System directories and put things at will, the learning cost will be very high.

FHS has a lot of introduction on the internet, FHS based on the experience of Multi-Go has also been in the continuous revision (http://www.pathname.com/fhs/), FHS according to the frequent use of the file system, whether the user is allowed to modify, the directory is defined as four forms of interaction:

  • Shareable: You can share the directory used for mounting to other systems.
  • Not shareable: It is only related to your own machine and is not suitable for sharing with other hosts. Such as the device files running on your machine or socket files related to programs.
  • Unchanged: data that does not change frequently, such as the description file, function library, and host service configuration file.
  • Changeable: frequently changed data, such as logon files and newsgroups.

Folder storage in the root directory and root directory

The root directory is the most important directory of the entire system, because all directories are derived from it, and the root directory is also related to operations such as startup, restoration, and system repair.

Because the system requires specific boot software, kernel files, programs, function libraries, and other file data for boot, if the system encounters an exception, the root directory must also contain programs that can repair the file system. This shows the importance of the root directory. Therefore, FHS suggests that the root directory should not be placed in a very large partition, because the larger the number of files to be prevented, the higher the chance of errors, and the worse the performance, therefore, the smaller the root directory, the better, and the software installed by the application should not be placed in a partition with the root directory.

So let's talk about what the next file is and how to place it.

In fact, the FHS standard defines only the following directory data for the root directory.

Five directories cannot be separated from the root directory and placed in different partitions. The five directories are: etc, bin, dev, lib, and sbin.

In addition to the above folders, there are also some important directories in linux systems:

/Dev directory:

  • Hd [a-t]: IDE Device
  • Sd [a-z]: SCSI Device
  • Fd [0-7]: Standard soft drive
  • Md [0-31]: soft raid device
  • Loop [0-7]: local loopback device
  • Ram [0-15]: Memory
  • Null: Infinite data receiving device, equivalent to a black hole
  • Zero: unlimited zero Resources
  • Tty [0-63]: virtual terminal
  • TtyS [0-3]: Serial Port
  • Lp [0-3]: Parallel Port
  • Console: console
  • Fb [0-31]: framebuffer
  • Cdrom =>/dev/hdc
  • Modem =>/dev/ttyS [0-9]
  • Pilot =>/dev/ttyS [0-9]
  • Random: random Number Device
  • Urandom: Random Number Device

/Etc directory

  • /Etc/rc,/etc/rc. d,/etc/rc *. d: directory of the scripts or scripts to start or change the runtime.
  • /Etc/passwd: user database. The domain name contains the user name, real name, Home Directory, encrypted password, and other user information.
  • /Etc/fstab: List of file systems automatically mounted by the mount-a command at startup (in/etc/rc or equivalent Startup File. In Linux, information about the swap zone enabled with swapon-a is also included.
  • /Etc/group: similar to/etc/passwd, but it does not indicate users but user groups.
  • /Etc/inittab: the configuration file of init. It sets the runlevel of the system when the system starts.
  • /Etc/issue getty output information before the logon prompt. The system administrator determines the short description or welcome information.
  • /Etc/motd: Message Of The Day. After Successful Logon, The automatically output content is determined by The system administrator. It is often used for notification information, such as a warning Of The scheduled shutdown time.
  • /Etc/mtab: List of currently installed file systems. It is initialized by scripts and automatically updated by the mount command. It is used when you need a list of currently installed file systems, such as the df command.
  • /Etc/shadow: the shadow password file on the system where the shadow password software is installed. the shadow password file moves the encrypted password in the/etc/passwd file to the/etc/shadow file, while the latter only reads the password to the root, making it more difficult to crack the password.
  • /Etc/login. defs: configuration file of the login command.
  • /Etc/printcap: similar to/etc/termcap, but the printer syntax is different.
  • /Etc/profile,/etc/csh. login,/etc/csh. cshrc: The file executed by Bourne or C shells at login or startup, which allows the system administrator to create a global default environment for all users.
  • /Etc/securetty: confirm the security terminal, that is, the terminal that allows root login. generally, only the virtual console is listed. In this way, it is impossible (at least difficult) to break into the system through a modem or network and obtain super user privileges.
  • /Etc/shells: List trusted shells. the chsh command allows you to change the logon shell within the range specified in this file. the ftpd service process that provides an FTP service on a machine checks whether the user's shell is listed in the/etc/shells file. If not, the user is not allowed to log on.
  • /Etc/sysconfig: network configuration directory
  • /Etc/DIR_COLORS: Set the color
  • /Etc/HOSTNAME: Set the user's node name
  • /Etc/NETWORKING: Only YES indicates that the network exists.
  • /Etc/host. conf: The file describes how the user's system queries the node name
  • /Etc/hosts: set the table for the user's own IP address and name
  • /Etc/hosts. allow: set to allow inetd machines to use
  • /Etc/hosts. deny: Set inetd not allowed for machines
  • /Etc/hosts. equiv: Set remote machine password not needed
  • /Etc/inetd. conf: configure the system network daemon inetd.
  • /Etc/inetd. pid: process id of the inetd process
  • /Etc/hosts. lpd: set which nodes on the remote end can use the local printer.
  • /Etc/gateways: Set the vro
  • /Etc/protocols: Set the protocols supported by the system
  • /Etc/named. boot: Set the local server as the name server configuration file
  • /Etc/named. pid: process id of the name server running on the local machine
  • /Etc/networks: sets the network configuration file
  • /Etc/resolv. conf: sets the system name server.
  • /Etc/services: set the end product and protocol type of the system and the services provided
  • /Etc/exports: Used to set NFS
  • /Etc/NNTP_INEWS_DOMAIN: sets the configuration file of the news server.
  • /Etc/nntpserver: sets the address of the news server used by the user.
  • /Etc/XF86Config: X Window configuration file
  • /Etc/hostid: A unique hardware id of the system.
  • /Etc/at. deny: specifies which users cannot use the at command.
  • /Etc/bootptab: sets the formats of driver files of different devices for MAKEDEV programs.
  • /Etc/makedev. cfg: the configuration file used by MAKEDEV in the same way as DEVINFO
  • /Etc/diphosts: Set the username and password of the dial-up Server
  • /Etc/slip. hosts,/etc/slip. login: sets the configuration file of the SLIP.
  • /Etc/fastboot: this file is generated using shutdown-f. You need to check this file when you restart the system.
  • /Etc/fstab: record the file system to be mounted upon startup
  • /Etc/ftpaccess: Some FTP server configurations
  • /Etc/ftpconversions: Set the position of the filter used in FTP
  • /Etc/ftpusers: Set users who cannot use the FTP service
  • /Etc/ld. so. cache: Find the cache of the Dynamic Linked Library of the system
  • /Etc/ld. so. conf: Path of the System Dynamic Link Library
  • /Etc/lilo. conf lilo: Configuration File
  • /Etc/magic: used by the file command
  • /Etc/aliases: Specifies the file used by sendmail to set the alias.
  • /Etc/sendmail. st: Set
  • /Etc/motd: the place where the superuser sends a notification
  • /Etc/organization: stores the user name and organization
  • /Etc/pnpdevices: List supported Plug & Play devices
  • /Etc/snooptad: monitors the user's screen and monitors the terminal list
  • /Etc/sudoers: configuration file for sudo commands
  • /Etc/syslog. conf: System Record Program syslogd configuration file
  • /Etc/utmp: User information of the currently used System
  • /Etc/wtmp: similar to utmp, But it accumulates
  • /Etc/nologin: this file is generated when the system shuts down without user logon.
  • /Etc/termcap: Specifies
  • /Etc/ttys: Set the terminal type of the system.
  • /Etc/gettydefs: getty_ps definition file
  • /Etc/yp. conf: NIS configuration file
  • /Etc/mtools. conf: Set mtools program parameters
  • /Etc/fdprm: sets the parameters for formatting a floppy disk.
  • /Etc/login. access: The file that controls the user's logon Permissions

/Proc directory

  • /Proc/cmdline: the related parameters issued when the kernel is loaded. Refer to this file to learn how the system starts.
  • /Proc/cpuinfo: information about the CPU of the local machine, including the time pulse, type, and operation function.
  • /Proc/devices: This file records the main device code of each major device of the system, which is related to mknod.
  • /Proc/filesystems: file systems that have been loaded by the system.
  • /Proc/interrupts: Current IRQ allocation status on the system.
  • /Proc/ioports: the I/O address configured by each device on the system.
  • /Proc/kcore: the memory size, but do not read it.
  • /Proc/loadavg: Do you still remember top and uptime? That's right. The three average values above are recorded here.
  • /Proc/meminfo: memory information listed using free, which can be viewed here.
  • /Proc/modules: List of modules already loaded in Linux. You can also think of it as a driver.
  • /Proc/mounts: the data already attached to the system, that is, the data called by the mount command.
  • /Proc/swaps: Where exactly does the system mount and load exist? The used partition is recorded here.
  • /Proc/partitions: If fdisk-l is used, will all the current partitions appear? There are also records in this file.
  • /Proc/pci: On the PCI bus, you can view the details of each device using lspci.
  • /Proc/uptime: the information that appears when uptime is used.
  • /Proc/version: the core version, that is, the content displayed with uname-.
  • /Proc/bus/*: some bus devices and USB flash drives are also recorded here.

/Usr directory

Data stored in/usr can be shared and cannot be changed according to the basic definition of FHS. Usr is the abbreviation of UNIX Software Resource, that is, the directory where "UNIX operating system Software resources" are stored, rather than user data, and should not be related to users. It is equivalent to the combination of c: \ windows and c: program files in windows. When the system is installed, the directory occupies the most disk capacity. Because almost all applications are installed here, locally installed programs and other things are stored in/usr/local.

  • /Usr/etc: stores configuration files.
  • /Usr/games: stores game and teaching files.
  • /Usr/include: header files and inclusion file placement in c/c ++. When we install some data in the tarball method (* .tar.gz method, will use many containing files. Header files required for developing and compiling applications.
  • /Usr/share: place shared files. The data stored in this directory is almost readable regardless of the hardware architecture, because almost all files are text files. For example,/usr/share/man: Online Help file,/usr/share/doc: Description of miscellaneous software files, zoneinfo: Time Zone-related files.
  • /Usr/bin: the commands that most users can use are stored here. Some commands are in/bin (whether it is related to the boot process) or/usr/local/bin.
  • /Usr/sbin: Unnecessary system management commands for the root file system, such as most service programs.
  • /Usr/share/man,/usr/share/info,/usr/share/doc: the manual page, GNU information document, and various other document files.
  • /Usr/lib: contains the function libraries, target files, and execution files or scripts that are not commonly used by users. Some software provides some special commands to set the server. These commands are not often operated by the system administrator, so they are placed in this directory.
  • /Usr/local: the Administrator installs software downloaded by himself on the local machine. We recommend that you install the software in this directory. This directory also has bin, etc, include, lib.
  • /Usr/src: stores the program source code. The Linux kernel source code is stored in/usr/src/kernels.

/Var directory

Usr occupies a large amount of hard disk capacity during installation, while var takes up the hard disk capacity after the system runs. Because the var directory is mainly used for files that change frequently, such as cache, login files, and files generated by running some software, including program files (lock file, run file ).

  • /Var/catman: cache of the man page when formatting is required. the source file of the man page usually exists in/usr/man *; some man pages may have pre-formatted versions, which exist in/usr/man/cat. other man pages need to be formatted when they are viewed for the first time. The formatted version exists in/var/man, so that other people do not have to wait for formatting when looking at the same page. (/var/catman is often cleared, just like clearing a temporary directory .)
  • /Var/lib: the file to be changed when the system is running normally.
  • /Var/local,/usr/local: variable data of the program installed in (that is, the program installed by the system administrator ). note: if necessary, other/var directories, such as/var/lock, will be used even for locally installed programs.
  • /Var/lock: lock the file. many programs follow the Convention of generating a locked file in/var/lock to support their use of a specific device or file. other programs will not try to use this device or file when they notice this locked file.
  • /Var/log: Log files of various programs, especially login (/var/log/wtmp log all logon and logout to the system) and syslog (/var/log/messages stores all core and system program information. files in/var/log often grow uncertain and should be cleared regularly.
  • /Var/run: after some programs or services are started, their pid will be placed in this directory. A valid system information file before the next boot. For example,/var/run/utmp contains the information of the currently logged-on user.
  • /Var/spool: Put some queue data, that is, the data waiting in queue for other programs to use. This data is usually deleted after it is used. For example, the system will place a new letter in/var/spool/mail. After the user accepts the letter, it will be deleted in principle. If the mail cannot be sent temporarily, It will be placed in/var/spool/mqueue and deleted after it is sent. If it is a Job Schedule data, it will be placed in the/var/spool/cron directory.
  • /Var/tmp: The value is larger than/tmp, or a temporary file must exist for a long time. (Although the system administrator may not allow/var/tmp to have very old files .)
  • /Var/cache: some temporary files generated during application running.

The directory tree of the LIUNX system is as follows:

File compression and packaging in Linux

Compression: a mechanism that uses specific algorithms to reduce the size of computer files (under Baidu encyclopedia ).

Package: put multiple files into one file, and finally exist as one file.

Common compression commands in Linux include compress, gzip, and bzip2.

  • Compress: This compression command only exists on the old unix machine. It is an old compression method and is replaced by gzip. gzip can also decompress commress compressed files. So I do not do too much here, there is a need for friends can: http://man.linuxde.net/compress I here to give a as follows:
  • Gzip: This compression command is currently the most common. It can uncompress files compressed by compress, zip, gzip, and other software. There are 9 compression levels, the fastest one has the worst compression ratio, and the lowest 9 has the best compression ratio. The default value is 6. Use the zcat command to view the compressed files that read compress and gzip. The text compression ratio can be 60%-70%, which can be used with tar.
  • Bzip: If gzip is used to replace compress, bzip exists to replace gzip. The compression ratio is better than gzip, and can be used with tar.

Common gzip usage:

Syntax: gzip parameter file name

Parameters:

-C: outputs compressed data to the screen and can be processed through data redirection.

-D: extracted Parameters

-T: it can be used to check the consistency of a compressed file to see if there are any errors in the file.

-V: displays the compression ratio of the source file/compressed file.

-#: Compression level, 1-9.

Common statement: compression: gzip-v filename, decompress: gzip-d filename. View the compressed text file: zcat file name.

Common bzip2 usage:

Syntax: bzip2 parameter file name

Parameters:

-C: output the data generated during the compression process to the screen.

-D: Extract

-K: Keep the source file without deleting the original file.

-Z: Compression

-V: displays the compression ratio of the source file/compressed file.

-#: Same as gzip, 1-9 compression ratio parameter, 1 is the fastest, 9 is the best.

Common statement: compress: bzip2-z filename, decompress: bzip2-d filename. View compressed text: bzcat filename.bz2

Tar packaging command

The above three types of compression and decompression can only be performed on a single file. How can we combine multiple files into a large file? Use the tar command. Tar is more than that. It also supports gzip/bzip2 to compress files while packaging. Since the tar.tar.gz file name is decompressed, winrar.tar.gz files in windows are supported.

Syntax: Packaging and compression: tar [-j |-z] [cv] [-f New file name] filename decompression: tar [-j |-z] [xv] [-f New file name] [-C Directory]

Parameters:

-C: Create a new packaging file. You can use-v to view the packaged file name.

-T: view the file names contained in the package. Focus on viewing the files.

-X: The extract or decompress Package function, which can be used with-C to unbind from a specific directory. Note that-c,-t, and-x cannot appear in a string of commands at the same time.

-J: Use bzip2 to compress or decompress the package.

-Z: supports gzip compression or decompression.

-V: displays the name of the file being processed during compression or decompression.

-F filename: the name of the file to be processed after-f. It is recommended that-f write a parameter separately.

-C Directory: this parameter can be used to extract files from a specific directory.

 

Common syntax of .tar.bz2 format

Decompress: tar jxvf filename.tar.bz2 and compress the file: tar jcvf filename.tar.bz2 to be compressed.

Common syntax in .tar.gz format

Decompress: tar zxvf filename.tar.gz, and compress the file to be compressed by tar zcvf filename.tar.gz.

Summary

The following is your favorite summary, which includes three parts:

1. I hope to keep an eye on my other articles.

2. Are there any clear instructions in the blog, or you have a better way? Join the two chat groups in the upper left corner to study and discuss them together.

3. You can forget to pay attention to likes, but never forget to scan the QR code to enjoy them.

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.