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

Source: Internet
Author: User
Tags create directory

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 .

Learning Linux is a gradual process, with a bit of accumulation. It's better to have a small project ready to learn and speed up your learning. Oh

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

Shutdown-h now    immediately shuts down shutdown-r now reboot    reboot    now reboot

Su-If you are currently a normal user, enter this command to switch to the administrator user (root), and if you want to switch to another user, type Su-user name such as: Su-xiaoluo
Logout Log off from the current user (if it is a terminal in the graphical interface, enter the exit command to exit the current user)
CD switch directory "such as: CD/switch to the root directory of Linux!! (/) represents the root directory "
PWD shows the command under which path the user is currently in (This command is particularly used, and if you do not know the current folder in the command line, you can enter the command pwd

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

Useradd User name  "Add a user" such as: Useradd xiaoluopasswd username    "Modify password for specified user name" such as: passwd xiaoluouserdel username    "Delete a user, However, the user's subfolder under the home file will retain "such as: Userdel xiaoluouserdel-r username    " To delete a user, and delete the subfolder along 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-thevim 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 about the VI editor and how to use it, please go to the VIM website

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    "to view the file name of the current directory"  ls-l "View current directory Detail file information" ⑦ 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 Home) ls-l "List of files and directories displayed in a long list" such as: ls-l//
Ls-a "list hidden files and directories" such as: Ls-a/homemkdir "Create directory" such as: mkdir xiaoluormdir "Delete empty directory" such as: RmDir Xiaoluo (only empty directory can be deleted, if there are other files in the directory, the command is invalid) Touc H "Create empty file" such as: Touch Test.java

The following are some common commands:

cp "Copy command" such as: Cp/home/test.java/(the Test.java file under the home path is copied to the root directory) cp-r dir1 Dir2 "-R for recursion, the Dir1 represents the folder and the files inside the DIR2 path there." 
such as: Cp-r/home/xiaoluo/(Copy the Xiaoluo folder under home to the root directory) MV "Move files and change the file name" such as: Mv/home/test.java/( Move the Test.java file under home to the root directory)
Mv/test.java/hello.java (means to change Test.java file name to Hello.java) RM "Delete files and directories" such as: Rm/test.java (remove Test.java from the root directory) " Note: If the file is a folder, deleting "Rm-rf *" (-R for recursion, F for forced deletion ) deletes all content, including directories and folders "such as: Rm-rf/home/xiaoluo (forcibly deleting the Xiaoluo folder under Home) ln "Establish symbolic links similar to shortcuts in Windows (root or appropriate user rights required)" Ln-s source target destination such as: Ln-s/etc/inittab/inittab (This creates a inittab link in the root directory, The link points to the Inittab file under the ETC directory) more "show file contents with paging" 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
such as: more/etc/prelink.conf (to etc, the contents of the Prelink.conf File page display) | " pipeline Command " "This command in the Linux system with a lot of" (| The role of this command is to | The result of the preceding command is given | The following command to process) such as: Ls/etc | More (| The previous command is to display all files and directories in the ETC folder, | The next command is displayed in pagination form,
so the meaning of this command is to display all the files and directories in the ETC directory with pagination, grep "query content in text" This command is used very much as: grep "Xiaoluo"/home/test.txt ( Query the Test.txt file for the line containing the Xiaoluo text message)
If you need to show the number of rows that you are looking for, use: Grep-n "Xiaoluo"/home/test.txt (query the number of rows in the Test.txt file that the information is in and change all text) find "Search files and directories" such as: Find/ Home-name Test.java (Find files named Test.java under the home folder or all subfolders in home) REDIRECT Commands >, >>, <, such as: Ls-l/etc> a.txt ( Write the following list information to "overwrite" in the A.txt file, and if the A.txt file does not exist before, create the A.txt file and write the information in it.
If a a.txt file is present, the previous information is overwritten) ls-al/etc>> aa.txt (Append the list information of etc to the Aa.txt file information) Enter information from the file AAA < BBB

CentOS (ii)--some common commands for the initial knowledge of 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.