tags: Linux


System environment

We know that Windows is great for its graphical interface, and Linux is not that GUI friendly… In fact, we in Windows graphical interface operations are installed into the command way!

Of course, if we use the GRAPHICAL interface in The Ubuntu system, it is also converted into commands. In order to better improve the performance, we basically use commands in the Linux system to operate, so we have to learn the common commands of Linux

Linux provides six command channels and one GUI channel by default. The GUI channel is entered by default

  • Command interaction mode switch: CTRL + Alt + F1 -- F6Copy the code
  • Graphical interface CTRL + Alt + F7Copy the code

Graphical interface interaction mode

  • Terminal: the command terminal of the GRAPHICAL user interface (GUI). It is an extension of the GUI interaction channel and depends on the GUI

This is what it looks like when you enter a terminal. In fact, the command terminal in our Linux graphical interface is similar to the console in Windows

The Windows Console is this:

The meaning of a command prompt

fucheng@ubuntu:~$what does this sentence mean??

  • Fucheng: user name
  • Ubuntu: indicates the host name
  • ~ : indicates the path. If the current path is the root directory where the user stores data, ~ is displayed
  • Represents ordinary users. # represents superusers

Permission to view files

We can view the details of the files in this directory by using the following command:

ls -la

Copy the code

Here’s what we got:


total 100
drwxr-xr-x 15 fucheng fucheng 4096 Aug  1 23:18 .
drwxr-xr-x  3 root    root    4096 Aug  1 23:08 ..
-rw-r--r--  1 fucheng fucheng  220 Aug  1 23:08 .bash_logout
-rw-r--r--  1 fucheng fucheng 3637 Aug  1 23:08 .bashrc
drwx------ 20 fucheng fucheng 4096 Aug  1 23:31 .cache
drwx------ 15 fucheng fucheng 4096 Aug  1 23:18 .config
drwxr-xr-x  3 fucheng fucheng 4096 Aug  1 23:19 Desktop
-rw-r--r--  1 fucheng fucheng   25 Aug  1 23:11 .dmrc
drwxr-xr-x  2 fucheng fucheng 4096 Aug  1 23:11 Documents
drwxr-xr-x  2 fucheng fucheng 4096 Aug  1 23:11 Downloads
-rw-r--r--  1 fucheng fucheng 8980 Aug  1 23:08 examples.desktop
drwx------  3 fucheng fucheng 4096 Aug  1 23:12 .gconf
-rw-------  1 fucheng fucheng  318 Aug  1 23:11 .ICEauthority
drwx------  3 fucheng fucheng 4096 Aug  1 23:11 .local
drwx------  4 fucheng fucheng 4096 Aug  1 23:18 .mozilla
drwxr-xr-x  2 fucheng fucheng 4096 Aug  1 23:11 Music
drwxr-xr-x  2 fucheng fucheng 4096 Aug  1 23:11 Pictures
-rw-r--r--  1 fucheng fucheng  675 Aug  1 23:08 .profile
drwxr-xr-x  2 fucheng fucheng 4096 Aug  1 23:11 Public
drwxr-xr-x  2 fucheng fucheng 4096 Aug  1 23:11 Templates
drwxr-xr-x  2 fucheng fucheng 4096 Aug  1 23:11 Videos
-rw-------  1 fucheng fucheng   51 Aug  1 23:11 .Xauthority
-rw-------  1 fucheng fucheng  711 Aug  1 23:11 .xsession-errors

Copy the code

The e first column is the file permissions, so what do they mean?

W: It’s writable. R: Read only. X: Executable. – : No permission

  1. Character representation
    • Drwxr-xr-x is a normal file that can be written, read and executed by the current user, read and executed by the same group of users, and read and executed by different users.
    • First character: file type D: common file: folder C: serial file L: connection file
    • **2-4 characters: the permission of the owner of the file **
    • 5-7 characters: Permissions of other users in the same group as the owner user
    • 8-10 characters: permissions of other users in different groups
  2. Numerical representation [expressed by weight in base 8]
    • -rw-r–r: indicates the default file permission 644
    • Drwxr-xr-x: default directory permission 755

Common Linux Commands

Shutdown restart logout command

1. Logout, shutdown, restart - Logout:logoutLog out,exit-shutdown -h Time -h: shutdown -time: 1. Now: immediately 2. 12.30: specified time 3doTo configure the sudo command: Which users are authorized to run which commands are configured by the superuser sudo /etc/sudoers sudo shutdown -h now Current account: itcast - Restart: Shutdown -r Time -r: restartCopy the code

In Linux, you need permission to shut down and restart the server, because you can’t just shut down the server. You need the super administrator to grant you permission to shut down or restart the server

File operation command

1. Ls: view directory contents -l: view details -a: View all files (hidden) Man: manual, help, and help commandshelpMkdir: create a directory Desktop: -java-jee: aa.txt bb.txt -android 3.cdSwitch directory -cd. Remember to put a space -cd/ Java goes to the subdirectory of the current directory -cd. / XXX Go to the subdirectory of the upper-level directory TAB: auto-complete 4. Touch: Create a blank common file touch aa.txt 5.echoCat and more: view the file content. -cat: View the file content. -more: View the file content in pages and press the space bar to change pages. Copy cp bj.txt./ Java/jee-mv: cut and rename Cut: mv aa.txt.. /android/ 2. Rename: If the clipped files are stored in the same directory, rename mv bb. TXT cc. TXT -rm: delete files or folders-f: If the file to be deleted does not exist, the system does not prompt you. -I: the system prompts you before deleting the file. To delete the file, enter y-dWc: word count: count the number of characters 154 233 3418-154: number of lines -233: number of words -3418: number of characters Command: Wc bj.txt 9.ln: creates a connection file - By default, a hard connection is created, such as copying, but the two files will be synchronized with the command: ln./ Java /android/aa. TXT aaa -s: creates a soft connection 10.pwd: see the absolute path to the current directory 11. Piping | command: ls - la | wc 12. Redirection - > : Override mode command:echo "ww">aaa - >> : Append mode command:echo "ww">>aaa 13. Passwd: Set the password. Ubuntu root is disabled by defaultCopy the code

System commands

1. Stat: View detailed file informationstatTXT 2. Who and whoami who: view online users whoami: view current users 3. Hostname: display the hostname hostname 4-a: displays complete system information. 5. Top: displays information about the current process that takes time and is refreshed every 3 seconds. Ifconfig: view or configure nic information, for example, ipconfig in Windows. Ipv4:32-bit 2 to 32 ipv6:128-bit ipv4 2 to 96 Multiple Set the VM IP address as follows: 1. Set the vmware connection mode: - Share the IP address of the host. The neighbor cannot be found on the network. - Bridge mode: Set the IP address separately. Graphical User Interface Set IP address Edit Connection ipv4 manual add IP Address Subnet mask 3. Run the following command to set the IP address: sudo ifconfig eth0 192.168.15.122 netmask 255.255.255.0 10. Ping Test the connection to the target host 11. Clear: Clear the screen Windows: CLS 12. Man: help command man command 13. Kill: kills a processkillPid.net 14. stat: Network connection details 15 useradd - view the user information sudo cat/etc/passwd itcast: x: 1000-1000: UbuntuA,,,, / home/itcast: / bin/bash - itcast: username - x : Password: encrypted and stored in /etc/shadow-1000: Account ID, userid-1000: group ID, group ID - UbuntuA,, : Account description - /home/itcast: Default location for storing files ~ - /bin/bash: Sh, bash, rbash - create user sudo useradd lijun-d  /home/lijun   -s /bin/bash 
	   -d-s: indicates the shell resolution mode of the user. Procedure: 1. Create the /home/lijun directory. 2. Run the useradd command. Run the passwd command to change the password. 4Copy the code

Package and compress files

Windows: zip, RAR Linux: gz, bzip, zip

Tar: package and unpack command tar -cxzjvf < Packaged file > < Directory to be packed > -c: creates an archive file, that is, the package folder. -x: unpack -z: compressed in gzip format, with the default compression ratio of 6 times (0-9) -j: Compressed in bzip2 format -v: displays information about packed or unpacked files. -f: / Java Abstract/unpack tar -xvf news.tar 2. Gzip, bzip2 compress and decompress 1. Decompress the gzip news.tar file. 2-d news.tar.gz
	    -dGz./ Java - Unpack and decompress tar -xzvf news.tar.gzCopy the code


Software management

Windows:.exe installation and uninstallation

  • Install: mysql.exe cc.exe
  • Uninstall: unique identifier of the software, package name Alibaba

Android:.apk Uninstallation package name Red Hat:. RPM Ubuntu: Debian upgrade *. Deb format

Install the software

Sudo DPKG -i < file name > -i: install sudo DPKG -i./tree_1.6.0-1_i386.deb Sudo DPKG -r < package name > -r: remove command: sudo DPKG -r tree-apt-get: advance package tools &emsp; &emsp; , to upgrade the DPKG command online installation install: sudo apt - get - install < package name > uninstall: sudo apt - get - remove < package name >Copy the code

Install VIM

Install viM 2. Use the VIM operation mode: 1. General mode, the default general mode, this mode cannot edit documents, can only view I (insert) into the insert mode 2. Edit mode, Insert mode You can edit a document in this mode. Press Esc to exit the insert mode and enter the general mode 3. Command mode: In common mode, press: to enter the command mode -q: to exit the command mode safely. If no operation is performed on the document, press q to exit vim -q! : When you modify the content but do not want to save it, q! Forced exit -wq: save the changes and exitsetNumber Displays the line number -setNonumber cancels line number displayCopy the code

Use vim to edit aa.txt

Setting up the development environment

7. Build Java server and realize remote access to Linux system. Secure Remote Access to Linux Using SSH SSH: Secure Shell Encryption: 1. Symmetric encryption (the encryption key is the same as the decryption key) DES and AES 2. Asymmetric encryption (different encryption key from decryption key) RSA: public key, private key Abstract: MD5 \sha1 1. Check whether the SSH server and client are installed. Sudo apt-cache policy openssh-client openssh-server 2. Install the SSH server and client software sudo DPKG -i./ SSH /* 3. Using a Windows SSH client to access a Linux server - putty: remote login - winscp433setup.exe: File transfer 2. 1. Where is the JDK stored? /opt 2. Copy the software package to /opt. 3. Decompress the green software packageexport JAVA_HOME="/ opt/jdk1.6.0 _39"
        export PATH="$JAVA_HOME/bin:$PATH"5. Refresh the configuration for the configuration to take effectsourceJava -javac Demo. Java - Java Demo 3. Where to install Tomcat /opt 2. Copy and decompress tar -xzvf apache-tomcat.tar.gz 3. Run -./startup.sh -./shutdown.sh 4. Install Eclipse in /opt. 2. Copy and decompress cp eclipse.tar.gz /opt tar -xzvf Eclipse.tar. gzCopy the code

SSH Remote Access

If you want a Windows client to operate Linux remotely, you need to configure the following in the virtual machine:

Check whether the SSH server and client are installed. The SSH server is not installed.

Install the SSH server and client software

Check after installation

Run the ifconfig command to query the IP address of the server

Access the IP address through putty

Log in to the system using winscp


Install the JDK

Copy the development package to the opt directory


root@ubuntu:/home/fucheng/Desktop/practice-software# cp ./jdk-6u39-linux-i586.bin /opt

Copy the code

Switch to the opt directory


root@ubuntu:/home/fucheng/Desktop# cd /opt

Copy the code

Check whether the JDK development package exists in the opt directory


root@ubuntu:/opt# ls -l
total 70076
-rwxr--r-- 1 root root 71756435 Aug  2 19:40 jdk-6u39-linux-i586.bin


Copy the code

Install the JDK, bin is an executable software, direct execution of the line!

	./jdk-6u39-linux-i586.bin
Copy the code

Configuring environment Variables


	   vim /etc/profile 
		export JAVA_HOME="/ opt/jdk1.6.0 _39"
        export PATH="$JAVA_HOME/bin:$PATH"5. Refresh the configuration for the configuration to take effectsource /etc/profile
Copy the code

Compile and run Java

root@ubuntu:/home/fucheng/Desktop# javac bb.java
root@ubuntu:/home/fucheng/Desktop# java bb
hello java
root@ubuntu:/home/fucheng/Desktop# 
Copy the code
Install Tomcat as follows: 1. Where to install tomcat /opt 2. Copy and decompress tar -xzvf apache-tomcat.tar.gz 3. Run -./startup.sh -./shutdown.sh 4. Install Eclipse in /opt. 2. Copy and decompress cp eclipse.tar.gz /opt tar -xzvf Eclipse.tar. gzCopy the code

If you find this article helpful, give the author a little encouragement