Linux basics #1: Basic bash operations

Source: Internet
Author: User

Linux basics #1: Shell is an intermediary between the user and the underlying operating system (usually the kernel, the Shell responsible for passing USER commands and operations to the underlying operating system is generally divided into: graphical Shell (GUI), command line Shell (CLI) CLI: command line interface GUI: in Graphical User Interface Linux, the default GUI is GNOME. The default CLI is: BASH prompt starting with # Or $. # indicates that the current User is the root User, $ indicates that the current user is a common user. We can press the Tab button on the keyboard to automatically complete the su-to enter the root user mode. Su does not switch the terminal, but is still in the current directory. su-switches the new terminal. If you do not know or forget the password, sudo passwd root can directly reset the root password. Direct passwd is to change the password and enter exit to exit the root mode. Common users use sudo. You can run hostname as an administrator to view the system information of the Host Name uname, uname-a all information command IDS can display the information of the current user ~ Indicates that the home directory Ctrl + C terminates the current command Ctrl + C: sends the SIGINT signal. By default, the process ends, but the process itself can redefine the behavior of receiving this signal. Ctrl + Z: Send the SIGSTOP signal, the process is only stopped, then send the SIGCONT signal, and the process continues to run. Ctrl-d is not a sending signal, but a special binary value, indicating that EOF 1, Ctrl + C is more violent, is to send Terminal to the current program, for example, if you are running a search function and the file is being searched, Ctrl + C will force the current process to end. 2. Ctrl + Z suspends the current program and suspends it. For example, if you are in the mysql terminal, you need to execute other file operations, I don't want to exit the mysql terminal (because I have to enter the user name and password next time, which is quite troublesome), so I can press ctrl + z to suspend mysql and perform other operations, enter fg and press enter to return. Of course, you can suspend many processes to the background. Then, you can add a number to fg to return the suspended process to the foreground. Of course, it is very convenient to switch the front and back ends with the bg and fg commands. 3. Ctrl + D is used to send an exit signal, which is not so strong. It is similar to ctrl + C. For example, you can return the exit signal from the administrator root to your normal user. Clear: the command for clearing the terminal screen consists of the command, option, and parameter Tab key used to complete the file (folder) name. The command press the arrow key "up" or Ctrl + p, repeat the last command BASH to record previous commands. You can use the history command to view all history commands. BASH can call history in the following ways to simplify the operation :!! Repeat the previous command! Repeat the previous command that starts with a specified character! Num: Execute the command by the serial number of the history record !? Abc commands that contain abc are repeated! -N. before repeating n commands, we can use ctrl + r to search and query the history Command records. (ESC +) the parameter command su of the previous command can be switched to the USER command passwd. You can modify the password of the current user and append an & after the command to run the command in the background. For example, firefox &: Add & indicates running firefox in the background, so that the command line can continue to be used. CLI is a multi-process terminal command wildcard: *: matches zero or multiple?: Match any character [0-9]: match a number range [abc]: match the character [^ abc] in the list: you can use the following command to manage background jobs that match characters other than the list: & run jobs in the background to display background jobs (jobs are scheduled for tasks on the current terminal. Ps is used to view and manage processes on the current terminal or system. Ps must be at the underlying level .) Fg transfers the background job to the foreground for execution; fg = foreground 'bg (+ process serial number) continues to execute a background job bg = background. For example, if you buy process 2, sleep 5000 has stopped, then bg 2 can reply to it and continue.

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.