Start from Linux cainiao

Source: Internet
Author: User
Tags touch command
Linux cainiao started learning-general Linux technology-Linux technology and application information. The following is a detailed description. In Linux, partitions are expressed in this way.

/Dev/hda
/Dev/hda1
/Dev/hda2
/Dev/hda5
/Dev/sdb1

Take/dev/hda5 as an example:

In Linux, every device is represented by a file in the/dev/folder. In/dev/hda5,/dev/indicates the dev directory under the root directory, let's look at the remaining part of hda5.

The first two letters "hd" indicate that this is an IDE hard disk. If it is sd, it indicates a SATA hard disk, or flash memory and other peripherals.

The third letter, a, indicates that this is the first device on this type of interface. Similarly, B, c, d ...... Represents the second, third, and fourth interfaces of this type respectively ...... Devices. For example, hdc indicates the master disk on the second IDE interface (each IDE interface allows one master device and one slave device ).

The fourth digit, number 5, does not indicate that this is the first logical partition in the hard disk. In Linux, the partition sequence cannot be changed to avoid unnecessary confusion, and the partition IDs are determined by their locations on the hard disk. The system reserves an identifier for all possible primary partitions, so 1-4 is not a logical partition, 5 is the first logical partition, and so on.

PS: I gave an example of a book, such as a directory, preface, and chapter;

What is a directory usually used?

/
The root directory, which must be mounted. Do not hesitate to select a partition and mount it! (In most cases, 2 GB of capacity should be enough. Of course, many things are more beneficial.

Swap
Swap partition may not be necessary, but according to the tradition, and take care of your security, mount it. It can only be larger than your physical memory. If the capacity exceeds twice your physical memory, it is definitely a waste.

/Home
As mentioned above, this is your home directory. files created by yourself are usually stored here. You 'd better allocate a partition to it.

/Usr
Application directory. Most of the software is installed here. If you plan to install many software, we recommend that you allocate a partition to it.

/Var
If you want to make some server applications, you can consider assigning a large partition to it.

/Boot
If your hard disk does not support the LBA mode (I think it is unlikely), You 'd better mount it. If you mount the first partition of the hard disk, It should be relatively safe. Generally, the size of the mounted partition is only MB.

In the file system, we recommend that you select ReiserFS.

In Windows, the drive letter is used to indicate both hardware (partitions on the hard disk) and paths in the system. In Linux, hardware is the hardware, path is the path, and will not be confused together, simple and direct!

PS: Remember all dead!

Path commands

Cd (change directory) to change the directory.
Pwd (print working directory) shows the current path.
Ls (list) displays the list of files in the current directory.

Run cd/etc to enter the "/etc" directory. Here, the absolute path is used.
Pwd displays the current path. This command returns the result "/etc"
Cd init. d enter the "init. d" subdirectory In the "/etc" directory, where the relative path is used.
Cd .. go to the upper-level directory "/etc"
The upper-level directory of cd ../home "/etc" is "/", and its subdirectory "home" is "/home"
Cd-go back to the last directory. We jumped to the "/home" directory in the "/etc" directory, so this time we went back to the "/etc" directory.
Cd ~ "~" Represents the "$ HOME" directory of the current user, that is, the "/home/{username}" directory.
At any time, you can use the "ls" command to understand the files in the current directory.

Remote path:

The remote path is expressed as Protocol: // User name: password @ location/path: Port

Most remote paths can be accessed anonymously using the default port. Therefore, the user name, password, and port are not required.

PS: Try your skills;

Software

Linux does not have the registry concept. Theoretically, you only need to copy all the relevant files and run the main program.

Traditionally, a software is usually copied to the bin, etc, lib, share, and other folders in the same directory.

Bin
Executable File. the executable file of the program is usually in this directory. You can set the search path in the environment variable and directly execute it without locating the path.

Etc
Configuration files. Most system program configuration files are stored in the/etc directory for centralized modification.

Lib
Library files, together to facilitate sharing to different programs. Compared with different software, saving database files separately can save some disk space.

Share
Other resources required for running the program, such as the sample mark and text. This part of files are proprietary and do not need to be shared. In addition, the directory structure is relatively complex and the contents are mixed and stored separately.

There are also some software that occupies a separate directory where all resources are stored. Similar to the green software in Windows, it is not recommended in Linux.

During execution, the system cannot find the executable file (it is unrealistic to search all paths and the resource overhead is too large). You need to locate the executable file, it is not convenient to run the/home/user/bin/executable file like this.

Many system software needs to run collaboratively, and configuration files are saved separately, which is very troublesome to locate.

If the library files used by the program, such as graphics library files, are stored separately, the disk space will be wasted very seriously.


There are some large software or important applications that you deploy. you can install them separately in a folder. (This method is usually supported by source code installation, which will be introduced in the software installation Section)

PS: recordable

File Type

In Linux, the file type is determined based on the file header information. The extension is not the deciding factor.

Now, run the ls-l command to view the file list in the detailed information format. You will see the following content:

Total 5
Drwxr-x --- 4 user group 4096 Mar 10 filename
Drwxr-xr-x 21 user group 4096 Mar 10 file name
-Rw ------- 1 user group 524 Mar 10
-Rw-r -- 1 usergroup 24 Jun 11 2000 B
Drwx ------ 2 user group 4096 Mar 9 11: 06 c

Seven columns of information are displayed, from left to right: permission, number of files, owner user, owner group, file size, creation date, and file name.

Note the first column:

Drwxr-xr-x

A total of 10 positions can be divided into four groups:

D rwx r-x

The first group has only one character:
D folder
-Common files
L Link
Block B Device Files
C character device file.

The remaining three groups are the owner user, owner group, and other users or groups. Let's look at its format.

Rwx
R readable
W writable
X executable

By the way, they cannot be reversed. If a position is null (-), it means they do not have the corresponding permissions.

Tip
The executable files in Linux are not determined by the extension (for example,. exe), but by the limit of the executable right.

Ctrl + S
By accident, sometimes you press Ctrl + s to freeze the Shell. Use the Ctrl + q key combination to check whether the problem can be recovered.

Task Management

&
Add an & symbol at the end of the command to indicate the background task.

;
Use; when multiple commands are linked, the task is executed in order.

&&
Using & to link Multiple commands indicates that only the preceding commands are successfully executed and Subsequent commands can be executed.

''
' <命令> '. If a command contains a subcommand that is enclosed by ''(the key at the bottom of the Esc key), The subcommand is preferentially executed and the execution result is substituted into the upper-level command for further execution, for example, create a file named after the current time:

Touch 'date + % m. % d _ % H: % M: % s'

The touch command can create a file whose operation object is the date + % m % d % H % M % S command output 06.06_06: 06: 60

In this way, we created a file named 06.06_06: 06: 60 (just over 60 seconds at 06:06 on January 1, June 6 -_-!)

Ctrl + z
Suspends a task in the current Shell.

The task status is

[1] + Stopped xxx

Bg
Run the suspended task background. The status is

[1] + xxx &

Fg
Transfer the background task to the foreground for execution

Jobs
The number in square brackets is the task number of the command. You can use the jobs command to view all background tasks.

If you run multiple tasks in the background, you can use bg or fg followed by the task number as the operation object, for example:

Bg 2

Pipelines and redirection

>
The redirection symbol is used to redirect the command output to a file. For example, if we want to save the result of the command ls aS a FileList file and make a list, we can use the redirection symbol to complete it:

Ls-l> FileList

>
The function is basically the same as>. The difference is that> writes the command output to the end of the file in append mode.

<
Is the redirection from the file to the command, the file content as the command input.

|
Pipeline symbol. It serves as the output of the previous command as the input of the next command. Assume that there are too many files in a directory, and the ls command cannot be fully displayed on the screen. In this case, you can output the ls command and use the pipeline symbol as the browser less input. You can use the browser function to flip pages and search:

Ls-al | less

Tip: the Key Binding of the less browser is almost the same as that of man. For details, see online help system.
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.