Linux basic commands

Source: Internet
Author: User

  • first, the directory structure of Linux

    Directory name meaning

    /bin common commands for Linux in this directory, in some versions the same directory as the root directory.
    /boot This directory is stored in the system to use the program when booting, when using Lilo to boot Linux, will use some of the information here
    /dev The directory contains all the external devices used in the Linux system, and it is actually a port that accesses these external devices, and you can access these external devices without distinction from accessing a file or a directory. For example, by typing "cd/dev/cdrom" in the system, you can see the files in the optical drive, and type "Cd/dev/mouse" to see the relevant files of the mouse.
    /cdrom This directory is empty when the system is just installed, you can hang the optical drive file system in this directory, for example "Mount/dev/cdrom/cdrom"
    /etc The directory contains various configuration files and subdirectories to be used in system administration, such as network configuration file, file system, x system configuration file, device configuration information, setting user information, etc.
    /sbin This directory is used to store system administrator's system management program.
    /home If a user named "XX" is established, then there is a corresponding "/home/xx" path in the/* directory to hold the user's master directory.
    /lib This directory is used to store system dynamic connection shared libraries, almost all applications will use the shared library in this directory
    /lost+found the directory is empty in most cases. However, some files are temporarily stored here when there is a sudden power outage or an abnormal shutdown.
    /mnt The directory is also empty in general, you can temporarily hang other file systems in that directory.
    /proc can obtain system information in this directory, which is generated by the system itself in memory.
    /root If you are logged in as a superuser, this is the Superuser's home directory
    /tmp is used to store temporary files generated when different programs are executed
    Many applications and files for the/usr user are stored in this directory

    Second, Linux Basic use command

    1. LS lists the file and file directory commands
    LS--help is used to display the Help information for this command
    The LS--color display file is not color-coded. For example, the executable file is green, the normal file is white, the directory is blue
    Ls-a list all the files, including those hidden files
    Ls-r shows all the files under this directory, and also shows the files under all subdirectories

    2. CD Open Directory
    CD/Open root directory

    3. mkdir Create a new directory
    mkdir Temp

    RmDir Deleting a directory
    RmDir Temp

    4. RM Delete Directory
    RM-RF Temp

    5. MV Change the file name and directory name of the command
    MV old filename New file name
    MV Old directory name new directory name

    6. CP Copy files and directories command
    The CP command is used to copy a file into a new file,
    CP old filename New file name

    7. VI Editing software
    Now we execute VI loveletter. After entering, click on the keyboard Insert function key or I key can enter the editing state, you can insert characters,
    Then click Insert into the cover mode, the difference between the two modes is easy to reflect, you can try it. Up and down four arrow keys to move the cursor.
    There is no difference between basic editing commands and Windows. Isn't it easy? When you have entered the required content, we will save it,
    At this point, click the ESC key to return to command mode from edit mode, first enter a colon ":", that is, hold down the SHIFT key and then press the semicolon ";" So first enter a ":", then, enter W, return,
    You can save the contents of our edits to the Loveletter file. Now we can press insert to continue editing. Press ESC again, enter ":", and then press W to save.
    But now we don't need to save, we want to quit without saving, how to do it? When we enter w is the write meaning, save,
    Then we enter Q is quit quit the meaning. OK, input q, enter, vi hints we have just made the changes have not been saved,
    So remember! Once we need to discard our changes, we can not directly exit with the Q command, and we need to use "q!" Command. Input q!, OK, quit.
    We want to see if the Loveletter we just edited was really saved, and then VI Loveletter,ok, see? Now we want to exit directly,
    You can only enter ": Q" on it, do not enter that "!" Because we did not modify the contents of the file. If we revise this article, we can enter "Esc:wq" when we exit. You do not need to divide W and Q into two inputs.


    8. Cat View File contents
    Cat LoveLetter.txt
    If our text file is very long and a screen is not displayed, cat will not automatically page out. We can switch orders.
    More Loveletter
    The more command displays a text file, if there is too much content, it will automatically pause at the end of each page until the user presses the SPACEBAR to continue

    9. Halt reboot shutdown and restart command
    Halt reboot

    Find Files
    Find/-NAME/TEMP2

    One. Man command use Help
    Mans LS
    Man CP
    Man has its own command, usually composed of a single key, press the SPACEBAR and the F key to turn to the next page, press the B key to the previous page, press Q to exit the man, go back to the command line


    Three, Linux shutdown various shutdown command summary

    Linux if it is shutdown does not want Windows, especially the command interface. If you are using a virtual machine, we often shut it down with a virtual machine. It's a little cumbersome. A special find about Linux shutdown commands to share to everyone.

    Some common shutdown/Restart commands under Linux are shutdown, halt, reboot, and Init, all of which can be used to reboot the system, but each command has a different internal working process.

    Linux CentOS Restart Command:

    1, reboot
    2. shutdown-r now reboot (root user)
    3, Shutdown-r 10 over 10 minutes automatic restart (root user use)
    4, Shutdown-r 20:35 restart at 20:35 time (root user use)

    If you set the restart through the shutdown command, you can cancel the restart with the Shutdown-c command.

    Linux CentOS shutdown Command:

    1, halt immediately shut down the machine
    2, Poweroff immediately shut down the machine
    3, Shutdown-h now immediately shut down (root user use)
    4, shutdown-h 10 10 minutes after the automatic shutdown

    If you set the shutdown through the shutdown command, you can cancel the restart with the Shutdown-c command.

    Shutdown parameter Description:
    [-T] tell Init how long it will shut down before changing to another runlevel.
    [-R] Restart calculator.
    [-K] does not really shut down, just send a warning signal to each login (login).
    [-h] turn off the power (halt) after shutting down the machine.
    [-n] do not use init, but to shut down the machine. The use of this option is discouraged, and the consequences of this option are often not always what you expect it to be.
    [-c] Cancel current process cancels the shutdown program that is currently executing. So this option certainly does not have a time parameter, but you can enter a message to interpret, and this information will be sent to each user.
    [-f] ignores fsck when restarting the calculator (reboot).
    [-f] forces fsck to restart the calculator (reboot).
    [-time] Sets the time before the shutdown (shutdown).

    2.halt----The simplest shutdown command

    In fact, halt is called shutdown-h. When the halt executes, the application process is killed, the sync system is called, and the kernel is stopped after the file system write operation is complete.
    Parameter description:
    [-n] prevents the sync system from being called, it is used after patching the root partition with fsck to prevent the kernel from overwriting the patched super block with the old version of the Super Block (superblock).
    [-W] is not a real restart or shutdown, just write Wtmp(/var/log/wtmp) records.
    [-d] does not write wtmp record (included in option [-n]).
    [-f] does not invoke shutdown and forces shutdown or restart.
    [-i] before shutting down (or restarting), turn off all network interfaces.
    [-p] This option is the default option. is to call Poweroff when shutting down the machine.




This article is from the "7496608" blog, please be sure to keep this source http://7506608.blog.51cto.com/7496608/1812384

Linux basic commands

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.