Common Linux commands in Web development __arduino

Source: Internet
Author: User
1, ifconfig-ip View Management command
Put IP View management commands on the first introduction,
It is because you know the IP of the installed Linux system that you can learn and manage by remote SSH logon to the system.
Used to view the system's IP, you can enter: "Ifconfig" or "ifconfig-a", and then enter.
Note that it is not ipconfig under windows, but ifconfig.

Note: If it is CentOS, the default is not to add the/sbin path to the environment variable $path (see the value of this environment variable for the current user available command: Echo $PATH),
You can enter the absolute path of the command to execute it, namely: "/sbin/ifconfig".
The following other commands, etc.

2. Man command and--help parameter view command Help document
Before you go down, let's introduce a very useful command and parameter that you can use to view the Help documentation for the command.
If you want to see what detailed parameters are in the LS command, how to use it,
can enter: "ls--help" or "Man ls" and then enter,
The system prints out all the usage instructions associated with LS.
Almost all commands can use the--HELP parameter, or use the man command to see how they are used.

Note: When the man command looks at the help document for a command, the exit Help document enters the letter: "Q".

3, CD directory Switch command
As with the CD in Windows DOS commands, it is used to toggle the current directory.
Use such as:
After you log on to Linux, the default will be in the current user's directory, such as user name, then the absolute path of the directory is: "/home/user/";
If you want to switch to the/ETC directory, type the command: "Cd/etc" and then enter.

4, LS and LL (ls-l) Browse directories and file commands
Compared to the command dir under Windows, it is not difficult to understand its usage.
What needs to be explained is that there is no ll (two lowercase L) commands under Ubuntu, but it can be replaced with the Ls-l command.

5. Find Resource Lookup command
Find is equivalent to the file lookup feature opened by CTRL + F shortcuts in Windows.
If you want to find a file test.html the entire disk,
Input: "Find/-name test.html"
You can use wildcard characters in the file name you are looking for, such as: "Find/-name *.html"

6. sudo and Su use root account permission command
Typically, you don't use the root account in general,
Because it is the most privileged user of the Linux system, a slight carelessness may cause serious consequences.
Occasionally some operations need to temporarily use the permissions of the root account how to do it.
You can add sudo before the command, such as using the root account to open an Apache configuration file with vi: sudo vi/etc/httpd/conf/httpd.conf
The first time you use sudo prompts for the password for the current user, and then use sudo for a while before you need to enter the password again.

In addition to using sudo, you can use the User Switching command: Su to switch to the root account,
Enter the command: "su" or "su root", enter after the prompt input root account password, you can change to the root account.

7. passwd Password Modification command
In Ubuntu, when the system is first installed, there is usually no password to set the root account.
The first time you use the root account, you need to set a password for root.
Use command: "sudo passwd root", then enter,
The system prompts you to enter the new password for the root account two times and repeat it two times.
You can then login to the root account with the newly set password.

8, Apt-get and Yum Software installation, uninstall command
Just contact Linux or initial installed Linux system, it is inevitable to install some of the software you need.
One of the great charms of Linux is that most of the Open-source software you want to use,
Whether it's Ubuntu or CentOS, they've collected these open-source software together,
It also provides a software management tool to help users easily download, install, and configure software.
The tools provided by Ubuntu are Apt-get, and CentOS (Red hat) offers Yum.
This only describes how to use them to install a software,
If you install Apache2, enter the command: "sudo apt-get install apache2" or "sudo yum install the apache2"

9, service services start Stop management and PS Process view command
Linux systems also have the same concept of "services" as in Windows:
A software that automatically runs in the background after the system has been booted can be called a "service".
The commands for managing services in Linux are: "Service", which typically supports three parameters (start, stop, and restart): "Start", "Stop" and "restart".
If you restart the Apache2 service, enter: "sudo service apache2 restart"

Typically, "Ps-ef" is used to view all current processes;
If you need to filter the process name, add the grep command: "Ps-ef | grep http "

10. Chkconfig Service Management Command (non-system self-belt, need to be installed separately)
Service management here is not the same as the service startup, stop, and restart management above.
The service command above can be seen as the start, stop, and restart management of a software
Chkconfig is the management of the service itself, such as setting up a service to run automatically, or setting up a service that does not run, or even removes it from the service.
This tool can be installed by: sudo apt-get install chkconfig or yum install Chkconfig.
In CentOS, Apache2 is set to boot automatically: "Chkconfig--level 2345 httpd on"
Note: Apache2 's service name may not be apache2, but httpd.
Available commands: Chkconfig--list to view all services

11, Vim text Editing tool
VI (VIM) can be seen in Windows like the notebook software, it is a plain text editor, but its function is far more powerful than Notepad.
Because Vim is too powerful, here is only the basic usage:
Use it to open a file test.html, input: "Vi test.html",
The following argument can be either an absolute or a relative path to one or more files (see this article in more detail:).
In Vim, enter the letter: "I" into edit mode, I means insert;
Press Esc key in edit mode to exit edit mode;
The letters "H", "J", "K", "L", respectively, represent the cursor "left", "top", "bottom", "right" move;
Enter the colon character: ":", that is, the key: "Shift + semicolon;", enter command mode;
In the command mode input: "W" and then enter, that is, save the file;
In the command mode input: "x" and then enter, that is, save the file and exit vim;
In command mode input: "Q" then enter, or press SHIFT + Z + Q to save the file and exit vim;
Other commonly used operation, can check the relevant information of vim.


12, chmod file and directory Rights Management command
The permissions for files in Linux include reading, writing, and executing three kinds, respectively: "R", "W", "X";
If you add execute permissions to a script file test.sh, enter: "Chmod +x test.sh"
Where the plus sign "+" represents adding this permission, minus "-" means to remove this permission.
If you want to set the directory test and all of the files in it to anyone, read and execute it,
Then enter the command: "Chmod-r 777 Test"
Where the value of R is: 4, the value of Write W is: 2, the value of X is: 1.

13, CP, MV, RM file and directory copy, move (rename) and delete command
Copy file or directory command: CP, such as copy test.html for test2.html, input: "CP test.html test2.html";
Move file or directory commands: MV, such as mobile test.html to the previous level directory, input: "MV test.html. /”;
Delete file or directory commands: RM, such as delete file test.html, enter: "rm test.html";
If the above three actions are for the directory, you need the-R parameter.

14. SCP Remote Copy command
It is often used to copy a file from a Linux server to another server,
Using the SCP Remote replication command is very convenient and quick.
For example, a file test.html is copied to another IP-192.168.1.102 machine directory/usr/test directory,
You can enter: "SCP test.html root@192.168.1.102:/usr/test/", then return,
Press the prompt to enter 102 of the machine's root account password confirmation can be.

15, wget remote resource access, download command
If you download a file from the Web to this computer,
Can enter: "Wget http://www.qq.com/qq.exe", and then enter confirm,
It downloads the Qq.exe file to the current directory, named Qq.exe.

16, SSH remote login command
If you telnet to another machine from a Linux server via SSH,
This is typically used on multiple servers.
Because the server will often set up a firewall, the external network can not directly access a server,
To be accessible, you need to connect to a machine outside the firewall and then connect to the server inside the firewall.
If the root account is used to connect an IP-192.168.1.102 machine, enter: "SSH 192.168.1.102-l Root",
Enter the password of the root account after entering and confirm the return.
If the SSH port for this server is not the default 22 port and is a custom one such as 1234, you can add the argument-p after the command.
such as: "SSH 192.168.1.102-l root-p 1234"

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.