Common Linux commands

Source: Internet
Author: User

Common Linux commands
Common commands

 
  1. Ls display file or directory
  2. -L list file DETAILS l (list)
  3. -A: List all files and directories in the current directory, including hidden a (all)
  4. Mkdir create directory
  5. -P: Creates a directory. If no parent directory exists, p (parent) is created)
  6. Cd switch directory
  7. Touch creates an empty file
  8. Echo creates a file with content.
  9. Cat View File Content
  10. Cp copy
  11. Move or rename music videos
  12. Rm delete file
  13. -R recursively deletes sub-directories and files.
  14. -F force Delete
  15. Find searches for a file in the file system
  16. Wc counts the number of rows, words, and characters in the text
  17. Grep searches for a string in a text file.
  18. Rmdir Delete empty directory
  19. Tree structure display directory, you need to install the tree package
  20. Pwd displays the current directory
  21. Ln create link file
  22. More and less display text file content by PAGE
  23. Head and tail show file header and tail content
  24. Ctrl + alt + F1 command line full screen mode
System Management commands
 
  1. Stat displays the details of the specified file, which is more detailed than ls.
  2. Who displays online login users
  3. Whoami displays the current user
  4. Hostname display Host Name
  5. Uname: displays system information
  6. Top dynamically displays the process information that currently consumes the most resources
  7. Ps displays the Instantaneous Process status ps-aux
  8. Du: view the directory size. du-h/home displays the directory information in units.
  9. Df view disk size df-h Displays disk information in units
  10. Ifconfig
  11. Ping test network connection
  12. Netstat displays network status information
  13. Man Command won't be used anymore. Looking for a man? For example, man ls
  14. Clear Screen
  15. Alias rename the command, for example, alias showmeit = "ps-aux", and unaliax showmeit
  16. Kill to kill a process. You can view the process id with the ps or top command, and then kill the process with the kill command.
Compress related commands
 
  1. gzip:
  2. bzip2:
  3. Tar: Package and Compression
  4. -C. archive file
  5. -X compressed file
  6. -Z gzip compressed file
  7. -J bzip2: compressed file
  8. -V shows the compression or decompression process v (view)
  9. -F indicates the file name.
Example:
 
  1. Tar-cvf/home/abc.tar/home/abc Package only, not compressed
  2. Package tar-zcvf/home/abc.tar.gz/home/abc and compress it with gzip
  3. Package tar-jcvf/home/abc.tar.bz2/home/abc and compress it with bzip2
If you want to decompress the package, replace "c" in the tar-cvf/tar-zcvf/tar-jcvf command with "x. Shut down/restart the machine
 
  1. shutdown
  2. -R: shutdown and restart
  3. -H Shutdown without restarting
  4. Now shut down immediately
  5. Halt Shutdown
  6. Reboot restart
The Linux pipeline uses the standard output of one command as the standard input of another command. That is, several commands are combined for use, and the result of the last command is exclusive to the previous one. For example, grep-r "close"/home/* | more searches for all files in the home directory, including close files, and outputs them by page. Linux software package management Dpkg (Debian Package) management tool. The Package name is suffixed with. deb. This method is suitable when the system cannot be connected to the Internet. For example, to install the installation package of the tree Command, first upload tree. deb to the Linux system. Run the following command to install the SDK.
 
 
  1. Sudo dpkg-I tree_1.5.3-1_i386.deb Installation Software
  2. Sudo dpkg-r tree uninstall software
Note: There are multiple methods to upload tree. deb to Linux. VMwareTool, using the mounting method; using the winSCP tool;APT (Advanced Packaging Tool) Advanced software tools. This method is suitable when the system can connect to the Internet. Tree is used as an example.
 
  
  1. Sudo apt-get install tree installation tree
  2. Sudo apt-get remove tree uninstall tree
  3. Sudo apt-get update Software
  4. sudo apt-get upgrade
Set.Convert the rpm file.Deb file. rpm is the software format used by RedHat. It cannot be used directly in Ubuntu, so you need to convert it.
 
    
  1. sudo alien abc.rpm
Vim uses vim three modes: Command mode, insert mode, and edit mode. Use ESC or I or: to switch the mode. In command mode:
 
    
  1. : Q exit
  2. : Q! Force exit
  3. : Wq save and exit
  4. : Set number: displays the row number.
  5. : Set nonumber hide row number
  6. /Apache finds in the document that apache jumps to the next one by pressing n, shift + n
  7. Copy and paste the row where the cursor is located.
  8. H (move one character to the left), j (next line), k (last line), l (move one character to the right →)
User and User Group Management
 
    
  1. /Etc/passwd storage User Account
  2. /Etc/group storage group account
  3. /Etc/shadow stores the password of the user account
  4. /Etc/gshadow: password used to store user group accounts
  5. Useradd Add User Name
  6. Userdel delete user name
  7. Adduser
  8. Groupadd add group name
  9. Groupdel Delete group name
  10. Passwd root SET Password for root
  11. su root
  12. su – root
  13. /Etc/profile system environment variable
  14. Bash_profile user environment variables
  15. . Bashrc user environment variable
  16. Su user switches users and loads the configuration file. bashrc
  17. Su-user: Switch the user, load the configuration file/etc/profile, and load the bash_profile
Users and user groups who change files
 
    
  1. sudo chown [-R] owner[:group] {File|Directory}
For example, jdk-7u21-linux-i586.tar.gz is used as an example. Belongs to the user hadoop. to switch the user and group to which this file belongs to the group hadoop. You can use commands.
 
    
  1. sudo chown root:root jdk-7u21-linux-i586.tar.gz
File Permission management three basic permissions R read value expressed as 4 W write value expressed as 2X executable numeric value 1. jdk-7u21-linux-i586.tar.gz File Permission is-rw-r -- rw-r-total 10 characters, it is divided into four sections. The first character "-" indicates a common file. The "l" link may appear at this location; "d" indicates the second, third, and fourth characters of the directory. "rw-" indicates the permissions of the current user. Therefore, the value is 4 + 2 = 6, the fifth, sixth, and seventh characters "rw-" to indicate the permissions of the current group. Therefore, the value is 4 + 2 = 6. The second character "r-" indicates other user permissions. So the value is 2. So the permission to operate this file is expressed as 662 in number? Change permission sudo chmod [u user g owner group o all users of another user a] [+ Add permission-revoke permission] [r w x] Directory Name example: there is a file filename, the permission is "-rw-r -- x", and the permission value is changed to "-rwxrw-r-x". The value is 765.
 
    
  1. sudo chmod u+x g+w o+r filename
The preceding example can be represented by numerical values.
 
    
  1. sudo chmod 765 filename
Some interesting commands used in work:
 
     
  1. linux nc
  2. tree

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.