CentOS for Linux (2)-common linux commands

Source: Internet
Author: User

After installing CentOS6.4 on the VM, I was excited when I watched the linux system run successfully ...... But the road to learning is still far away...

To learn about linux for the first time, you must first run some basic linux commands.

Linux commands are used to manage Linux systems. For a Linux system, whether it is a central processor, memory, disk drive, keyboard, mouse, or user, it is a file. The Linux system management command is the core of its normal operation, similar to the previous doscommand. There are two types of linux commands in the system:Built-in Shell commandsAndLinux commands.

There are a lot of linux commands... There are no more than 4000, or at least about 3500. We cannot learn so many commands, nor can we finish learning them .... Just like java APIs, we only need to remember some frequently-used commands. If you use them, just google them.

Below are some common commands for the time being:

Shutdown-h now shutdown-r now restart reboot now restart

Su-if the current user is a common user, enter this command to switch to the administrator user (root). If you want to switch to another user, enter the su-user name, for example, su-xiaoluo.
Logout logs out from the current user (if it is on a GUI terminal, enter the exit command to exit the current user)
Cd switch directory. For example, cd/indicates switching to the linux root directory !!(/) Indicates the root directory.]
Pwd displays the command in which path the user is currently running (this command is used in many cases. If you do not know the current folder in the command line, you can enter the command pwd

The user management commands for creating and Deleting Users are as follows:

Useradd username [Add a user] For example: useradd xiaoluopasswd username [Change Password for the specified username] For example: passwd xiaoluouserdel username [delete a user, however, the user's subfolders in the home file are retained. For example, userdel xiaoluouserdel-r username: [delete a user and delete the subfolders of the user in the home folder together with the user.] For example: userdel-r xiaoluo

Speaking of linux, a famous editor under linux must be mentioned here --Vi Editor... I believe that anyone who has worked in linux development is not familiar with this editor. on the windows platform, there are even software similar to the vi Editor (gvim editor ). For more information about the vi editor and tips, click http://baike.baidu.com/view/908054.htm.

The following is a simple example to get a preliminary understanding of the use of the vi editor. (Use the vi editor to create a Hello. java program and compile and run it)

Procedure:

① Input vi Hello in the command line prompt. java ② enter I [enter the editing status] ③ Press esc [enter the command line Input status] ④ Press: [in this way, you can enter the command.] ⑤ Press wq to [Save and exit], q! [Do not save and exit] ⑥ ls [view the file name of the current directory] ls-l [view the details of the current directory] 7. Compile and execute the program you just compiled! (Javac, java)

The preceding is a simple example written in the vi editor. in linux, you can use the vi editor to edit a file as long as you have the file permission.

In the preceding example, a new command is displayed.LsSo now we have to introduce some common commands:

Ls [List Files And Directories] such as ls/home (list all files and directories under home) ls-l [List Files And Directories In a long list] such: ls-l/home
Ls-a [list hidden files and directories] For example: ls-a/homemkdir [create a directory] For example: mkdir xiaoluormdir [delete an empty directory] For example: rmdir xiaoluo (only empty directories can be deleted. If there are other files in this directory, this command is invalid) touch [Create an empty file] For example: touch Test. java

The following are some common commands:

Cp [Copy command] such as cp/home/Test. java/(set Test. copy the java file to the root directory) cp-r dir1 dir2 [-r indicates recursion, copy the folder represented by dir1 and the files in it to the dir2 path]
For example, cp-r/home/xiaoluo/(copy the xiaoluo folder under home to the root directory) mv [Move file and change file name], for example, mv/home/Test. java/(indicates. move the java file to the root directory)
Mv/Test. java/Hello. java. change the java file name to Hello. java) rm [delete files and directories] such as rm/Test. java (Test. java delete) [Note: if this file is a folder, it cannot be deleted] rm-rf *【(-R indicates recursion and f indicates force deletion.) Delete all contents, including directories and folders.] For example, rm-rf/home/xiaoluo (Force Delete the xiaoluo folder under home) ln [Create a symbolic link, similar to the shortcut in windows (root permission or corresponding user permission is required). The ln-s source target is as follows: ln-s/etc/inittab (this will create an inittab Link under the root directory, which points to the inittab file under the etc directory) more [display file content, with paging] less [display file content, with paging] if a file contains a lot of content, you can use the more command to paging it
For example: more/etc/prelink. conf (display the content of prelink. conf file under etc by PAGE) | 【Pipeline command] [This command is used in many linux systems] (| the function of this command is to deliver the result of the previous command to the next command for processing), such: ls/etc | more (| the previous command shows all the files and directories in the etc folder. | the subsequent command is displayed on pages,
Therefore, this command is used to display all files and directories under the etc directory by page. grep [query content in the text] is used in many ways, such: grep "xiaoluo"/home/Test.txt (query the line of text information containing xiaoluo in the Test.txt file)
To display the number of lines of the queried text, use grep-n "xiaoluo"/home/test.txt(query the number of lines of the information in xiaoluo in the test.txt file and change all text lines) find [search for files and directories] such as find/home-name Test. java (the name is Test in the home folder or in all subfolders in home. (For example, ls-l/etc> a.txt (to overwrite the information in the.txt file). If the.txt file does not exist, the.txt file is created and the information is written in,
If the.txt file exists, the previous information will be overwritten.) ls-al/etc> aa.txt (Add the following information of etcto the information of aa.txt file) aaa <bbb

I almost forgot a very important command:

[Cat, vi] (the cat command can only view files. The vi command can view and modify files. For some key files, we generally use the cat command to view them)
For example, cat/etc/profile (only view the content in the file) vi/etc/profile (view and modify the content in the file)

Subsequent blog posts will continue to record the details of the Linux system and add more common Linux commands.

 

 

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.