linux summary 20160727

1: ls -lat t is sorted by time
2: The
necessary , / root partition, swap partition
recommended partition, /boot boot partition
/
/boot /etc /home
       etc/ under passwd shadow group

partition: put the big hard disk Divide into small logical partitions
Format file system
Partition device file name: Define the device file name for each partition
Mount : Assign a mount point to each partition
3: File processing command
ls -h Humanized display size, t time sorting
ls -d aa view directory
mkdir -p cascade create
pwd view current directory
. current directory
.. parent directory
/root directory
~ user empty directory
rmdir

cp -r /AA /BB
cascade copy all files in the folder ( You can modify the name)

mv move, modify the name
rm delete files and directories -rf cascade force delete
touch create file
cat file
more file space page, enter page, q quit (can not view the page)
less same more, but can Page up (page up one page, up arrow one line)
/Keywords, you can search, press n to find the next
head -n20 to view the first 20 lines,
tail -n to view the last few lines
tail -f dynamically display the file content at the end of the file

ln -s source file target file
ln -s /root/aa /usr/aa.soft soft connection (similar to windows shortcut)
ln -s /root/aa /usr/aa.hard hard connection (similar to copy, synchronous update)


shutdown -h now
shutdown -r now

logout exit

4: network Command
ping 192.168.1.1
ifconfig View network card information
mail Send mail command
last View all logged in users
lastlog All users logged in
traceroute www.baidu.com website access routing path
netstat -t tcp, -u udp, -l monitor, -r route, -n display ip address and port number
netstat -tlun view the port monitored by the machine
netstat -an view all network connections of
the machine netstat -rn view the machine's routing table

monut mount point

5: linux decompression
command.zip (compression format supported by both win and linux)
.gz command (can only compress files, cannot compress directories, does not keep source files)
compress gzip file
name decompress gunzip file name
decompress gzip -d file name

tar command()
tar -c pack, -v details, -f file Name, -z package and compress
tar -zcf file name directory such as: tar -zcf zou.tar.gz /usr/zou
decompress -x decompress
tar -zxf file

zip command (add -r option to compress the directory, keep the source file, common to win and linux)
zip file name
zip -r directory
unzip decompress


bzip2 (compress large files, the compression ratio is very large)
bzip2 file name
bzip2 -k file name (-k preserves the source file)
bunzip2 decompresses the file (-k preserves source file)

6: User management command
Add user user add username
Set password passwd username
View
how long the current user who server has been running, uptime
view the information of the currently logged in user, w

7: Help command
View the help command or configuration file, man ls
to view shell built-in commands (built-in commands cannot be viewed with man), help cd
8: File search command find search
range matching conditions Search
by file name (not directory)
find /etc/ -name zou
find /etc/ -naume *zou*
find /etc/ -name zou*
finde /etc/ - name zou???
(*multiple characters, ?single character)
-name Find by file name
-iname Find by file name Case-insensitive

-size Find by file size (+ means how much is greater than, - means how much less than, no means How much is equal, the main university is the data block unit, which needs to be converted, x2)
files larger than 100M
find / -size +204800

find /etc -cmin -5 View files and directories whose attributes have been modified within 5 minutes
-amin access time access
-cmin file attribute change
-mmin file content modify

find files larger than 80m and less than 100m
find /etc -size +163840 -a -size -204800
-a both conditions are met
-o both conditions are met either

-type Find
f file, d directory, l soft link file according to file type

find /etc -name zou -exec ls -l {} \;
find the zou file under /etc and display its details
-exec/-ok command {} \; perform an operation on the searched result


locate find in the file library , (the system automatically updates the file library on a regular basis, new files cannot be found if they are not updated to the file library)
locate zou
updatedb (update the file library manually,)
locate -i file name (-i means case insensitive)

which,whereis View the absolute path of the command
grep Search in the file content
grep -iv Specified string file
-i Case insensitive
-v Exclude the specified file
For example : grep mysql /root/install.log

8: Privilege management command
chmod
chmod g+w, or zou.txt
g belongs to the group
o other users
u belongs to the user
a means all users

-R files in the directory cascade modification
chmod -R 777 /temp/

to change the owner of the user
chown (only root can operate )
chown user file or directory
chgrp user group file or directory

umask -S
Display the default permissions of new files

9: linx system management
linux process management
Determine the health status of the server
View all processes in the system
Kill processes

Query all processes in the system
ps -aux (commonly used)
ps -le

stat Process status
R Running, S : sleep, T: stop state, s: contains child processes, +: in the background

pstree View the process tree
-p display the pid of the
process -u display the user of the process



top command to view the system health status


kill kill the process
kill -1 process number Restart the process
kill -9 process is good to kill the process

view process pstree -p | grep java
view process ps -aux | grep java

kill all processes
killall -9 process name (not process number)
pkill -9 in and out name (not process number)
Kick user
w View all logged in users
pkill -9 -t terminal number


Work management
Put the process into the background management
1: Add & after the command (running in the background)
2: Press ctrl+z for the command (do not run in the background)

fg % job number restore the background suspended work to the foreground execution
bg % job number restore the background suspended work to the background execution


view the background work
jobs -l

system resources view
vmstat refresh delay refresh times (monitor system resources, view memory, cpu)
dmesg Kernel check information when booting
dmesg | grep CPU (check cpu information)
free check memory usage status
-b byte unit
-k kb
-m mb

uptime (system running time)
w (system login user)

uname check system Kernel information
-a View all system related information
-r View kernel version
-s View kernel name

Check whether the operating system is 32-bit or 64-bit
file /bin/ls

Query the release version of the liunx system
lsb_relcase -a

List the processes opened or used file information
lsof -p process number

system cron task
crontab
-e edit cron task
-l view cron task
-r delete all tasks of the current user

cron task standard format
***** command
The front is time

10 vim editor
10.1 includes 3 modes, edit mode, insert mode, command mode
Start to enter, command mode: all inputs are commands
Enter i, a, o to enter insert mode
Press esc to enter command mode
Command Mode press: enter the editing mode, enter the command mode automatically,
such as : wq exit save, :q! force quit without saving
: set nu set line number
: set nonu cancel line number
: n to n line
x delete character nx delete Multiple
dd delete lines ndd delete multiple lines
yy copy nyy copy multiple lines
p paste

dd cut ndd cut multiple lines
p paste

r replace
u go back to the previous

/string search, press n to belong to the next
: set ic search ignore size Write
: %s/old/new/g Replace the specified string with the full text
: n1,n2s/old/new/g Replace the specified range with the specified string

: r aa.txt Import aa.txt into vim


11: linux software Package installation
11.1 Package classification
Source package - script installation package (mainly, written in c, c##, easy to install wrong, need to compile and install very slowly)
*.gz
Easy to uninstall, just delete it.
Disadvantages : There are many installation steps, and it
is easy to make mistakes. The
compilation process takes a long time . Advantages of rpm : package installation is simple, only commands can be used to install, upgrade, and uninstall Fast installation speed Disadvantages: It has been compiled and can no longer read the source code Function selection is not as flexible as source code package Dependency RPM package management - rpm package command management Naming rules Such as: httpd-2.2.15-15.el6.centos.1.i686.rpm httpd package name 2.2.15 software version 15 software release times el6.centos suitable linux platform i686 suitable hardware platform rpm rpm package extension rpm package dependency (the biggest problem) tree dependency A->B->C ring dependency A->B->C->A module dependency: module dependency query website: www.rpmfind.net rpm install rpm -ivh package full name i install v show details h show progress rpm -Uvh package full name upgrade



































-U Upgrade
rpm -e Uninstall package full name

Check if
rpm is installed -q Package name
rpm -qa Check all installed packages

Check package information
rpm -qi package name


rpm -yum online management
Configure ip address, network yum source

rpm default Installation location
/etc/ Configuration file installation directory
/usr/bin/Executable file installation directory
/usr/lib/Storage location of function libraries used by programs
/usr/share/doc/Basic software manual storage location
/usr/share /man/Help document save location


16: Partition and file system
The main partition can only be divided into 4 at most, (generally three main partitions + one extended partition (there are multiple logical partitions))
df Display partition
df -h

du Directory size
du Directory name
du -s Total file size
du -h Humanized display
















--------------------------------- -----
Check if there is any installed java
ps -aux|grep java
close the java process
kill -9 process id

install tomcat
Upload the apache-tomcat-7.0.29.tar.gz file to /usr/local and perform the following operations:

[root@admin local]# cd /usr/local
[root@admin local]# tar -zxv -f apache- tomcat-7.0.29.tar.gz // Decompress the archive
[root@admin local]# rm -rf apache-tomcat-7.0.29.tar.gz // Delete the archive
[root@admin local]# mv apache- tomcat-7.0.29 tomcat

to start Tomcat
do the following:

[root@admin ~]# /usr/local/tomcat/bin/startup.sh //Start tomcat
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/ local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.7.0/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/ If
the above print information appears in bin/tomcat-juli.jar , it has been successfully started.

Firewall opens port 8080
Add port 8080 to the firewall configuration and perform the following operations:

[root@admin ~]# vi + /etc/sysconfig/iptables #Add
the following code
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
Restart the firewall

[root@admin java]# service iptables restart
Verify Tomcat installation and running Check whether tomcat is running normally
through the following address:

http://192.168.15.231:8080/see
Go to the tomcat system interface, congratulations, the installation is successful!

Stop Tomcat
[root@admin ~]# /usr/local/tomcat/bin/shutdown.sh //Stop tomcat

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326530406&siteId=291194637