Chapter 5 Linux commands and tips

Source: Internet
Author: User
Tags echo message

1. mount umount command

Using your floppy disk and Cd in Linux is not as dangerous as in Windows.
Think about it. If you install software on a CD or play games in Windows, your girlfriend, render manager, is the first girlfriend, because you play games every day instead of making dinner, even if someone else has made dinner, you don't have time to eat it, and you press the Eject button on the disc in a bad mood ...... Haha, scared? Don't worry about such things in Linux.

To use a CD, first place the CD and then execute the following command:

Mount-t iso9660/dev/cdrom/mnt/cdom to mount the optical drive to the/mnt/cdrom directory

The-t parameter specifies the file system type of the disc. Generally, the disc is in the ISO standard format. The following/dev/cdrom file is the device file corresponding to your optical drive. We have mentioned that each hardware device corresponds to a standard device file. The last/mnt/cdrom directory is a directory on your local hard disk. If you do not find this directory before using it, you can create one. Of course, you do not have to use this directory. You can even use the mount/dev/cdrom/root command to mount your optical drive to your/root directory, in this way, your/root content will no longer be the original content until you cancel the mounting.

Run the following command to cancel mounting:

Umount/mnt/cdrom or umount/dev/cdrom

Both of these commands can unmount the attached CD so that your CD can be taken out. If not, run the mounting command again, and then click the Eject button on the optical drive to see if there is any response? No, right? This is one of the advantages of Linux. Although it is a bit difficult to operate, it is very safe and slightly complicated. Which one do you choose?

The method for using a floppy disk is similar:

Mount/dev/fd0/mnt/floppy

/Dev/fd0 is the device file corresponding to your floppy disk, followed by your mounted directory. However, if you want to try to launch a floppy disk without canceling the mounting of a floppy disk, you will be a very BT person. Are there any mistakes? The exit of a floppy disk is a mechanical operation. You have to press it out. What can I do? The method for dismounting a floppy disk is similar:

Umount/dev/fd0 or umount/mnt/floppy

In fact, the first parameter-t can be omitted during mounting, because the system will automatically determine what format should be used for identification. However, knowing the format of the floppy disk or CD is helpful for mounting an ISO file.

Mount-t iso9660-o loop/home/kris/somewhat. iso/mnt/cdrom

We all know that there are a lot of ISO files on the Internet, which is to package all the content of the CD into a file for convenient online transmission. After obtaining such a file, we don't have to use a burner to burn it into a CD. We just need to use the following command to mount the ISO file of the CD to the/mnt/cdrom directory. The first parameter-t iso9660 is the file system format used by the CD, and the second parameter is the meaning of loopback.

Cancel mounting: umount/mnt/cdrom

2. Pipeline commands

Pipeline commands are an important part of the Linux system. Here we will only introduce some simple.

First, we have learned a command cat to display the content of a file. But have you ever encountered a situation where a file is too long and one page cannot be displayed? If you need to display a long file by PAGE and press a key to display the next page, you can use the more command:

More LoveLetter
In this way, the content of the LoveLetter is displayed on the screen. When it is not a page, it stops automatically and waits for your buttons to continue displaying the following page.

However, if we use the ls command to display all files in a directory, what should we do if one page cannot be displayed completely? In this case, a pipe symbol "|" is required, which is the character above the "\" button:

Ls/dev | more

Next, we have encountered a new problem. We not only want to see which files are under the/dev directory, but also want to use a file to record all the results displayed by the ls command just now, do I need to input it manually? No. We will introduce two pipeline symbols: ">;>;>;, which is greater than the symbol.

Ls/dev>; filenames.txt

Another pipeline symbol is ">;>;", which is composed of two big signs. It is different from the previous one in that it is used to create a new file filenames.txt. If a file with the same name already exists, it overwrites the previous content; two pipelines larger than the symbol are used to append new content to an existing file. If this file is not available, it is created.

Now let's see how many lines are there in vi filenames.txt, isn't there more than 1000 lines? We run

Ls/dev >;>; filenames.txt

Let's look at vi filenames.txt. Is there more than 2000 lines in total?

In fact, these two pipeline symbols are easy to remember. The arrows on the left mean to input the content of the previous command into the subsequent files, the "|" pipe symbol is used to treat the output result of the preceding command as the input data of the following command. Next, let's look at a pipeline symbol that is opposite to the one just mentioned above: <":

Cat >;>; friends <"EOF"
>;
>; B
>; C
>; EOF
After running the first line, it means to save the following input content to the friends file and end when we enter "EOF. "<" Means to send a data packet to the forward command.
In the middle, I symbolically input three lines a B c, and the ">;" in front of each line is the prompt symbol automatically generated by the system. Enter "EOF" in the fourth line, and the system will save the three rows of a B c just entered to a file named friends.
Now let's check whether the input is successfully saved. The same command uses different pipeline symbols to display the file content or create files. This is the powerful pipeline symbol.

3. Linux usage skills (not completed yet, for your help)

There are too many tips for using Linux. Here we will summarize:
4. Summary of basic commands

1) ls

Ls -- color = never *. txt>; the report does not show the text color. All txt files are recorded in the report file.

2) cd
Cd ../to the upper-level directory
Cd... to the upper-level directory
Cd ~ Enter the user's personal directory. the root user is the/root directory, and the kris user is the/home/kris directory.

3) rm
The rm-fr directory name is used to directly delete a directory and all directories in it, without any prompt.

4) cp
Cp source directory target location-R copy all files and subdirectories in the original directory

5) echo
Echo message "I Love You" displays some content under the character interface. Here is "I love you"

6) export
Export LC_ALL = defines a variable LC_ALL and sets it to NULL.
Export LANG = zh_CN.gb2312 defines the LANG value of a variable as zh_CN.gb2312.
Export http_proxy = "http://xxx.xxx.xxx.xxx: port"
Define http Proxy Server

7) find
Find-iname [Directory] the file name is in the specified directory (if no directory is specified, it is the current directory) to find the file with the specified file name

Grep
Ps-A | grep some_command

Add the-A parameter to the ps command to display all currently running processes. Use the pipeline symbol "|" and the grep command to check whether the specified some_command is running.

9) lynx
Lynx www.google.com

The Web browser of the character interface, which is used to browse www.google.com, is very fast because there is no image

Author: birds"

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.