Linux Learning CentOS (ii)--some common commands for the initial knowledge of Linux

Source: Internet
Author: User
Tags create directory

The first time you learn a Linux system, you have to start with some basic Linux commands.

Linux commands are commands for managing a Linux system. For Linux systems, whether the CPU, memory, disk drives, keyboards, mice, or users are all files, the Linux System Management command is the core of its normal operation, similar to the previous DOS command. There are two types of Linux commands in the system: built-in shell commands and linux commands .

Linux commands are very much ... No more than 4,000, at least 3500 or so, we can not all go to learn so many orders, it is impossible to learn .... Just like the Java API, we just need to remember some of the commonly used commands, we can go to Google for a little bit.

Here are some of the commonly used commands for a temporary study:

Shutdown-h now    shut down immediately. Shutdown-r Now restarts    reboot now restart    Su-If you are currently a normal user, enter this command to switch to the administrator user (root), If you want to switch to a different user  , type Su-user name such as: Su-xiaoluologout Log off from the current user (or enter the Exit command to exit the current user if it is at the terminal of the graphical interface  ) CD switch directory "such as: CD/table Switch to the root directory of Linux!! (/) indicates the root directory "PWD shows the command under which the user is currently under (This command is very much used, you can enter the command if you do not know the current folder in the command line pwd

Next is the user Management command to create the user and delete the user:

Useradd username  "Add a user" such as: Useradd xiaoluopasswd user name    "Change password for specified user name" such as:passwd Xiaoluouserdel User name    "Delete a user, but the user's subfolder under the home file will retain " such as: Userdel xiaoluouserdel-r username    "To delete a user, and delete the subfolder with the user in the home folder "such as: Userdel-r Xiaoluo

When it comes to Linux, here's a well-known editor for Linux-theVI editor ... The editor believes that people who have done Linux development are familiar with it, and even have software like the VI Editor (Gvim Editor) on the Windows platform. For more information and tips on how to use the VI editor, please click Http://baike.baidu.com/view/908054.htm to view

The following is a simple example to understand the VI Editor's use. (Create a Hello.java program with the VI editor and compile and run)

Steps :

① at the command prompt    , type vi hello.java② input    i "enter into the edit state" ③ type     ESC "Enter the command line input status" ④ typing     : "So you can enter the command. "⑤   -Wq" Save and Exit ", q! "Do not save and exit" ⑥ls    "View the current directory filename"  ls -l "View current directory Detail file information" ⑦ to compile and execute the program you just wrote! (Javac, Java)

The above is just a simple example written in the VI editor, in the Linux system, as long as you have the file permissions, you can use the VI editor to edit it

The above example has a new command LS , so now we have to introduce some common commands:

ls "list files and directories" such as:ls /home (list all files and directories under the page)LS -L "List of files and directories displayed in a long list" such as:ls -l/home  LS -a "lists hidden files and directories" such as:ls -a/homemkdir "Create directory" such as:mkdir xiaoluormdir "Delete empty directory" such as: rmdir Xiaoluo (only empty directories can be deleted, if there are other files in that directory, the command is invalid)touch "Create empty file" such as:touch Test.java

The following are some common commands:

CP"Copy command" such as:CP/home/test.java/(Copy the Test.java file under the home path to the root directory)CP-R Dir1 Dir2 "- RRepresents recursion, copies the folder that Dir1 represents and the files inside it to the DIR2 path, "such as:CP-r/home/xiaoluo/(Copy the Xiaoluo folder under home to the root directory)MV"Moving files and changing filenames" such as:MV/home/test.java/(means to move the Test.java file under home to the root directory)MV/test.java/hello.java (indicates that the Test.java file name is changed to Hello.java)RM"Delete files and directories" such as:RM/test.java (remove Test.java from root) "Note: If the file is a folder, it will not be deleted"RM-RF * "(- R for recursion, F for forced deletionDelete all content, including directories and folders such as:RM-rf/home/xiaoluo (forcibly delete the Xiaoluo folder under Home)LN"Establish symbolic links similar to shortcuts in Windows (root or appropriate user rights required)"LN-s source target target such as:LN-s/etc/inittab/inittab (This will create a inittab link in the root directory, which points to the Inittab file under the ETC directory) More"Show file contents, with pagination" Less"Show file contents, with pagination" If there is a lot of content in one of our files, you can use the more command to page it as: More/etc/prelink.conf (to display the contents of the prelink.conf file below etc) | 【Pipeline Command"This command is used in many Linux systems" (| The function of this command is to hand over the results of the previous command to | The command to be processed later) such as:ls/etc | More(| The previous command is to show all files and directories in the ETC folder, | The next command is displayed in pagination, so this command means to display all the files and directories in the ETC directory by paging)grepThe "Query content in text" command is used very much as:grep "Xiaoluo"/home/test.txt (the line of text that contains Xiaoluo in the Test.txt file) is used if it is necessary to show the number of lines in which the text is being looked at:grep-N"Xiaoluo"/home/test.txt (Query the number of rows in the Test.txt file that the information is in Xiaoluo and all the text is diverted)Find"Search for files and directories" such as:Find/home-name Test.java (look for files named Test.java under the home folder or all subfolders in home) redirect Command ">, >>, <" such as:ls-l/etc> A.txt (ETC, the following list information is written to the a.txt file "overwrite", if the A.txt file does not exist before, then create a a.txt file and then write the information in, if there is a a.txt file, it will overwrite the previous information)ls-al/etc>> aa.txt (Append etc list information to aa.txt file information) Enter information from file AAA < BBB

Almost forgot a very important command:

"cat,vi" (CAT command can only view files, vi command can view the file and can modify the file, for some of the key files we generally use the Cat command to view) such as: Cat/etc/profile ( Just view the contents of the file) Vi/etc/profile (view, and can modify the contents of the file)

CentOS for Linux Learning (ii)--some common commands for Linux

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.