Useful terminal commands for programmers in linux

Source: Internet
Author: User

The terminal command file encoding and Conversion Tool enca used by programmers in linux: enca-L zh_CN-x UTF-8 file converts file encoding to "UTF-8" encoding enca-L zh_CN-x UTF-8 <file1> file2 if you don't want to overwrite the original file, you can open the ISO file like this: mount-o loop test. iso/cdrom: mount the ISO file to the cdrom folder. unmount umount/cdrom and modify the default Operating System: sudo cp/boot/grub. cfg/boot/grub. performance_backupsudo gedit/boot/grub. cfg find default 0, change 0 to the location of your other system, in item X, that is, change to X-1 (starting from 0 ). Do not execute sudo update-grub, otherwise it will be reset. If the installation fails due to dependency packages not installed, use sudo apt-get install-f. How to view historical Command records: use history {$ NUM} to view recently used $ NUM commands. The default value is 500; 1. ctrl + r: (reverse-I-search, the terminal will scroll to display your History commands. When you find the appropriate historical command, you can directly [Enter] and run the historical command. 2. Use '! ': "Success, success": Enter !! (Called "progress, progress") to execute the last command in history. "Digit number": type! Number (for example! 302) will execute 302nd items in the command history file. "Pipeline string": type! String (such! Rpm) will execute the command that matches the latest near output of the string in the command line. Bash Shell shortcut: Ctrl + a-jump to the beginning of the line Ctrl + e-jump to the end of the line Ctrl + k-delete from the cursor to the end of the line Ctrl + l-clear screen, similar to the clear command Ctrl + w-delete the last word/parameter cp filename {,. bak} This Command copies the filename file to filename. bak is based on bash's expansion of braces, filename {,. bak} is expanded to filename. bak then sends the script to cpCentOS to automatically run the program upon startup: Sometimes we need to set a script on the server so that it can be started as soon as it is started. The method is as follows: cd/etc/init. dvi youshell. sh # modify youshell. sh to your own script name, write your own script, and save and exit. When writing a script, add the following note # add for chkconfig # chkconfig: 2345 70 30 # description: the description of the shell # Brief description of the script # processname: servicename # The first process name, which will be used when the script is set to be started later: 2345 indicates the script running level, that is, it can be run in the four modes of 2345, 234 is a text interface, and 5 is the graphic interface refers to the sequence number of the script to be started in the future. If the sequence number of the startup of other programs is smaller than 70 (such as 44 and 45 ), the script must be started only after these programs are started. 30 indicates the stop sequence number of the script when the system is disabled. Add executable permissions to the script: chmod + x youshell. sh use the chkconfig command to set the script to self-start chkconfig -- add servicename so that your script can run automatically after it is started. In addition, you can use this method in redhat to enable auto-start upon startup. Usage of chkconfig Function Description: check and set various services of the system. Syntax: chkconfig [-- add] [-- del] [-- list] [System Service] Or chkconfig [-- level <level code>] [System Service] [on/off/reset] supplementary instructions: this is a program developed by RedHat following GPL rules. It can query which system services the operating system will execute in each execution level, including various resident services. Parameter:-add adds the specified system service, enables the chkconfig command to manage it, and adds relevant data in the system startup description file. -Del: deletes the specified system service. It is no longer managed by the chkconfig command, and relevant data is also deleted in the description file started by the system. -Level <level code> specifies the execution level in which the read system service is enabled or disabled. The chkconfig command can also be used to activate or remove the service. The chkconfig-list command displays the list of system services, and whether these services have been started (on) or stopped (off) in the running level from 0 to 6 ). Chkconfig-listchkconfig-list httpdhttpd 0: off 1: off 2: on 3: on 4: on 5: on 6: off2: chkconfig can also be used to set whether a service is started or stopped at a specified running level. For example, to stop the nscd service in runlevel 3, 4, and 5, run the following command: chkconfig-level 345 nscd off 3: services managed by xinetd are immediately affected by chkconfig. For example, if xinetd is running and finger is disabled, after the chkconfig finger on command is executed, finger does not have to manually restart xinetd to be enabled immediately. Changes to other services do not take effect immediately after chkconfig is used. You must use the service servicename start/stop/restart command to restart the service. Method 2: edit/etc/rc. d/rc. the local file is in the program name path, for example,. sh/home/. sh

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: 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.