Summary of linux commands used in recent projects

Source: Internet
Author: User
This section abstract: recently, many linux commands have been used to deploy and release projects in the production environment, and the commands used are summarized and recorded. Linux command Summary: The following statements are made first: (1) These commands are run on redhatlinux and may not be used on IBMAIX...
This section abstract: recently, many linux commands have been used to deploy and release projects in the production environment, and the commands used are summarized and recorded. Linux command Summary: The following statements are made first: (1 ). these commands are run on redhat linux and may not work on ibm aix; (2 ). I will not introduce all commands, and I will not introduce all parameters for each command. I will only introduce what I use and is commonly used; (3 ). the introduction is not sequential. I just want to review and summarize the commands used in the recent period;
(4 ). I used the root user to log on to the linux system, and then created a pantp directory under the root directory. the operations that follow the black and white characters are all performed in this directory; (5 ). (1) and (2) in the command indicate several common forms of the command ;. ls --- the files in the current directory are commonly used in the following two ways: (1 ). ls displays the pantp file in the current directory (2 ). ls-alt: displays all the pantp files in the current directory (including. detailed list of hidden files at the beginning, and sorted by time. hostname (1) hostname view computer name (2) hostname-I view computer IP address. whoami to view the current login user. cp copy file or directory (1) Copy File (2) copy Directory
. Scp remote copying of files or directories (copying files or directories from one host to another) I have installed a linux system in the virtual machine, which I can't, just write the syntax, here, only the copy from the local machine to the remote host is listed, and the other copy from the remote host to the local machine is not listed; (1) copy a file first switch to the directory where the file to be copied on the local machine is located (you can also write the absolute path or the relative path as needed) scp local File name: username for remote host login @ remote host IP address: The Directory of the remote host lists an actual example:
(2) the copy directory is first switched to the upper layer of the directory to be copied on the local machine (you can also write the absolute path or the relative path as needed) scp-r Local directory name: username for remote host login @ remote host IP address: Login
. Vi command mode, edit mode, and baseline mode: press esc to switch to command line mode, in this mode, delete x to delete the current cursor character dd to delete the current row of the cursor Editing mode: press a, I, o to enter the editing mode a, the cursor will move one backward, insert I at the end of the current cursor before the current cursor. the characters where the current cursor is located will be moved behind o for another line. Insert the pantp characters in the following three ways:
The procedure is as follows: 1. open the file vi new.txt 2. place the cursor on the second character of the first line, press the letter a, and then enter pantp3. press esc to switch to command line mode 4. place the cursor on the second character in the second line, press the letter I, and then enter pantp5. press esc to switch to command line mode 6. place the cursor on the second character in the third line, press the letter o, and then enter pantp7. press esc to switch to command line Mode 8. enter wq to save and exit the original file as follows: after editing according to the above steps, the file content is as follows: exit and save (1) switch to command line mode (2 ): q Do not save disk exit vi: wq save and exit vi: q! Force exit vi. the more split screen display file is valid only when the file size exceeds a certain length. after the length exceeds a certain length, the percentage information is displayed; otherwise, the command works similar to cat; more file name. cat displays all the content of the file and all the content of the file at a time. cat file name. tail displays the latest file content (1 ). the tail-f file name dynamically displays the increasing content of the file; (2 ). the tail-1000f file name dynamically displays the content of the last 1000 lines of the file growth ;. history (1 ). history displays all historical commands (2 ). history 2 displays the last two commands. chmod changes the file mode x (execution), w (write), r (read). the red part contains a total of ten characters. The first character indicates whether it is a file or a directory, and d indicates a directory, -The second, third, and fourth characters of the file indicate the root user's read, write, and execute permissions of the current file;
The fifth, sixth, and seventh characters indicate the root user's permission to read, write, and execute the current file group; the 80 or 90 characters indicate the read, write, and execute permissions of users in other groups of the current file. (1 ). the chmod g + x file name adds w permissions to the user in the group to which the current file belongs to sed.txt; (2 ). chmod 777 file name to sed.txt. add w permissions to the group to which the current cp file belongs. in binary format, if you have the permission, write 1. if you do not have the permission, write 0. then calculate the total number. before the change: 110 100 -----> 6 4 4 4 need to be changed to: 100 110 110 -----> 6 6 4. chown: change the user and group of the table file or directory. (linux installed on my VM has only one root user and one root group. First, create a test group, and create a test user under the group, and the password is also test; operations for new users and groups are not described here, as a developer rarely) (1) chown user name file name/directory change the user of the file or directory to change the user of directory dir1 from root to test (2 ). change dir1 group from root to test. crontabcrontab labels in order to make this effect obvious, I set crontab. the sh file has been changed. the modified file is as follows: first, we will introduce the format of the schedule table in crontab as follows:
F1 f2 f3 f4 f5 program where f1 represents minute (0-59), f2 represents hour (0-23), f3 represents the day (1-31) of a month ), f4 indicates the month (1-12), f5 indicates the day of the week (0-6 0 indicates Sunday ). Program indicates the program to be executed.

When f1 is *, the program is executed every minute. when f2 is *, the program is executed every hour, and so on.
When f1 is a-B, it indicates that execution is performed from the minute a to the minute B. When f2 is a-B, it indicates that execution is performed from the hour a to the hour B, and so on
When f1 is */n, it indicates execution is performed every n minutes. if f2 is */n, it indicates execution is performed every n hours, and so on.
When f1 is a, B, c ,... a, B, c ,... execute in minutes. f2 is a, B, c ,... a, B, c... execute in hours, and so on. enter crontab-e and enter the following part. after the input is complete, Press: wq to exit. (2 ). to view the custom task, you can view the running result in mongolog.txt: (3) delete the custom task-r delete the current user's crontab file. This command is used with caution. This will delete all the custom tasks of the current user, we can directly import crontab-e, and then delete the unused. sedto use scriptto process the hosts file and sed.txtand sed.txt. in cp, Abc is replaced by the following before pantp executes the sed command: (1) Method 1: sed-e's/Abc/pantp/'a.txt-e indicates that the command is executed as a command line; parameter s indicates that the replacement operation is executed, the execution result will be displayed. note: In this case, only the execution result will be displayed, but the file itself has not changed. (2) The second case: sed-I's/Abc/pantp/'a.txt parameter-I, indicates that the file is directly modified without output, and the file itself has changed ;. ssh (1) log on to a machine. the current user is logged on by default. (2) log on to a machine using the specified User :. ps (1 ). ps-ef
Through the above command, I usually check whether a process exists. sometimes I need to kill the process according to the process. in this case, I use the kill-3 process number in combination with the kill command, use this command to generate a core file. (2). the ps-auxaux options will also be used together, but I will not summarize them here if they are not commonly used .. Rm deletes a file or directory; rm-rf file name or directory name .tar
(1) package tar, package directory A to a.tar-cvf a.tar a(2)decompress the tarpackage, and decompress the.tar package to tar-xvf a.tar. jar (1) package and package directory a into. jarjar-cvf. jar a (2) decompress the package and. jar decompress jar-xvf. jar (3) view the file list in the jar package. jar-tvf. jar. grep only describes two common options. c statistics I ignore the number of characters in a case-insensitive search file, and count the number of lines of characters, if the character to be searched appears more than once in a row, it will only be counted once; grep-c character file name. find is commonly used as follows: (1) view the files in a directory and the find system directory (2) matching the required File find path-name by file name matching options. wc-l number of lines of the current file output-c number of bytes of the current file output-w number of words of the current file output (1) wc file name (2) used with other commands, such as cat. clear the screen ;. pwd
View the current directory ;. su. switch to the specified user su-tyjk. switch to root user su. logout/exit to exit the current session box; the shutdown command is generally used in the actual production environment to verify that the problem is not used;
Shutdown: shutdown now restart: shutdown-r now reboot add 2012/09/11 toptop command is the resource manager in the linux system, which can display the current CPU, memory usage, and remaining amount. Unameuname-a view the linux system version
 
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.