As a Java back-end developer, there is certainly a time to work with Linux on a daily basis. Below I have organized some of the development may need to use some of the commands (before writing this essay, I do not have any experience, mainly to prevent themselves forget these operation commands, later useful to the new command and then modify).
The following is a remote connection to the server via SECURECRT and a file upload using WINSCP.
First, some user-related commands
1. New User AddUser username (only root has permission to add users)
2. Modify User password passwd username
3. Switch User su username
4. Delete User Userdel username
5. act as an administrator sudo
Second, the operation of the document command
1. List the basic information of the file Ls-l
-rw-rw-r--1 ubuntu Ubuntu 162 Mar 14:49 t.tar.gz
The first character, D, represents the directory, which represents the file
The next 9 bits are the current user, the current user's group, and other users ' permissions on the file, each accounting for three bits. The permission of the file-indicates that there is no permission, R is read, the number is 4;w, the number is 2;x, the number is 1.
The following indicates the user and group to which the file belongs, as well as the file size, creation date, and file name
2. Modify file Operation permissions
chmod u+x filename Indicates additional permissions for the owning user to execute
chmod g-w filename to reduce write permissions for a group
chmod o+w filename Indicates additional Write permissions to other users
chmod 777 filename Indicates to the owning user, the owning group, other users to open all permissions; 7 is obtained by 4+2+1
3. Operation of the file
PWD Displays the path that is currently located
mkdir FileName Create folder
Mkdir-p/a/b Creating a nested directory
Touch filename to create a file
CP filename New_filename Copying files
MV filename Path Moves the file (the file is renamed if it has a file name in the path)
Rm-r filename Delete file or folder, (-R is recursive meaning)
Rm-f forcibly deleting a directory or file
rmdir filename Delete folder (only empty folder)
Find/-name "Install.log" lookup can use * as a wildcard character
4. Content operation of the file
Find/path-name "*findname*"-type D query a folder under the name containing filename
Find/path-type d |wc-l count the number of folders under a path
Find/path-type F | Wc-l count the number of files under a path
Cat View File Contents
WC-LWC the number of rows, characters, bytes L of the filename statistic file, number of rows, W = number of characters, and c for number of bytes
> Overlay Output Redirector >> Append output redirect character
VI filename to edit the file.
VI has three modes, namely command mode, insert mode and last line mode.
Default into command mode, other modes press ESC to enter command mode
Cursor ←↑→↓ up or down
Page DOWN or ctrl+f
Page UP or ctrl+b
Home or ^ or 0 jump to the beginning of the line
End or $ jumps to the end of the line
#→ Right Jump # Characters
#← left Jump # Characters
1G or GG jumps to the first line
G Jump to Tail line
#G Jump To Line #
: Set NU line number
: Set Nonu shows the number of rows
X or del deletes a single character at the cursor
DD Delete When moving forward
#dd Delete the # line at the beginning of the current line
d^ Delete the current line from the beginning to the cursor character
d$ Delete the current line end to the cursor character
YY copy when moving forward
#yy Copy the # line at the beginning of the current line
P Paste to the right of the cursor
P paste to the left of the cursor
/word down to find string word
Word looks up string word
n Cursor is positioned to the next matching character
N Cursor positioned first match character
U undo multiple restores at one time
U Undo All edits
Insert mode: Command mode, I, A, O, insert to enter. This mode can be used to edit text
Last-line mode: shit+: Ready to go
: W Save File
:/filename save File as Fielname
: Q Quit when not modified
: q! Do not save and force quit
: Wq Save changes and exit
: s/old/new first old to replace with new
: All old s/old/new/g ahead are replaced with new
: #,# s/old/new/g #行间的所有old替换为new
:% s/old/new/g Current file All old replace with new
: S/OLD/NEW/C old replaces with new when prompt for confirmation replacement
Ii. commands used by programmers for routine maintenance projects
1. Find the server corresponding process Ps-ef |grep "Tomcat" so that you can know the server's corresponding process, as well as the server installation directory.
2. Shutting down the server can kill the process with kill-9 PID. You can also go to the Tomcat Bin directory./shutdown.sh. Turn on the server./startup.sh
3. Upload the modified file with WINSCP.
4. Log viewing, tail-200f Catalina.out displays the last 200 lines of the log. CTRL + C exit view.
III. Installation and uninstallation of JDK and Tomcat (I am accustomed to installing it in the/OPT directory)
Packaged TAR-CVF 1.tar 1.txt
Package and compress Tar-cvzf 1.tar.gz 1.txt
Compressed gzip 1.txt
Decompression gzip-d 1.txt.zip
Unzip and unpack TAR-ZXVF 1.tar.gz
There are two ways of installing, automatic and manual.
① Download the required version of the JDK installation package from the official website, upload it to the server, and unzip it.
Setting Environment variables: vim/etc/profile
At the end of the file, add
Export Java_home= "/opt/jdk1.8.0_131"
Export path= "${java_home}/bin: $PATH"
After the modification is completed, the profile file is executed with Source/etc/profile and then tested with Java-version.
② download the corresponding version of the Tomcat installation package from the official website, upload it to the server, and unzip it.
1. See if there are any configuration environment variables in the/etc/profile file.
2, modify the Tomcat conf directory under the Server.xml file, modify the http1.1 listening port changed to 80.
3. Start the server tomcat under the bin directory./startup.sh
4. Shut down the server tomcat in the bin directory./shutdown.sh
5, check the port number by which end share population with lsof-i:80
6, according to the PID query process related information; cd/proc/5941; then Ls-ail.
Linux commands commonly used by Java programmers