Common Linux commands

Source: Internet
Author: User

Common Linux commands

System Basics

  • Use the environment variable of the root user to switch to the root usersu -
  • Show current working pathpwd
  • Display the default language and keyboard layout of the current systemlocalectl
  • Display All languages supported in the systemlocalectl list-locales
  • Set the default system language to Chinese.localectl set-locale LANG=zh_CN.gb2312
  • Restart the machinereboot
  • Shutdownpoweroff
  • Exit the Current shelllogout/exit

Command help

  • command --help
  • man command
  • info command
  • List brief usage information of commands (when usingwhatisWhen an error is reported, runmandbCommand to generate an index file)whatis command

Routine commands

  • Display or change datedate
  • Show Calendarcal
  • Count the number of lines or characters of text and other related informationwc
  • Find the absolute path of the commandwhich
  • List the number of recently used commands (rehl saves 1000 by default)history number
  • The first 10 lines of text are displayed by default. to display more lines, you can add or subtract numbers.head [+- number]
  • The last 10 lines of text are displayed by default. to display more lines, you can add or subtract numbers.tail [+- number]
  • Display text content from top to bottomcat
  • Display text content from bottom uptac
  • Switch the working pathcd
  • Show directory contentls
  • When copying a file or directory, add-rOption indicates recursive Replicationcp
  • Rename/move a file or directorymv
  • Delete a file or directory. When deleting a directory, add-rOption indicates recursion, plus-fOption indicates force deletion and no reminderrm
  • Create directory, recursively create and add-pOptionmkdir
  • Create an empty file or update the timestamptouch
  • List Directory treestree
  • File Verificationsha1sum sha224sum sha256sum sha384sum sha512sum
  • Verify Filemd5Valuemd5sum
  • View text content on screenless

Users, groups, and permissions

  • Print user identity informationid
  • ChangeuserUser Passwordpasswd user
  • Add Useruseradd
  • Change User Information (uid, gid, and groups)usermod
  • Delete a useruserdel
  • Add Groupgroupadd
  • Delete Groupgroupdel
  • Change User Permissions, groups, and IDschange
  • Change the user and group of the file to student.chown student.student file
  • Change the group to which the file belongschgrp
  • Change File Permissionschmod
  • Mask mode changeumask

Network Configuration

  • Miscellaneous
    Files related to network configuration are stored in/etc/sysconfig/network-scripts/ifcfg-*/etc/hosts # static IP address to the name resolution file/etc/hostname # host name configuration file Interface Name rule ethx # Ethernet interface wlanx # wireless network interface pppxx # PPPOE dialing Interface
  • VIEdit the configuration file to configure the network
    Configure static IPv4 addresses (vi manually edit the configuration file) cat/etc/sysconfig/network-scripts/ifcfg-DEVICE = # enter the physical Nic name BOOTPROTO = none # Address Allocation type {dhcp | none | static} IPADDR = 1.2.3.4 # IPv4 address PREFIX = 24 # NetmaskGATEWAY = 1.2.3.254 # GWDNS1 = 1.2.3.254DNS2 = 1.2.3.253ONBOOT = yes # configure whether this interface is enabled at startup # systemctl restart network configure dynamic IPv4 addresses (vi manually edits the configuration file) cat/etc/sysconfig/network-scripts/ifcfg-DEVICE = # enter the physical Nic name BOOTPROTO = dhcp # Address Allocation type {dhcp | none | static} ONBOOT = yes # configure this whether the interface is enabled at startup # systemctl restart network configure DNS Client # cat/etc/resolv. confsearch redhat.com # search domain nameserver 1.2.3.4nameserver 4.3.2.1 configure the static IP address to the resolution list of the name. When no DNS server exists in the Intranet, you can edit the hosts file to resolve the IP address to the name # cat/etc/hosts10.1.1.1 server1 server1.example. com10.1.1.2 server2 server2.example.com change host name # cat/etc/hostnameserver.example.com

Decompression Problems

  • Tar
    • cCreate
    • tList
    • xExtract
    • fFile Name
    • CDecompress the package to the specified directory.
    • zUsegzipCompression
    • jUsebzip2Compression
    • JUsexzCompress
  • Packagetar cvf filename.tar /path
  • Package and compress it into gzip formattar czvf filename.tar.gz /path
  • Decompress the package to the specified folder.tar xvf filename.tar /path
  • View the compressed Package content but do not understand the pressuretar tvf filename.tar

Software Package Management

  • yumCommon commands
    Yum install a B c d # install software package a B c d (with the-y option added, you can leave the prompt "continue" when installing the software package) yum remove a B c d # uninstall software package a B c dyum groups list # view installed software groups and available software groups yum groups install "Infiniband Support" # install software group yum groups remove "Infiniband Support" # uninstall the software group yum info a B c # view information about the software package a B c d, such as size and version... yum update a B c d # update the software package a B c dyum update # update the yum provides file or directory of all the software packages that can be updated as a whole # Check which rpm package provides the yum search tree for the file # search for a tree package yum history # view the yum running history from the Repository
  • rpmCommon commands
    Rpm-qa # query all RPM packages installed on the local machine rpm-qa -- last # query all RPM packages installed on the local machine in chronological order rpm-qf files or directories # Check which rpm files are installed on the local machine the rpm-Va package name provided by the package # verify the integrity of the RPM package, you can also leave it empty, verify the RPM-qd package name of all rpm packages # Check which RPM-ql package names are attached to the rpm package # Check which files are released by the RPM package under which rpm-qc package name # view the RPM-e package name in the configuration file attached to the rpm package # uninstall the RPM package, multiple packages are separated by spaces. rpm-e package name -- nodeps # The dependency between RPM packages is not checked, directly uninstall the RPM-ivh package name # install one or more rpm-Uvh Package Names # upgrade one or more RPM packages

File System Problems

  • Device File naming rules
    Naming rules for device files in Linux/dev/sda # The first serial Hard Disk/dev/hda # The first parallel hard disk/dev/vda # The first virtio Driver Based on KVM one Virtual Disk/dev/xvda # Virtual Disk/dev/cdrom # CD/DVD Device Based on Xen virtualization technology, this file is usually linked to/dev/sr0, that is, the first CD/DVD device, and the second optical drive device, that is,/dev/sr1, and so on/dev/vgname/lvname # logical volume Disk/dev/sda1 # The first partition of the first serial Hard Disk/dev/hda1 # Remarks on the first partition of the first parallel hard disk: when there are more than 24 disks in Linux, for example, from/dev/sda>/dev/sdz, the redundant disks will continue with/dev/sdaa, /dev/sdab df # display file system usage du # Count file size mount # mount a partition to a directory, or display the mounting status

File Search

  • RunupdatedbCreate an index database and then executelocate filename
  • findSearch
    Find/-name ccie # traverse all subdirectories from/partition, and find/-type d-name ccie # traverse all subdirectories from/partition according to the file name, then, only find/-size 10 M in the directory named ccie # traverse all subdirectories from/partition, find/-perm 0755 # retrieve all subdirectories from/partition, find the file with the permission of 0755 and find/-user student # traverse all subdirectories from/partition, and then find the file of student.

Services and processes

  • Inrehl7Used insystemctlTo manage
    Systemctl-t help # list all the unit types systemctl -- type "unit" # view the status of the specified unit type systemctl -- failed # view information about all failed units loaded systemctl status cups. service # view the status of the cups service unit systemctl start cups. service # Start the cups service unit systemctl stop cups. service # Stop the systemctl restart cups service unit. service # restart the systemctl enable cups service unit. service # configure the cups service unit to automatically start systemctl disable cups upon startup. service # configure the cups service unit to boot without starting systemctl reload cups. service # reload the configuration file systemctl is-active cups of the cups service unit. service # Check whether the cups service unit is currently running systemctl is-enabled cups. service # Check whether the cups service unit automatically runs systemctl mask NetworkManager when it is started. service # completely shield the systemctl unmask NetworkManager of the NM service Unit. service # unblocking NM service Units

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.