Summary of Linux commands and shortcut keys

Source: Internet
Author: User
Tags clear screen

  • Log in to the Linux system after entering the password, you want to delete ctrl+u Delete all the input before, (is uppercase U)
  • IP a view IP (full ifconfig addr)
  • Systemctl Restart Networkmanager.service Start command
  • Dhclient dynamic acquisition of IP addresses
  • Control+o (ctrl+o) Sign Out
  • Control+l (ctrl+l) Clear screen can also use the command clear
  • Device class information is in the/dev directory
  • Top View memory Information
  • Who view all current online users
  • WhoAmI See who you are uname-r view kernel version number
    -A View all version information

  • Systemctl Stop/start firewalld.service Stop/start firewall
  • Systemctl enable/disable firewalld.service Allow/disable firewall boot
  • CD-Only Transfer home directory
    Cd. Switch to current directory
    Cd.. Switch to the previous level directory
    Cd.. /.. Switch to the top level two directory
    Cd.. /.. /.. Switch to the top level three directory
    。。。。。。
    cd– switch to the most recently switched directory
  • Su-username Switching users
  • PWD Displays the directory where you are currently
  • cd/etc/yum.repo.d/. repo file storage for this folder is the Yum source address;
    cd/etc/yum.repos.d/Modify or create a new. Repo file within a folder, specify the following
    [Base] Casual
    Name=lk Casual
    Baseurl=file:///lk a new directory of your own designation
    Enabled=1 enabled
    Gpgcheck=0
  • Install package: Take Lsb_release as an example yum Whatprovides lsb_release takes the Lsb_release toolkit name from the version number, and then installs: Yum Install lsb_release_xx Installation Kit, Enter the toolkit name instead of the name of the command; Use Lsb_release to view operating system information after successful installation;
  • DirName Gets the directory name removes the file name (not the directory part) from the given file name that contains the absolute path, and then returns the remaining path (directory part)
    Input: Dirname/etc/sysconfig/network-scripts/ifcfg-eth0
    /etc/sysconfig/networt-scripts
    Output:/etc/sysconfig/network-scripts/
    /etc/sysconfig/

  • BaseName gets the base name from the file name of the Godin containing the absolute path to the left part of the directory, or the colleague removes the content of a suffix (the directory part), and then returns the remainder (not part of the directory)
  • MV Move or rename file
  • CP Copy or rename file
  • Mount CD mount/dev/cdrom/New directory mount the optical drive file to the new directory specified
    23.tty is also teletypewriter. You can see which endpoints are connected PTS/1 ... pts is a pseudo-terminal
    can also be considered as a virtual terminal, Linux generally default to 6, tty1-7, respectively, corresponding to Alt-f1/f6, starting from F7, F7-F12 is a graphics terminal, you can open multiple characters or graphics terminal at the same time without affecting each other
    24.echo Echo, that is, display Eg:echo $SHELL display the current SHELL
    25.cat/etc/shells display all variables used by the system
    Cat command: View the file, which means showing how many shell types the system supports by default
    26. User prompt, take [[email protected] ~]# as an example
    [[: Normal identifier
    \u Root: User currently in use
    @ @: normal identifier
    \h localhost: host name
    \w ~: Current working directory (not full current directory, abbreviated)
    ]]: normal identifier
    \$ #: User ID (Root is #, normal user is $)
    27.30.[[email protected] ~]# echo $PS 1
    [\[email protected]\h \w]\$ are both escape characters, in the shell's PS1 environment variable definition, no longer represents a simple combination of slash letters, is an escape character

      export PS1=‘[\[email protected]\h \W]\$‘   更改’’的内容可以更改用户提示符

    Export command: Set environment variables for the current system
    The default modification does not take effect and needs to be written to the. BASHRC variable.

        vi .bashrc    export PS1=‘\[\e[1;35m\][\[\e[1;33m\]\[email protected]\h \[\e[1;31m\]\w\[\e[1;35m\]]\[\e[1;36m\]\$‘     改变账号颜色    PS1=‘\e[31m[\[email protected]\h \W]\$ \e[0m‘    \e \033\u 当前用户    \h 主机名简称\H 主机名    \w 当前工作目录\W 当前工作目录基名    \t 24小时时间格式\T 12小时时间格式    \! 命令历史数\# 开机后命令历史数
  • A 28.type command that displays the type of the specified command, judging whether the specified command is an internal command or an external command;
    29.which command: The directory where the execution program of the command is often seen;-a view all paths containing the command;
    30.date Display system time;
    Hwclock Display hardware time,-W to the system time calibration,-s to the hardware time is quasi-calibration;
    Cal displays the current calendar; y Displays the calendar for one year;
    file format for viewing files;
    chmod +x filename To execute permissions on the file;
    U+r to master Read permission
    G+w Write permission to the genus Group
    A+x to perform permissions on other users
    Du-sh./View the total file size of the directory
    Info is also information for finding commands, but it's too informative to use man for info
    Example: Man bash, man ls

      echo $PS 1à[\[email protected]\h \w]\$ enable command option-E, if the following character appears in the string, it is handled in particular, not as a general text output ECHO-E ' aaa\n ' \a warns \b Backspace bar \c finally does not add newline symbol \ n newline and the cursor moves to the beginning of the line \ r Enter, that is, the cursor moves to the beginning of the line, but does not wrap \ t insert tab \ \ insert \ character \0nnn insert nnn (octal) The ASCII character represented by Echo-e "\033[43;31mred color\033[0m" \xhh inserted in HH (hexadecimal) represented by the ASCII word export $SP 1= "[\[email protected ]\h \w]\$ Change the escape character to change the style of the command prompt PS1 set the character color in the format: ps1= ' \e[31m[\[email protected]\h \w]\$ \e[0m ' F B 30 4    0 Black 31 41 Red 32 42 green 43xxx34 44 Blue 35 45 purplish red 36 46 Cyan Blue 37 47 white vim ~/.BASHRC source ~/.BASHRC Reload will be permanently saved or reopen the shell will restore or. ~/.BASHRC points can also be used instead of source  

    31. Folder function functions:
    /boot: Boot file directory, kernel file (vmlinuz), boot loader (bootloader,grub) are stored in this directory;
    /bin: Basic command for all users, can not be associated to a separate partition, OS boot will be used by the program;
    /sbin: The basic command of the management class, cannot be associated to the independent partition, the OS starts the program which will use;
    /lib: Basic shared library files and kernel module files that the program relies on at startup;
    /LIB64: storage location for secondary shared library files dedicated to x86_64 systems
    /etc: Configuration file directory;
    /home/username: Home directory for ordinary users;
    /root: Administrator's home directory;
    /media: Portable mobile device mount point;
    /MNT: Temporary file mount point;
    /dev: Device files and special file storage locations;
    /OPT: The installation location of the third-party application;
    /SRV: Data used by services running on the system;
    /tmp: Historical file storage location;

    32. File system different file colors:

      • White Plain file (plain executable file)
        L Light Green Connection file (similar to Windows shortcut)
        D Blue Catalog File
        P Dark xxx Pipe file (related to redirection)
        Bxxx Block Execution file
        Cxxx Character device files
        s pink socket (socket) file (IP found host, port found program, IP and port number)
        Green: Executable file
        Red: Compress files
        Vi/etc/dir_colors changing the file type color

    Summary of Linux commands and shortcut keys

    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.