Learn how to use Linux commands

Source: Internet
Author: User

Linux has developed into many versions, and different companies have developed different Linux versions. It is best to describe Linux.

Linux is free of charge, but it is indeed a very good operating system, compared with the MS-WINDOWS has the advantages of reliability, stability, fast, etc, it also has a variety of powerful functions improved according to the unix version. Next, as a typical DOS and Windows user, let's take a look at some of the main Linux commands and hope that everyone can enter the Linux world as soon as possible.

1. Start

The Startup Process of Linux is similar to that of DOS (however, as the operating system itself, Linux does much more work at startup and exit than DoS ), you can also press CTRL + ALT + DEL to perform hot start. The difference is that when Linux is started to the end, you need to log on. The following is a typical logon process:

......
RedHat Linux release 5.1
Kernel 2.0.32 on an i686
Login:

You type: Root Then, the computer displays the password (password :) and enter your password (if it is the first time you start, it is the password you entered during installation. When a "#" prompt appears on the computer, it indicates that you have successfully logged on!

[Root @ localhost root] # _ Linux prompt
C:/> _ DOS prompt

Ii. Common commands:

1. display the file directory command ls (DIR in DOS)

Use the LS command in Linux to display files and directories (of course, you can still use the Dir command, but the parameters here are different ). Example: # ls

Root MNT boot Dev bin USR Xiong TMP etc games

It seems simple (equivalent to "DIR/W" in DOS), but you will find that what you see is hard to understand, even which directories and files are unclear, what are executable files? It doesn't matter. Enter # ls-F + root/mnt/boot/dev/bin/usr/Xiong * tmp/etc/games/readme

See it clearly, with * executable files (equivalent to EXE and COM files in DOS),/as sub-directories, and others as common files. In addition, we can use LS-L to display the details of the file directory (equivalent to the Dir command in DOS ). Be case sensitive !! Such as LS-F and LS are all incorrect. In addition, the LS command has many parameters. You can use man ls or ls -- help to learn more.

2. Change the current directory command Cd (CD in DOS)

In dos, we can use C:/> Cd/mnt/CDROM or CD/mnt/CDROM
C:/mnt/CDROM> Cd... or CD ..
C:/mnt> Cd/or C:/mnt> Cd/
In Linux, CD, MNT, and CDROM are used. The directory name must be in the same case as the actual one, and there must be spaces after CD.
PWD displays the current directory
CD .. it must be lowercase and contain spaces
The CD/directory is/, and the CD and/must contain spaces.

3. Create a subdirectory mkdir (MD or mkdir in DOS)

In Linux, only mkdir can be used. relative paths and absolute paths are available. Please compare:
C:/> MD Xiong, MD/Xiong, or Md/Xiong
Dossystem
[Root @ localhost/] # mkdir Xiong or mkdir/Xiong
Linux

4. Delete the subdirectory command rmdir (RD in DOS)

In Linux, run the rmdir command to delete sub-directories, for example:
Rmdir/mnt/CDROM is equivalent to RD/mnt/CDROM
Note: Like Dos, The subdirectories to be deleted must be empty and must be in the upper-level directory to delete the lower-level subdirectories.

5. Run the delete file command RM (DEL or earse in DOS)

In Linux, run the RM command to delete an object. For example:
Rm/UCDOS. bat is equivalent to Del/UCDOS. bat

6. The file RENAME Command mV (REN or rename in DOS) is used in Linux to rename the file. For example:
MV/mnt/Floppy P is equivalent to Ren/mnt/Floppy P
Note: In addition to renaming a file, the MV command in Linux also provides the file movement function. See the example below:
MV/mnt/floppy/bin is equivalent to the DOS command move/mnt/floppy/bin

7. file copy command CP (copy in DOS)

Use the CP command in Linux to copy files, for example:
CP/UCDOS/*/Fox is equivalent to copy/UCDOS/*. */Fox
Note: *. * In DOS is replaced by * in Linux.

8. Command man for obtaining help information (help in DOS)

Use the man command in Linux to obtain help information, for example:
Man ls is equivalent to help dir
Ls -- help is equivalent to Dir/

9. Show the file content less (type in DOS)

In Linux, run the less command to display files. For example, to display the content of mwm. lx in the Man1 subdirectory, enter [root @ localhost Man1] # less mwm. lx. You can. In Linux, we can also use another command "more" to display the file content, for example, more mwm. lx. As you can see, these two commands are very similar. In fact, the less commands have better functions than the more commands. You can explore them yourself. In Linux, two commands for reading files that are not available in DOS are also provided. They are head and tail commands, which are used to display the content of the file's header and back. Format: Head (tail) [m] 10 rows are displayed by default when n is used. For example:

Head/usr/man/mwm. Lx: displays the contents of the first 10 lines in the file mwm. lx.
Head 15/usr/man/mwm. Lx display the contents of the first 15 lines of the file mwm. LX
Tail 17/usr/man/mwm. Lx displays the contents of the last 17 lines of the mwm. Lx file.

10. redirection and Pipelines

As you know, in DOS, we can easily perform some special operations through redirection and pipelines, such as: dir> direct to put the current directory into the file direct; Type readme> direct, append the README content of the file to the direct file. For example, type readme.txt | more. In Linux, the redirection and pipeline operations are almost the same as those in DOS. The preceding two examples in Linux should be: ls> direct; less readme.txt | more (Note: actually, the more and less commands in Linux have paging functions ).

11. Shell: Command Interpreter)

In the dossystem, most of our users use the command.com command interpreter. Of course, you can also use the dosshell after Norton or dos4.0. There are several shell types in Linux. Common examples include ash, Bash, KSh, tcsh, and zsh. From the preceding environment variables, shell =/bin/bash can be used to see which shell you are using and where it is located. The default computer type is Bash.

DOS functions are similar to Linux commands. Linux is a multi-user, multi-task operating system, and its powerful functions are far more than that.

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.