Beginner Linux has gone through many pits, which is recorded here
Throw the pot before writing: because it is a beginner, many technologies and understanding are not necessarily accurate. If anyone refers to the knowledge of this article, please forgive me for any deviation
Environment: Ubuntu 16.4.1 server
Brief introduction: Ubuntu is one of the many branches of the Linux kernel. In addition, there are CentOS, red hat, Debian, etc. my understanding is that Ubuntu belongs to the secondary development based on Debian The advantage of Ubuntu is that the foundation maintains and updates continuously, Moreover, it solves the cross reference dependency between software and software under Linux system (dependency: software a needs software B, C and D to work normally, so you need to install software B, C and d first when installing software a, and B, C and d need to install other software first to work, resulting in very complex software installation under Linux), You can directly use the apt get install XXX command to install a software. Ubuntu will help you download and install other dependent software required by the software
1. The difference between $sudo and root
Explanation of $: it means the command line. Beginners can often see the $symbol when they look at some materials without help,
When entering the reference code, enter $together. The meaning of $is to tell you that this is a command line, followed by the code,
For example, $sudo means that you enter sudo
Sudo is to enable * * temporary * * super permission for the current user
Sometimes installing software requires super permissions. When modifying some readonly files, you need to log in to the root account. Sudo is useless
Method 1
Yes, use the sudo command to turn on temporary permissions
For example, $sudo apt get install XXX // XXX: the software name of Ubuntu
Method 2
Exit the current login account and log in with the root account
1 - > $logout // exit the login command
2 - > enter the root account and password
Or switch directly to the root account
->$Su - root // completely switch to the root account (user environment variable changes)
->$Su root // only switch the permission to the root account (the user environment variable remains unchanged)
Root is the system super privilege account
This account is a full authority super user. After logging in, you can do whatever you want
Pit:
If the system has not set the root account password, this account is useless. You can use it only after setting the password with the following command
->$sudo passwd root // note that this is passwd, not password
//The author inputs the regular full spelling words many times, and then the infinite cycle fails all the time
//Linux has a lot of wonderful abbreviations. I stepped on them accidentally
//It's a pit
2. Use winscp to connect to Ubuntu via SSL
If SSH service is not installed in your version, you need to install it first
->$sudo apt get install SSH // you can also see openssh server when viewing the data
//SSH is short for this service
After downloading winscp, open it and click new session
Enter the account and password according to the prompt. The default port is 22
*A non root account can be used through an SSL connection
*The root account needs to do more
First, you need to set the root password. See the end of section 1
Then modify / etc / SSH / sshd_ Config configuration file
->$vi /etc/ssh/sshd_ Config // Note: sshd_ Config is not SSH_ config
//Linux is full of word pits
Find the permitrootlogin configuration property
Change the permitrootlogin line to permitrootlogin yes
An important step is to restart the sshd service
->$service sshd restart // note that sshd is not SSH
//Linx is full of word pits
After completing the above steps, you can use winscp to connect
! Some people inadvertently modified the default setting of winscp SFTP server, resulting in the problem of unable to link
Server sent command exit status 127.
Find the site login page, find advance, click on it, find SFTP on the left, and set it to default
3. Set global agent
Because Ubuntu is a virtual machine installed on windows (I use VMware, and my colleagues recommend VirtualBox, which is not easy to use)
The author's company does not allow access to some external networks, and the download image address of apt get is on the blacklist
Therefore, it can only be accessed through the proxy server set up by colleagues
Of course, there are many kinds of agent settings, including temporary agent, user agent (shell agent) and system global agent
//Linux is too flexible, but it is also too complicated. I really think Microsoft is very considerate for its loyalty to Microsoft
For the author's needs, only temporary agent and system global agent are available (similar to setting agent on IE)
[see article for other proxy settings]( http://blog.csdn.net/zm_21/article/details/8951005 )
Method 1: temporary agency
->$export http_proxy="http://x.x.x.x:port"
In addition to HTTP proxy, HTTPS, which is becoming more and more popular recently, also has the following commands
->$export https_proxy="http://x.x.x.x:port"
//The difference is only at http_ Change proxy to HTTPS_ proxy
Method 2: global agent
Log in with the root account in / etc / environment (system environment variable)
->$vi /etc/environment
Append the following configuration attributes
->http_proxy="http://x.x.x.x:port" //http
->https_proxy="http://x.x.x.x:port" //https
Update environment variables
->$source /etc/environment
4. Modify apt software download image source address
Apt get is actually the software market, because apt get relies on software for long-term maintenance and update
It is much easier to help Ubuntu install software, but the default image source of Ubuntu in en English language is from the United States
You can use $cat / etc / apt get / source List view
Therefore, the download speed is slow. At this time, you need to find a fast source. Apt get defines the image source address in
/etc/apt-get/source. List file, I don't know much about the explanation of various codes in the source
Looking for fast sources can be found on this website( https://repogen.simplylinux.ch/ )
Check all the options you need. It is recommended to check all of them
?: Lazy checkbox select all codes
var boxs=document.getElementsByTagName("input");
for(i=0;i<boxs.length;i++){
boxs[i].checked=true;
}
Press enter on the browser console
The generate button is the generate list button at the bottom of the page. Click it to copy all the generated image source addresses to the
source. List file (it's better to overwrite the original settings. Keeping the original settings may lead to conflicts)
More apt command References:
http://blog.csdn.net/heihuifeng/article/details/6610899
5. Install and delete JDK through PPA
**Installation**
PPA is not apt, but additional software. When using the PPA command, install the PPA dependent software first
The following commands are required to install PPA
->$sudo apt-get install software-properties-common
->$sudo apt-get install python-software-properties
//After the installation of the above two software, you can start to install JDK
->$sudo add apt repository PPA: webupd8team / Java // add configuration
->$sudo apt get update // update the configuration. This step is very important
->$sudo apt get install oracle-java6-installer // install 1.6
->$sudo apt get install oracle-java7-installer // install 1.7
->$sudo apt get install oracle-java8-installer // install 1.8
Configure Java_ HOME
->$sudo VI / etc / environment // open the system environment variable
Add the following code
JAVA_HOME="/usr/lib/jvm/java-7-oracle"
Update environment variables
->$source /etc/environment
Check whether the configuration is correct
->$echo $JAVA_ Home // should be the same as the appended path
Finally, you can view the JDK version
->$java -version
**Unload**
Run the uninstall command first
->$sudo apt autoremove oracle-java7-installer
->$apt-cache search java | awk '{print($1)}' | grep -E -e '^(ia32-)?(sun|Oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e 'java-common' | xargs sudo apt-get -y remove
->$apt-get -y autoremove
Then clear the cache and configuration
->$dpkg -l | grep ^rc | awk '{print($2)}' | xargs sudo apt-get -y purge
->$bash -c 'ls -d /home/*/.java' | xargs sudo rm -rf
->$rm -rf /usr/lib/jvm/*
Installation reference tutorial:
https://segmentfault.com/a/1190000001703180 (relatively complete)
http://www.cnblogs.com/a2211009/p/4265225.html (various ways)
Uninstall reference documents:
http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
6. Install JRE and delete JRE through apt
Pit: because source The source address in the list is incomplete, resulting in the following prompt errors for various dependent references during installation
The following packages have unmet dependencies:
Depends: xxxx(xxxx) but it is not going to be installed
Unable to correct problems, you have held broken packages.
The solution is to modify the image source address with reference to section 4 to make the dependency relationship between the software
The JRE can be installed directly using the following command
->$sudo apt-get install openjdk-7-jre
The author installs openjdk-7-jre here, which can be used by readers
->$sudo apt cache search software name
To find more other versions of JRE, such as default JRE
have access to
->$sudo update-alternatives --config java
Quickly find all Java versions and switching versions installed on the machine (press the corresponding number according to the prompt)
use
->$java -version
View current version
Configure JRE_ HOME
->$sudo VI / etc / environment // open the system environment variable
Add the following code
JRE_ Home = "/ usr / lib / JVM / java-7-openjdk-i386 / JRE" // this path is consistent with your current java version path
//笔者use的是openjdk-7-jre
//Note that the end path here is the JRE folder
Update environment variables
->$source /etc/environment
Check whether the configuration is correct
->$echo $JRE_ Home // should be the same as the appended path
**Unload**
Run the uninstall command first
->$sudo apt autoremove openjdk-7-jre
->$apt-cache search java | awk '{print($1)}' | grep -E -e '^(ia32-)?(sun|Oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e 'java-common' | xargs sudo apt-get -y remove
->$apt-get -y autoremove
Then clear the cache and configuration
->$dpkg -l | grep ^rc | awk '{print($2)}' | xargs sudo apt-get -y purge
->$bash -c 'ls -d /home/*/.java' | xargs sudo rm -rf
->$rm -rf /usr/lib/jvm/*
A complete tutorial is recommended for sections 5 and 6
https://www.digitalocean.com/…
7. Apache2 + Tomcat8