CentOS Learning notes-BASIC commands

Source: Internet
Author: User

Linux basic commands

Linux servers basically do not install X-window, that is, there is no Windows environment, only text mode, so mastering some of the Linux commands for future work is obviously very important.

Important several hotkeys [Tab], [Ctrl]-c, [ctrl]-d

Take a look at the hotkey before you learn the command, which can improve productivity.

    • [Tab] Button

This [Tab] key is one of the best features of the Linux bash shell! He has the function of "command completion" and "File Complete". The point is, we can avoid the wrong command or file name! It's great! But the [Tab] key is entered in different places, there will be a difference in the result Oh!

See 2 examples:

[[Email protected] ~] # Ca[tab][tab]     <---[Tab][tab] is 2 strikes [tab] key cacertdir_rehash  cache_repair      caller            Casecache_check       cache_restore     capsh             catcache_dump        cal               captoinfo         CATCHSEGV
<---[Tab][tab] lists the list of commands associated with the CA beginning

[[email protected] dev] # ls-al P[tab][tab] <---[Tab][tab] is 2 hits [tab] key parport0  Port      PPP       PTMX      pts/
<---[Tab][tab] lists all files in the/dev directory that begin with P
    • [Ctrl]-c button
    • If you entered the wrong command or parameter under Linux, sometimes the command or program will "run" at the bottom of the system. Don't worry, if you want the current program to "Stop", you can enter: [Ctrl] and C keys (press [Ctrl] not put, and then press the C button, is a combination of keys), that is the key to interrupt the current program!

    • [Ctrl]-d button
    • So [what is ctrl]-d?] is the combination of [Ctrl] and D buttons! This combination of keys usually means: "Keyboard input ends (end of File, EOF or end of input)" means! In addition, he can also be used to replace the input of exit! For example, if you want to leave the text interface directly, you can simply press [ctrl]-d to go straight away (equivalent to entering exit!). )。

Basic commands
    • command to display date and time: Date
[[Email protected] ~] # Date Wed Dec 17:04:35 CST 2014
    • Online Help Info page
An online help command is the same as the local man page. (Minimal no man package installed)
key working
move cursor to the first node in the info screen
move cursor to the last node in the info screen
go to next node
Go to previous node
u Move up one level
s (/)
h Show Help menu
q end this time info page
Correct shutdown command: Sync, shutdown, reboot, Halt, Poweroff, Init

There are a few things to keep in mind when shutting down:

    • Observe the system's usage status:
      If you want to see who is online, you can release the "who" command, and if you want to see the network online status, you can release the "netstat-a" command, and to see the background of the program can run "ps-aux" this command. Use these commands to let you know a little about the current state of the host! Of course, you can tell if you can shut down (these commands will be mentioned in the Linux common commands later!) )
    • To notify the online user of the time when the computer shuts down:
      To shut down before you have to give online users some time to end their work, so this time you can use shutdown special commands to achieve this function.
    • The correct shutdown command is used:
      For example shutdown and reboot two commands!
Data synchronously written to disk: Sync
[[Email protected] ~] # Sync

In the Linux system, in order to speed up the data read speed, so in the default case, some already loaded in memory of the data will not be directly written back to the hard disk, but the memory first, so that if a data is rewritten by you repeatedly, then because he has not been written to the hard disk, So it can be read directly from memory, in the speed must be very fast on quite a lot!

However, this also creates a bit of a problem, that is, in case your system causes abnormal shutdown due to special circumstances (such as power outages or careless kicks to power), because the data has not been written to the hard disk, wow! So it will cause the data upgrade is not normal! What do we do then? This is the time you need the sync command to write the data! Enter sync directly under the text interface, then the data that has not been upgraded in memory will be written to the hard drive! So, this command is important before the system shuts down or restarts. Better run a few more times!

Although the current shutdown/reboot/halt and so on commands are already in the shutdown before the sync this tool call, however, do more times always more reassuring point.

Customary shutdown command: shutdown
-T sec:--     k-R     -     H-     n-f       - F       -C     : Cancels the content of the shutdown command that is already in progress. Time   : This is the parameter that must be added! Specify the time the system shuts down! The example of time is explained below. 
Example:
[[Email protected] ~]#Shutdown-h NowShut down immediately, where now is equivalent to time of 0the status of [root@www ~]#shutdown-h 20:25System at today's 20:25session shutdown, if this command is issued at 21:25, the genius shuts down the machine [root@www ~]#shutdown-h +10The system shuts down automatically after 10 minutes [root@www ~]#Shutdown-r Nowsystem restarts immediately [root@www ~]#shutdown-r +30 ' The system would reboot 'in another 30 minutes the system restarts and displays the following information to all users who are online [root@www ~]#shutdown-k Now ' This system would reboot 'Give only the parameters of the warning letter! The system does not shut down! Scare People!
Reboot, Shutdown: Reboot, Halt, Poweroff

Usually only remember shutdown and reboot these two commands! But the use of Poweroff This command is relatively simple!

CentOS Learning notes-BASIC commands

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.