Linux Basic Operating notes

Source: Internet
Author: User
Tags gz file

  implementation of Linux file systemLinux has a tree structure to organize files, the top of the number is the root directory/, the node is the directory, and the stub point is the data file contained. We can perform various operations on files, such as opening and writing. storage Device Partitionthe ultimate goal of the file system is to organize large amounts of data into persistent storage devices, such as hard disks and disks. These storage devices, unlike memory, have persistent storage capabilities that do not disappear due to power outages, have a large amount of storage, but are slow to read. The data is stored in a partition, and a typical Linux partition (partition) contains the following sections: the first part of the partition is the boot block, which is primarily for the computer to start service. After the Linux boot starts, the MBR is loaded first, and then the MBR loads the program from the boot area of a hard disk. The program is responsible for further loading and booting of the operating system. For ease of administration, Linux also reserves the boot area for a partition, even if the operating system is not installed.

After the ScanDisk is the Super block. It stores information about the file system, including the type of file system, the number of inode, and the number of data blocks.

It is followed by multiple inodes, which are key to implementing file storage . In a Linux system, a file can be divided into several chunks to store each file corresponding to an inode. This inode contains multiple pointers to the individual data blocks that belong to the file. When the operating system needs to read the file, only the "map" corresponding to the inode, collect scattered data blocks, you can harvest our files.

the last part is the data block that really stores the data blocks. when Linux wants to open a file, it only needs to find the inode of the file, and then, along the pointer, collects all the blocks of data, it can compose the data of a file in memory. a complex way to use a linked list, each data quickly has a pointer to the next block of data belonging to the same file, the advantage is that the use of scattered free space, the disadvantage is that the file operation must be carried out in a linear manner, if you want to randomly access, then you must traverse the list to guide the target location. list detailed file information in a folderls is the list meaning, focusing on displaying the file name and related attributes. The option "-al" indicates that all files are listed with detailed permissions and attributes.
ls -al

1) The first column represents the type and permissions of this file (permission):

first character D is the directory, -is a file,  l  ] is indicated as a link file, b is indicated as the storage Interface Device (a random access device) inside the device file, c is represented as a serial port device inside the appliance file, such as a keyboard, mouse (one-time reading device).

The next characters, grouped in three, are rwx three parameter combinations, [R] stands for readable (read), [W] for writable (write), [x] for executable (execute). The First group is the permissions of the file owner , the second group is the same group, and the third group is Other permissions that are not in this group .

2) The second column indicates how many file names are linked to this node

3) The third column indicates the file's own account number

4) The fourth column indicates the group to which this file belongs

5) The Fifth column indicates the size of the file, the default unit is bytes

6) Column Six indicates the file's date of filing or the most recent modification date.

Create a folder
mkdir Test[email protected]: ls Test

Delete Empty folders

RM Test RM : Cannot remove ' test ': is a directory[email protected]: rmdir Test[email protected]: ls

Changing file properties and Permissions

chgrp   : change file owning group  : Change file owner chmod  : Change file permissions, SUID, SGID, sbit, etc.

Change the group that the file belongs to

sudo chgrp Users Linux_study
    Change file owner
sudo chown Root Linux_study
Change file Permissions
sudo chmod 755 Linux_study

Change the file's permissions to 755:owner r+w+x, Group:r+x, others:r+x

File Display
$Cat  filename         : Display file $cat  file1 file2      : Connection display file1 and file2$head - 1 filename     : Show file first line $tail -5  filename     : Show file penultimate line $diff File1 file2     : Shows the difference between File1 and file2

Number of rows, words, and characters in a statistic file
WC6 test2

Show Date

$Date +"%y-%m-%d_%t" displays datetime in the format yyyy-MM-DD_HH:MM:SS (format can refer to man  Date) $Date --Date="1999-01-03 05:30:00"  Show from 1900-basedon: 00 specificinformation

Internet

Displays the network excuse and the corresponding IP address . Ifconfig can be used to set up network interfaces:

Ifconfig

Running the Eth0 interface

sudo ifup eth0

Close the Eth0 interface

sudo ifdown eth0

Show Wireless network interface

[Email protected]:~/desktop/linux_study$ iwconfig

Displays the route table. Route can be used to modify the routing table

[Email protected]:~/desktop/linux_study$ iwconfig

Current Network connection Status

[Email protected]:~/desktop/linux_study$ netstat

Send ping packets to address IP

Ping 10.21. 171.15

Send DHCP requests to the DHCP host for IP addresses and other setup information

sudo dhclient

Use wget to download the resources that the URL points to

sudo dhclient

DNS query, look for the domain name IP corresponding to

sudo dhclient

Packaging and Compressioncompare large files with the so-called file compression technology, you can reduce the volume of his disk use, can reduce the file size effect. Linux supports a very high number of compression commands, and different commands use compression technology is not the same, of course, may not be able to communicate with each other compressed/uncompressed files, distinguish between different compressed files usually through the extension of the suffix. gzip or bzip2 compression test
gzip Test
Unzip Test
gzip -D test
Package Command: Tar
tar -cvf/tmp/etc.tar /etc<==tar -zcvf/tmp/etc.targzip  tar -jcvf/tmp/etc.tarbzip2 compression

Unzip the/tmp/etc.tar.gz file under/USR/LOCAL/SRC

[Email protected] ~]# cd/usr/local/tar -zxvf/tmp/etc.tar. gz

Linux Process Basicswhat the computer can actually do is very simple, such as the club two sum, find the address in memory and so on. These basic computer actions are referred to as "directives". The so-called program is a collection of this set of instructions. Through the program, we can let the computer complete the complex operation. most of the programs will be stored as executable files. differences in processes and procedures A process is a concrete implementation of a program. A process is the process of executing a program. To query a running process:
PS -eo pid,comm,cmd

-E stands for all processes, and-O pid,comm,cmd means we need pid,comm and cmd information.

Each row represents a process, the three columns of information represent each line of the process's unique PID representation, the command is the process of the abbreviation, CMD is the program corresponding to the process and the runtime with the parameters (for use [], is a part of the kernel function, is dressed up as a process appearance, Easy operating System Management).

How to create a process

In fact, when the computer is booting up, the kernel kernel only establishes an INIT process, and the Linux kernel is a system call that does not directly establish a new process. All processes are established through the fork mechanism. (Fork, the new process needs to pass the process of copying itself to get it). When the process is fork, Linux opens up a new memory space in memory to the new process, and copies the contents of the old process space into the new space, from which two processes run concurrently. The entire process tree can be displayed through the Pstree command:

End of child process

When the child process is terminated, the parent process is notified to empty the memory it occupies and leave the information in the kernel.

When the parent process learns that the child process is terminated, the wait system call is used for the child process. This wait function takes out the exit information of the child process from the kernel and empties the space occupied by the information in kernel.

However, if the parent process is older than the child process end, the child process becomes an orphan (Orphand) process. The orphan process is passed on to the Init process, and the Init process becomes the parent process of the process. The INIT process calls the wait function when the child process is terminated.

Linux Signal Path Basics There are several processes within kernel, each of which does not allow people outside the process to enter, which is a protection mechanism for each process, but sometimes it is necessary to break the closed protection to communicate information to the process. This requires a means of communication. The transmitted signal is coarse and can only be an integer, but it is because of the small amount of information transmitted that the signal is easy to manage and use. signals are often used for system management related tasks, such as notification process finalization, abort, or recovery, and are managed by the kernel or generated by the kernel. The PID of the process is queried by pinging, and then the KILL command is used to signal to a process:
$Kill9575

Pass the sigcont signal to the ping process.

Signal ProcessingAll signals use the default action of the corresponding signal, but not absolutely, when the process decides to execute the signal, there are several possibilities:1) disregard. The signal is cleared and the process itself complements any special operations. 2) Default. Each signal corresponds to a certain default action, such as the Sigcont mentioned above used to continue the process. 3) Custom actions. Also known as the acquisition of signals, the execution of a preset in the process corresponding to the operation of the signal.

Linux Basic Operating notes

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.