Linux operating system Getting Started Basics Tutorial 5

Source: Internet
Author: User
Tags echo message

Chapter Fifth Linux commands and tips

1. Mount Umount Command

Trying to use your floppy disk and disc in Linux is not as dangerous as it is in Windows.

Think about it if you install a CD inside the software or play a game, your girlfriend, no matter the number of girlfriends, because you play the game every day instead of cooking dinner, and even others do dinner you actually did not have time to eat, and angrily pressed the CD-ROM eject button ... Haha, scared? Rest assured, there is absolutely no need for you to worry about this kind of thing in Linux.

To use the disc, first put the disc in place, then execute the following command:

MOUNT-T Iso9660/dev/cdrom/mnt/cdom mount the optical drive to the/mnt/cdrom directory

The-t parameter is the file system type for the specified disc, and in general, the disc is in the ISO9660 standard format. The next/dev/cdrom is the device file for your CD-ROM drive, and we said earlier that each hardware device corresponds to a standard device file. The last/mnt/cdrom directory is a directory on your local hard drive, and you can build one before using it if you find that there is no such directory. Of course, it is not necessary to use this directory, you can even be very sick of using the Mount/dev/cdrom/root command to mount your CD-ROM to your/root directory, so that your/root content will no longer be the original content, until you cancel the mount.

The following command cancels the mount:

Umount/mnt/cdrom or Umount/dev/cdrom

Both of these commands can be removed from the mounted CD, so that your disc can be removed. If not, then you can execute the Mount command again, then click on the Eject button on the CD-ROM drive to see if there is any reaction. No, right? This is one of the advantages of Linux, although the operation of a bit cumbersome feeling, but think about it, very safe and slightly complicated, which one do you choose?

A floppy disk is also used in a similar way:

Mount/dev/fd0/mnt/floppy

/DEV/FD0 is your floppy disk corresponding to the device files, the back of the natural is your mount directory. But if you want to try to get a floppy disk without canceling the floppy, you're a very BT person. Is there a mistake? The exit of the floppy disk is a mechanical operation, you have to press it out, what can I do? Then the method of canceling the floppy disk mount is similar:

Umount/dev/fd0 or Umount/mnt/floppy

In fact, when the first parameter-T, can be omitted, because the system will automatically determine what format should be used to identify. But knowing the format of the floppy disk or disc that we use is helpful for mounting an ISO file.

Mount-t Iso9660-o Loop/home/kris/somewhat.iso/mnt/cdrom

We all know that there are many ISO files on the Internet, which is to pack all the contents of the CD-ROM into a file, so as to facilitate the online transmission. We do not have to use the recorder to burn it into a CD after we obtain such a file, we can only use the above command to mount the CD-ROM ISO file to the/mnt/cdrom directory. The first parameter-T iso9660 is the file system format used by the disc, and the second parameter is the meaning of loopback.

Un-mount: Umount/mnt/cdrom

2. Piping commands

Pipeline command is a very important part of Linux system, here we only introduce some simple.

First we have learned a command cat to display the contents of a file, but have you ever encountered a file that is long and does not show up on one page? If you need to display a very long file page, you can use the more command whenever you press a key to display the next page:

More Loveletter

In this way, the contents of the Loveletter are displayed on the screen, automatically stop on a page, wait for your keys, and then continue to display the following page.

But what if we encounter a page that does not show up when we use the LS command to display all the files of a directory? This requires a pipe symbol "|", which is the character above the "\" button:

Ls/dev | More

Below, we have a new problem, we do not just want to look at the/dev directory below what files, we also want to use a file to record the command of LS just displayed all the results, need to use manual input? No, we introduce two pipe symbols: ">;" " >;>; ", that is, greater than the symbol.

Ls/dev >; Filenames.txt

There is also a pipe symbol is composed of two greater than the number of ">;>;", it and just ">;" The difference is that a pipe greater than a symbol is used to create a new file Filenames.txt, and if a file with the same name is already present, the previous content will be removed, while the two pipes greater than the symbol are used to append the new content to the existing file and create it without the file.

Now we VI filenames.txt look at a total number of lines, is not more than 1000 line ah? We run

Ls/dev >;>; Filenames.txt

Come again vi filenames.txt see, is not altogether more than 2000 line?

In fact, these two pipe symbols are easy to remember, to the left of the arrow means to put the contents of the preceding command into the following file, just that "|" The pipe symbol is used to treat the output of the preceding command as input data for the subsequent command. Below we look at a and just ">;>;" Just opposite the pipe symbol "<<":

Cat >;>; Friends << "EOF"

>; A

>; B

>; C

>; Eof

After running the first line, the meaning is to save our next input to the friends file, which ends when we enter "EOF". The meaning of "<<" is to send a data to the previous command.

In the middle I entered a B c three lines symbolically, and the ">;" in front of each line is a prompt symbol that is automatically generated by the system. The four-line input "EOF" system saves just the input of a B C three line to a file called friends.

Now we cat friends to see if the input you just made was saved successfully. How about the same command, using different pipe symbols to display the contents of the file, or to create a file, which is the powerful pipe symbol

3. Linux usage tips (no finishing, waiting for everyone to help)

There are too many tips for using Linux, and here's a slow summary:

4. Summary of BASIC commands

1) LS

LS--color=never *.txt >; Report does not display text color, and all txt files are recorded in the file

2) CD

Cd.. /to the top level directory

Cd.. /.. To the top level two directory

CD ~ Enter user's personal directory, root user is/root directory, Kris user is/home/kris directory

3) RM

RM-FR Directory name directly delete a directory and all the directories inside, without any hint

4) CP

CP Source Directory Target Location-r Copy the contents of all the files and subdirectories in the original directory

5) Echo

echo Message "I love You" shows something under the character interface, here is "I love You"

6) Export

Export lc_all= defines a variable lc_all and is set to NULL

Export lang=zh_cn.gb2312 defines the value of a variable LANG is zh_cn.gb2312

Export http_proxy= "Http://xxx.xxx.xxx.xxx:port"

Defining an HTTP Proxy server

7) Find

find-iname [Directory] file name in the specified directory (if you do not specify the directory is the current directory) to find files of the specified file name

Grep

ps-a | grep Some_command

Use the PS command Plus-a parameter to display all currently running processes, with the pipe symbol "|" Plus grep command to retrieve whether there is a some_command run that we specified

9) Lynx

Lynx www.google.com

The character interface of the Web browser, which we use here to browse www.google.com, because there is no picture, so very fast

Linux operating system Getting Started Basics Tutorial 5

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.