Common Linux commands for project deployment, configuration, and troubleshooting

Source: Internet
Author: User
Tags gz file

Common Linux commands for project deployment, configuration, and troubleshooting
I. Common commands

Ls display file or directory
-L list file DETAILS l (list)
-A: List all files and directories in the current directory, including hidden a (all)
Ll will list all the file information under the file, including the detailed information of the hidden file. The same effect can be achieved by using ls-l-.
Mkdir create directory
-P: Creates a directory. If no parent directory exists, p (parent) is created)
Cd switch directory
Touch creates an empty file
Cat View File Content
More and less display the text file content by PAGE (unlike cat, cat displays all content)
Cp copy
Move or rename music videos
Rm deletes a file or directory
-R recursively deletes sub-directories and files. If you delete a directory, the-r parameter is required.
-F force Delete
Rmdir Delete empty directory
Find searches for a file in the file system
Wc counts the number of rows, words, and characters in the text
Grep searches for a string in a text file (such as grep "jdk" serclasspath. sh, where jdk is the string to be queried and found in serclasspath. sh)
-E: the string to be searched for can be a regular expression.
Pwd displays the current directory
Head: Show file header content
Tail displays the content at the end of the file (when the file content changes, it will be dynamically printed and often used to view logs)
-Number f: displays the set row at the end.

Ii. system management commands

Stat displays the details of the specified file, which is more detailed than ls.
Who displays online login users
Whoami displays the current user
Hostname display Host Name
Uname: displays system information
Top dynamically displays the process information that currently consumes the most resources
Ps displays the Instantaneous Process status ps-aux
Du: view the directory size. du-h/home displays the directory information in units.
Df view disk size df-h Displays disk information in units
Ifconfig
Ping test network connection
Netstat displays network status information
Man HELP command and Syntax: man [command or configuration file]
Clear Screen
Alias rename the command, for example, alias showmeit = "ps-aux", and unaliax showmeit
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.

Iii. Compress related commands

Gzip:
Bzip2:
Tar: Package and Compression
-C. archive file
-X compressed file
-Z gzip compressed file
-J bzip2: compressed file
-V shows the compression or decompression process v (view)
-F indicates the file name.
Example:
Tar-cvf/home/abc.tar/home/abc Package only, not compressed
Package tar-zcvf/home/abc.tar.gz/home/abc and compress it with gzip
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 ".

4. Shut down/restart the machine

Shutdown
-R: shutdown and restart
-H Shutdown without restarting
Now shut down immediately
Halt Shutdown
Reboot restart

V. Linux Pipelines

Use 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, we want to view tomcat-related process information: ps-ef | gref tomcat

Vi. 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.
Sudo dpkg-I tree_1.5.3-1_i386.deb Installation Software
Sudo dpkg-r tree uninstall software

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.
Sudo apt-get install tree installation tree
Sudo apt-get remove tree uninstall tree
Sudo apt-get update Software
Sudo apt-get upgrade

Convert the. rpm file to the. deb file.
. Rpm is the software format used by RedHat. It cannot be used directly in Ubuntu, so you need to convert it.
Sudo alien abc. rpm

VII. Use vim

Vim mode: Command mode, insert mode, and edit mode. Use ESC or I or: to switch the mode.
In command mode:
: Q exit
: Q! Force exit
: Wq save and exit
: Set number: displays the row number.
: Set nonumber hide row number
/Apache finds in the document that apache jumps to the next one by pressing n, shift + n
Copy and paste the row where the cursor is located.
H (move one character to the left), j (next line), k (last line), l (move one character to the right →)
For more vim commands, visit the blog:
Linux File Editing Command details: http://blog.csdn.net/u013142781/article/details/50735470

VIII. User and User Group Management

/Etc/passwd storage User Account
/Etc/group storage group account
/Etc/shadow stores the password of the user account
/Etc/gshadow: password used to store user group accounts
Useradd Username
Userdel Username
Adduser User Name
Groupadd group name
Groupdel group name
Passwd root SET Password for root
Su root
Su-root
/Etc/profile system environment variable
Bash_profile user environment variables
. Bashrc user environment variable
Su user switches users and loads the configuration file. bashrc
Su-user: Switch the user, load the configuration file/etc/profile, and load the bash_profile

9. Users and user groups who change files

Sudo chown [-R] owner [: group] {File | Directory}
For example, jdk-7u21-linux-i586.tar.gz is used as an example. Belong to user hadoop, group hadoop
To switch the user and group to which the file belongs. You can use commands.
Sudo chown root: root jdk-7u21-linux-i586.tar.gz

10. File Permission Management

Three basic Permissions
The R read value is 4.
W write value is expressed as 2
X executable value is 1

The permission for the jdk-7u21-linux-i586.tar.gz file is-rw-r-
-Rw-r-a total of 10 characters, divided into four segments.
The first character "-" indicates a common file. This location may contain "l" links, and "d" indicates a directory.
The second, third, and fourth characters "rw-" indicate the permissions of the current user. Therefore, the value is 4 + 2 = 6.
The fifth, sixth, and seventh characters "rw-" indicate the permissions of the current group. Therefore, the value is 4 + 2 = 6.
The 80 or 90 character "r-" indicates other user permissions. So the value is 2.
Therefore, the permission to operate this file is expressed as 662 in numerical values.

11. Change permissions

Sudo chmod [u user g owner group o other user a all users] [+ add permissions-Reduce permissions] [r w x] Directory Name
For example, if you have a file filename with the "-rw-r -- x" permission, change the permission value to "-rwxrw-r-x" and use the value 765
Sudo chmod u + x g + w o + r filename
The preceding example can be represented by numerical values.
Sudo chmod 765 filename

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.