CentOS Study Notes-Basic commands and centos Study Notes --

Source: Internet
Author: User

CentOS Study Notes-Basic commands and centos Study Notes --
Linux basic commands

Linux servers do not have X-window installed, that is, there is no windows environment and only the text mode. Therefore, mastering some Linux commands is obviously important for future work.

Key keys: [Tab], [ctrl]-c, [ctrl]-d

Take a look at the hotkey before learning the command, which can improve work efficiency.

  • [Tab] buttons

This [Tab] button is one of the best features of Linux Bash shell! He has the "command completion" and "file completion" functions! The point is that we can avoid making an error in the command or file name! Great! However, if you enter the [Tab] key in different places, different results will be displayed!

Let's look at two examples:

[Root @ localhost ~] # Ca [tab] [tab] <--- [tab] [tab]: 2 times of hitting the [tab] key cacertdir_rehash cache_repair caller casecache_check cache_restore capsh catcache_dump cal captoinfo catchsegv
<--- [Tab] [tab] lists related commands starting with "ca ".

 

[Root @ localhost dev] # ls-al p [tab] [tab] <--- [tab] [tab] is two times of hitting the [tab] key parport0 port ppp ptmx pts/
<--- [Tab] [tab] lists all files starting with p in the/dev directory.
  • [Ctrl]-c
  • If you enter incorrect commands or parameters under Linux, what if the command or program will "run continuously" under the System sometimes? Don't worry, if you want to "stop" the current program, you can enter [Ctrl] and the c button (Press [Ctrl] First and press the c button again, is a combination of buttons), that is, to interrupt the current program button!

  • [Ctrl]-d
  • So what is [Ctrl]-d? Is the combination of [Ctrl] and d! This combination Of buttons usually indicates the End Of the keyboard Input (End Of File, EOF or End Of Input! In addition, it can be used to replace the exit input! For example, if you want to directly exit the text interface, you can press [Ctrl]-d to directly exit (equivalent to entering exit !).

Basic commands
  • Command for displaying date and Time: date
[root@localhost ~]# dateWed Dec 10 17:04:35 CST 2014
  • Online Help info page
In this case, an online help command is the same as the local man page. (The man package is not installed for minimal)
Buttons Work
B Move the cursor to the first node in the info screen
E Move the cursor to the last node in the info screen
N Go to the next node
P Go to the previous node
U Move up a Layer
S (/) Search in info page
H Show Help Menu
Q End info page this time
Correct shutdown commands: sync, shutdown, reboot, halt, poweroff, init

Pay attention to the following:

  • Observe the system usage status:
    If you want to see who is online, you can issue the "who" command. If you want to see the online status of the network, you can issue the "netstat-a" command, the program running in the background can run the "ps-aux" command. Using these commands can give you a little idea about the current usage status of the host! Of course, you can determine whether the server can be shut down (these commands will be mentioned in common Linux commands later !)
  • Notify online users of the shutdown time:
    Before shutdown, you have to give online users some time to finish their work. Therefore, you can use the special shutdown command to achieve this function.
  • Correct shutdown command:
    For example, shutdown and reboot commands!
Synchronize data to disk: sync
[root@localhost ~]# sync

In Linux, to speed up Data Reading, some data in the loaded memory will not be written back to the hard disk by default, but will be cached in the memory first, as a result, if a piece of data is repeatedly rewritten by you, it can be read directly from the memory because it has not been written to the hard disk. The speed must be quite fast!

However, this also causes some trouble, that is, in case your system is shut down abnormally due to some special circumstances (such as power outages or accidentally kicking power, because the data has not been written into the hard disk, wow! Therefore, the data upgrade is abnormal! What should we do? At this time, the sync command is required to write data! Enter sync directly under the text interface. data that has not been upgraded in the memory will be written to the hard disk! Therefore, this command is important before the system is shut down or restarted! It is best to run it several times more!

Although the shutdown, reboot, halt, and other commands have all called the sync tool before shutdown, it is always reassuring to do more times.

The usual shutdown command: shutdown
Option and parameter:-t sec:-t followed by the number of seconds, that is, "shut down after a few seconds" means-k: do not really shut down, just send a warning message! -R: restart (commonly used) after the system service is stopped-h: Shut down the system service immediately after it is stopped. (Commonly used)-n: Shut down directly using the shutdown function without going through the init program.-f: After the system is shut down and started, force the disk check skipped by fsck-F: After the system is restarted, force fsck disk check-c: cancel the content of the shutdown command that is already in progress. Time: This is a required parameter! The system shutdown time! The time example is described below.
Example:
[Root @ www ~] # Shutdown-h now shut down immediately, where now is equivalent to the status where the time is 0 [root @ www ~] # Shutdown-h 20:25 system shutdown at today. If this command is issued at, shutdown the system every other day [root @ www ~] # Shutdown-h + 10 the system will automatically shut down in 10 minutes [root @ www ~] # Shutdown-r now system restarts immediately [root @ www ~] # Shutdown-r + 30 'the system will reboot' The system will be restarted in 30 minutes and The following information will be displayed to all online users [root @ www ~] # Shutdown-k now 'this system will reboot' only sends parameters for the warning letter! The system will not shut down! Scare people!
Restart, shut down: reboot, halt, poweroff

Generally, only the shutdown and reboot commands are recorded! However, the command poweroff is relatively simple!

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.