20 commands that are useful to intermediate Linux users

Source: Internet
Author: User
Tags echo command disk usage ftp protocol

20 commands that are useful to intermediate Linux users 1. Command: FindSearches for files under the specified directory, starting at the parent directory, and then searching subdirectories. Note: The-name ' option is search case sensitive. You can use the-iname ' option so that the case can be ignored in the search.  (* is a wildcard, you can search all the files; '. Sh ' You can use the file name or part of the file name to make the output) Note: The above command looks for all files that contain ' tar.gz ' in the directory under the root and all folders and loaded devices. For more detailed information on the ' Find ' command, please refer to the "Find commands" Examples in Linux    2. Command: grepThe ' grep ' command searches the specified file for the line containing the given string or Word.  An example of searching for ' tecmint ' in '/etc/passwd ' files using the '-I ' option ignores case.  Use the '-r ' option to recursively search all the rows from the directory that contain the string "127.0.0.1".  Note: You can also use the following options:-W to search for words (egrep-w ' word1|word2 '/path/to/file).  -C is used to count the rows that meet the requirements (i.e., total number of the times the pattern matched) (grep-c ' word '/path/to/file). –color Color Output (grep–color Server/ETC/PASSWD). 3. Command: man' Man ' is the system help page. Man provides online documentation of all options and usage of the command.  Almost all commands have their help page, for example: the System help page for the Man command, similar to the help page for cat and LS. Note: The system help page is for the use of commands and Learningand designed. 4. Command: PSThe PS command gives the status of a process that is running, and each process has a specific ID that becomes the PID.  Use the '-A ' option to list all processes and their PID. Note: The PS command works well when you want to know which processes are running or need to know which process pid you want to kill. You can use it with ' grep ' to query the specified output, for example: the PS command and the grep command are split with the pipe line to get the results we want. 5. Command: KillPerhaps you have guessed from the name of the command what it is, kill is used to kill a process that is irrelevant or unresponsive. It is a very useful command, not very very useful. You may be familiar with WindowsThe next kill process may require a frequent restart of the machine because a running process cannot be killed in most cases, even if killing the process requires a reboot Operating SystemTo take effect. But in the Linux environment, things are not like that. You can kill a process and restart it instead of restarting the entire operating system.  Killing a process requires knowing the PID of the process.  Suppose you want to kill an already unresponsive ' apache2 ' process, run the following command: Search the ' apache2 ' process, find the PID and kill it. For example, in this example, the PID of the ' apache2 ' process is 1285.  Note: Every time you rerun a process or start a system, each process will generate a new PID. You can use the PS command to get the PID of the current running process. Another way to kill the process is: NOTE: Kill requires PID as a parameter, Pkill can choose how to apply it, such as specifying the owner of the process. 6. Command: WhereisThe role of Whereis is to locate the binary file \ Resource \ or help page of the command. For example, get binary files/resources for the LS and kill commands and help pages: note: Useful when you need to know where to save the binary file. 7. Command: ServiceThe ' Service ' command controls the start, stop, and restart of the service, allowing you to have the configuration take effect to open, stop, or restart a service without restarting the entire system.  Start Apache2 Server on Ubuntu: Restart Apache2 server: Stop apache2 Server: note: To use the service command, the script for the process must be placed in '/etc/init.d ' and the path must be in the specified location. If you want to run service apache2 start, actually do "service/etc/init.d/apache2 start". 8. Command: AliasAlias is a self-built system Shellcommand that allows you to specify aliases for long-named or frequently used commands. I often use the ' ls-l ' command, which has five characters (including spaces).  So I created an alias ' L ' for it. Try it: Remove the ' l ' Alias and use the Unalias command: Try it again: make a joke and designate an alias of an important command as another important command: Think how interesting it is now if your friend typed the ' CD ' command when he saw a list of directories instead of changing the directory; when he tried to use ' Su ' command, he will enter the current directory. You can then remove the alias and explain the situation to him. 9. Command: DFReports the disk usage of the system. It is useful for both normal users and system administrators to track disk usage. ' DF ' by checking the directory size work, but this value is updated only when the file is closed. See DF Command Examples in Linux for more examples of ' df ' commands. 10. Command: DuEstimate the space occupied by the file.  Level-by-layer statistics files (for example, recursively) and output summaries. Note: ' DF ' only shows file system usage statistics, but ' du ' statistics catalog contents. For more detailed information on the ' du ' command, please refer to the Ten du (Disk Usage) Commands. 11. Command: RMThe ' RM ' standard removal command.  RM can be used to delete files and directories.  Direct deletion of the directory will be an error: ' RM ' can not directly delete the directory, you need to add the corresponding '-rf ' parameter. Warning: the "rm-rf" command is a destructive command, if you accidentally delete an incorrect directory. Once you use ' rm-rf ' to delete a directory, all files in the directory including the directory itself will be permanently deleted, so use this command with great care. 12. Command: EchoEcho's function, as its name, is to print a piece of text based on standard output. It has nothing to do with the shell, nor does the shell read what is printed through the echo command. In an interactive script, however, Echo passes the information to the user through the terminal.  It is a command that is often used in scripting languages, interactive scripting languages. Create a small section of interactive script 1.  Create a new file on the desktop named ' interactive_shell.sh ' (remember to have the '. Sh ' extension).  2. Copy and paste the following script code to ensure consistency with the following.  Next, set the Execute permissions and run the script. Note: ' #!/bin/bash ' tells the shell that this is a script, and it is a good practice to write this sentence on the first line of the script. ' read ' reads the given output. 13. Command: passwdThis is a very important command, which is useful for changing your password in the terminal. Obviously, because of the security reasons, you need to know the current password. 14. Command: LPRThis command is used to print the specified file on the specified printer on the command line. Note: the "lpq" command lets you view the status of the printer (open or closed) and the status of the work (file) that is waiting to be printed. 15. Command: CMPCompares two files of any type and outputs the results to standard output.  If two files are the same, ' CMP ' returns 0 by default, and if different, the number of bytes and the first different location will be displayed. Take the following two files for example: File1.txt file2.txt compare these two files to see the output of the command. 16. Command: wgetWget is a free tool for non-interactive (for example, background) download files. Supports HTTP, HTTPS, FTP protocol, and HTTP proxy. Download FFmpeg using wget 17 Command: MountMount is an important command to mount a file system that cannot be mounted automatically.  You need root permission to mount the device.  After inserting your file system, first run the "lsblk" command, identify your device, and then write down the assigned device name. From this output, it is clear that I inserted a 4GB USB flash drive, so "SDB1" is to mount the file system.  Operate as root, and then switch to the/dev directory, which is where all file systems are mounted.  Create a directory of any name, but preferably related to a reference.  Now mount the "sdb1" file system to the "USB" directory.  You can now access the files from the terminal to the/dev/usb or from the Mount directory via the X Window System. It's time for the program ape to see how rich the Linux environment is! 18. Command: GCCGCC is a built-in compiler for the C language in Linux environments.  Here is a simple C program that is saved as hello.c on the desktop (remember that you must have the '. C ' extension). Compile and run Note: When compiling a C program, the output is automatically saved to a new file called "A.out", so the C program "A.out" will be modified every time it is compiled.  It is therefore better to define the output file name during compilation, so there is no risk of overwriting the output files. In this way, compile '-o ' to write the output to ' Hello ' file instead of ' a.out '. Run again. 19. Command: g++G++ is the built-in compiler for C + +.  Here is a simple C + + program that is saved as Add.cpp on the desktop (remember that you must have the '. cpp ' extension). Compile and run Note: When compiling a C + + program, the output is automatically saved to a new file called "a.out", so every compilation of the C + + program "A.out" will be modified.  It is therefore better to define the output file name during compilation, so there is no risk of overwriting the output files. Compile and run in this way 20. Command: JavaJava is one of the most widely used programming languages in the world. It is also considered to be an efficient, safe and reliable programming language.  Most web-based services now use Java implementations. Copy the following code to a file to create a simple Java program.  You might want to name the file Tecmint.java (remember: '. java ' extension is required). Compile Tecmint.java with Javac and run Note: Almost all Linux distributions have a GCC compiler, and most distributions have g++ and Java compilers built in, some of which may not be. You can install the required packages with apt or yum.

20 commands that are useful to intermediate Linux users

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.