Common operations commands in Linux

Source: Internet
Author: User

Common directives

    • LS: Show file or directory
      • -I: List file details (list)
      • -A: Lists all files and directories in the current directory, including hidden files and folders (a)
    • mkdir: Creating a Directory
      • -P: Create directory, if no parent directory is created (parent)
    • CD: Switch directories
    • Touch: Create an empty file
    • Echo: Create a file with content
    • Cat: View File contents
    • CP: Copy
    • MV: Move or rename
    • RM: Deleting files
      • -R: Recursive Delete, can delete non-empty directory and file
      • -F: Force delete
    • Find: Search for a file in the file system
    • WC: Statistics text line number, word count, number of characters
    • grep: Finding a string in a text file
    • RmDir: Delete Empty directory
    • Trees: Tree-structured reality directory, need to install tree package
    • PWD: Show current directory
    • LN: Creating a linked file
    • More, Less: Paging Reality text file content
    • Head, Tail: Real file header, tail content
    • CTRL+ALT+F1: Command line full-screen mode

System Management Directives

    • Stat: Displays detailed information about the development file, more detailed than LS
    • Who: Show online login
    • WHOAMI: Show current Operation user
    • Hostname: Real host name
    • Uname: Real System Information
    • Top: Dynamic display of currently consuming resources up to process information
    • PS: Show transient process status
      • -aux: Show All information
    • Du: View directory size
      • -H: Directory information with units displayed
    • DF: View disk size
      • -H: Disk information with unit display
    • Ifconfig: Viewing network conditions
    • Ping: Test network connectivity
    • Netstat: real-world Network status information
    • Man: View commands in detail
    • Clear: Clears the screen
    • Kill: End process, with PS or top instruction to see the process ID

Packaging compression Related instructions

    • Gzip
    • Bzip2
    • Tar: Packaging compression
      • -C: Archive file
      • -X: Compressing files
      • -z:gzip Compressed Files
      • -J:BZIP2 Compressed Files
      • -V: Show compression or decompression process
      • -F: Using file name

For example:

TAR-CVF/HOME/ABC.TAR/HOME/ABC only package does not compress

TAR-ZCVF/HOME/ABC.TAR.GZ/HOME/ABC packaging, and using gzip compression

TAR-JCVF/HOME/ABC.TAR.BZ2/HOME/ABC packaged and compressed with bzip2

If you want to decompress, the-c parameter of the direct Graph Huanhuan command is the-x parameter.

Shutdown/Restart Machine instructions

    • Shutdown
      • -R: Shutdown restart
      • -H: Shutdown does not restart
      • Now: Turn off the machine immediately
    • Halt: Shut down the machine
    • Reboot: Restart

Linux pipeline Directive

Use the standard output of one command as the standard input for another command.

Example: Grep-r "Close"/home/* | More in the home directory all files to find all the files including "close" and paging output

Linux Package Management

dpkg(Debian package) management tools, packages to. Debi for the rear mouth. This approach is suitable for systems that are not networked.

For example, install the tree command installation package and upload the Tree.deb to Linux first. Then install it using the command below.

sudo dpkg-i tree_1.5.3-1_i386.deb installation software

sudo dpkg-r tree Uninstall software

Note: There are several ways to upload tree.deb to a Linux system.

APTAdvanced Packaging tool. This method is suitable for the system to connect with the network.

Still take tree as an example

sudo apt-get install tree

sudo apt-get remove tree unload tree

sudo apt-get update updates the software source

sudo apt-get upgrade

Convert. rpm files to. deb files

. RPM is the software format used by Redhat. cannot be used directly under Ubuntu, so you need to convert it.

sudo alien abc.rpm

Vim use

Vim three modes: Command mode, insert mode, edit mode. Use ESC or "I" or ":" to toggle the mode.

Command mode:

    • : Q: Exit
    • : q!: Forced exit
    • : Wq: Save and exit
    • : Set Number: Displays line numbers
    • : Set Nonumber: Hide line number
    • /apache: Find "Apache" in the document, press N to jump to the next, Shift+n jump to the previous
    • YYP: Copy the line where the cursor is located and paste
    • H (move left one character ←), J (Next line ↓), K (Previous line ↑), L (move right one character →)

User and User group management

    • /ETC/PASSWD: Storing user accounts
    • /etc/group: Storage Group account
    • /etc/shadow: Store password for user account
    • /etc/gshadow: Store password for user group account
    • Useradd User Name
    • Userdel User Name
    • AddUser User Name
    • Groupadd Group Name
    • Groupdel Group Name
    • passwd root: Set a password for root
    • Su Root
    • Su-root
    • /etc/profile: System Environment variables
    • Bash_profile: User Environment variables
    • . BASHRC: User Environment variables
    • SU User: Switch user, load configuration file. bashrc
    • Su-user: Switch user, load configuration file/etc/profile, load Bash_profile

User and user groups for changing files

sudo chown [-R] owner [: Group] {file| Directory}

For example, take jdk-7u21-linux-i586.tar.gz as an example. belongs to user Hadoop, group Hadoop. To switch the users and groups to which this file belongs, you can use the command

sudo chown root:root jdk-7u21-linux-i586.tar.gz

File Rights Management

Three basic permissions

    • R: Read, numeric representation is 4
    • W: Write, value represented as 2
    • X: Executable with numeric representation of 1

Assume that the permissions for the jdk-7u21-linux-i586.tar.gz file are-rw-rw-r--

-rw-rw-r--altogether 10 characters, divided into four segments.

The first character "-" indicates a normal file, and the "L" link may also appear in this location; "D" means the directory

The No. 234 character "rw-" represents the permissions of the currently owned user. represented as 4+2=6 by numerical value

The No. 567 character "rw-" represents the permissions for the group that is currently owned. represented as 4+2=6 by numerical value

The No. 890 character "r--" represents other user rights. Represented by a value of 2

So the permission to manipulate this file is represented by a value of 662

Change permissions

sudo chmod [u belongs to user g belongs to group O Other User a All users] [+ Increase permissions-reduce permissions] [r W x] directory name

For example: There is a file filename, the permission is "-rw-r----x", the permission value is changed to "-rwxrw-r-x", with a numeric representation of 765

sudo chmod u+x g+w o+r filename

Can also be expressed as a value of

sudo chmod 765 filename

Common operations commands in Linux

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.