View the installation content of software xxx
Dpkg-l xxx
Search software
Apt-cache search Regular Expression
Find the package of the file
Dpkg-s filename apt-file search filename
Queries which packages the software XXX depends on
Apt-Cache depends xxx
Queries which packages depend on the software xxx
Apt-Cache rdepends xxx
Add a CD Source
Sudo apt-CDROM add
System Upgrade
Sudo apt-Get update sudo apt-Get upgrade sudo apt-Get dist-Upgrade
Clear the residual configuration file of the deleted package.
Dpkg-L | grep ^ RC | awk '{print $2}' | tr ["/N"] [""] | sudo xargs dpkg-p-
Automatic Processing of H files is missing during compilation
Sudo auto-apt run./configure
View the temporary directory for storing downloaded packages during software installation
Ls/var/Cache/APT/Archives
Back up the list of all packages installed in the current system
Dpkg -- Get-selections | grep-V deinstall> ~ /Somefile
Restore all packages from the list file of the installation package backed up above
Dpkg -- Set-selections <~ /Somefile sudo dselect
Clear old software caches
Sudo apt-Get autoclean
Clear all software caches
Sudo apt-Get clean
Delete isolated software that is no longer used by the System
Sudo apt-Get autoremove
View the address of the package on the server
Apt-get-QQ -- print-Uris Install SSH | cut-D/'-F2
System
View the kernel
Uname-
View Ubuntu version
CAT/etc/issue
View the modules loaded by the kernel
Lsmod
View PCI devices
Lspci
View USB devices
Lsusb
View Nic status
Sudo ethtool eth0
View CPU Information
CAT/proc/cpuinfo
Display current hardware information
Lshw
Hard Disk
View Hard Disk Partitions
Sudo fdisk-l
View IDE Hard Disk Information
Sudo hdparm-I/dev/hda
View stat hard disk Information
Sudo hdparm-I/dev/SDA or sudo apt-Get install blktool sudo blktool/dev/SDA ID
View remaining disk space
DF-H
View space occupied by Directories
Du-HS directory name
The USB flash drive cannot be detached.
Sync Fuser-km/Media/usbdisk
Memory
View Current memory usage
Free-m
Process
View Processes
PS-
Abort a process
Kill process number (the number in the first column of PS-A) or killall process name
Force stop a process (used when the process failed to be aborted)
Kill-9 process no. Or killall-9 process name
Graphically abort a program
Xkill the mouse with the skeleton icon. Click the program to be aborted.
View the real-time status of the current process
Top
View files opened by a process
Lsof-P
Configure ADSL
Sudo pppoeconf
ADSL Manual dialing
Sudo Pon DSL-provider
Activate ADSL
Sudo/etc/PPP/pppoe_on_boot
Disconnect ADSL
Sudo poff
View dialing logs
Sudo plog
How to Set dynamic domain names
# First go to the http://www.3322.org to apply for a dynamic domain name # Then modify/etc/PPP/IP-up add when dialing the update domain name command sudo Vim/etc/PPP/IP-up # Add the following at last line w3m-no-cookie-dump 'HTTP: // username: password@members.3322.org/dyndns/update? System = dyndns & hostname = yourdns.3322.org'
Network
Query Nic addresses based on IP addresses
Arping IP Address
View current IP Address
Ifconfig eth0 | awk '/inet/{split ($2, X, ":"); print X [2]}'
View the IP address of the current Internet
W3m-no-cookie-dump www.ip138.com | grep-o '[0-9]/{1, 3 /}/. [0-9]/{1, 3 /}/. [0-9]/{1, 3 /}/. [0-9]/{1, 3/} 'w3m-no-cookie-dump www.123cha.com | grep-O' [0-9]/{1, 3 /}/. [0-9]/{1, 3 /}/. [0-9]/{1, 3 /}/. [0-9]/{1, 3/} 'w3m-no-cookie-dump ip.loveroot.com | grep-O' [0-9]/{1, 3 /}/. [0-9]/{1, 3 /}/. [0-9]/{1, 3 /}/. [0-9]/{1, 3 /}'
View the program listening to port 80
Lsof-I: 80
View the physical address of the current Nic
ARP-A | awk '{print $4}' ifconfig eth0 | head-1 | awk '{print $5 }'
Enable the network to support NAT now
Sudo Echo 1>/proc/sys/NET/IPv4/ip_forward sudo iptables-T nat-I postrouting-J Masquerade
View route information
Netstat-Rn sudo route-n
Manually add or delete a route entry
Sudo route add-net 192.168.0.0 netmask 255.255.255.0 GW 172.16.0.1 sudo route del-net 192.168.0.0 netmask 255.255.255.0 GW 172.16.0.1
How to modify the MAC address of a NIC
Sudo ifconfig eth0 down # disable the NIC sudo ifconfig eth0 HW ether 00: AA: BB: CC: DD: ee # change the address sudo ifconfig eth0 up # then start the NIC
Count the number of current IP connections
Netstat-Na | grep established | awk '{print $5}' | awk-F: '{print $1}' | sort | uniq-c | sort-r-N netstat-Na | grep SYN | awk '{print $5}' | awk-F: '{print $1}' | sort | uniq-c | sort-r-n
Count the IP addresses of up to 20000 IP packets in the current 100 IP Packets
Tcpdump-tnn-C 20000-I eth0 | awk-F ". "'{print $1 ". "$2 ". "$3 ". "$4} '| sort | uniq-c | sort-Nr | awk' $1> 1000'
Mask IPv6
Echo "blacklist IPv6" | sudo tee/etc/modprobe. d/blacklist-ipv6
Service
Add a service
Sudo update-rc.d service name defaults 99
Delete a service
Sudo update-rc.d service name remove
Temporarily restart a service
/Etc/init. d/service name restart
Temporarily close a service
/Etc/init. d/service name stop
Start a service temporarily
/Etc/init. d/service name start
Set
Configure which Java is used by default
Sudo Update-alternatives -- config Java
Modify user information
Sudo chfn userid
Set proxy for Apt
Export http_proxy = http://xx.xx.xx.xx: XXX
Modify system logon information
Sudo Vim/etc/motd
Chinese
Convert the file name from GBK to utf8
Sudo apt-Get install convmv-r-F cp936-T utf8 -- notest -- nosmart *
Batch convert all files in the src directory from GBK to utf8
Find Src-type D-exec mkdir-P utf8/{}/; find Src-type F-exec iconv-f gbk-T UTF-8 {}-O utf8 /{}/; MV utf8/* SRC Rm-fr utf8
Convert the file content from GBK to utf8
Iconv-f gbk-T utf8 $ I> newfile
Convert MP3 tag Encoding
Sudo apt-Get install Python-mutagen find.-INAME "*. MP3"-execdir mid3iconv-e GBK {}/;
Display Chinese characters in the console
When using sudo apt-Get install zhcon, enter zhcon.
File
Quickly search for a file
Whereis filename
Find directory-name file name
View File Types
File filename
Display the last six lines of XXX File
Tail-N 6 XXX
Let tail keep reading the latest content
Tail-N 10-F/var/log/apache2/access. Log
View the content between the fifth line (inclusive) and the second line (inclusive) in the file.
Sed-n'5, 10p'/var/log/apache2/access. Log
Search for files containing XXX strings
Grep-l-r xxx.
Query XXX commands
Apropos XXX man-K xxx
Transfer files through SSH
SCP-RP/path/filename username @ remoteip:/path # copy the local file to the server SCP-RP username @ remoteip: /path/filename/path # download the remote file from the server to the local device
View the applications that read and write a file.
Lsof file name
Change the suffix of all files from RM to rmvb
Rename's/. rm $/. rmvb /'*
Replace uppercase letters in all file names with lowercase letters.
Rename 'tr/A-Z/a-z /'*
Delete a file with a special file name, for example, file name: --help.txt
Rm -- --help.txt or RM./--help.txt
View subdirectories of the current directory
Ls-D */. Or echo */.
Move the files in the current directory that have been accessed in the last 30 days to the upper-level back directory.
Find.-Type F-atime-30-exec MV {} ../back /;
Display the files in the current directory within the last 2 hours to 8 hours
Find.-mmin + 120-mmin-480-exec more {}/;
Delete all files modified 30 days ago
Find.-Type F-mtime + 30-mtime-3600-exec RM {}/;
Search for and delete the file ending with Avi or RM of the guest user.
Find.-Name '*. avi'-o-name' *. rm '-user 'guest'-exec RM {}/;
The files found do not end with Java or XML and are not used for seven days.
Find .! -Name *. Java! -Name '*. xml'-atime + 7-exec RM {}/;
Count the number of current files
Ls/usr/bin | WC-W
Count the number of current directories
Ls-L/usr/bin | grep ^ d | WC-l
Display the file name of 2006-01-01 in the current directory
Ls-L | grep 2006-01-01 | awk '{print $8 }'
Compression
Decompress xxx.tar.gz
Tar-zxvf xxx.tar.gz
Decompress xxx.tar.bz2
Tar-jxvf xxx.tar.bz2
Compress AAA bbbdirectory as xxx.tar.gz
Tar-zcvf xxx.tar.gz aaa bbb
Compress AAA bbbdirectory as xxx.tar.bz2
Tar-jcvf xxx.tar.bz2 aaa bbb
Nautilus
Show Hidden Files
CTRL + H
Show Address Bar
CTRL + L
Special URI address
* Computer: //-all mounted devices and networks * Network: //-view available networks * burn: ///-A data virtual directory for burning CdS/DVDs * SMB: //-available Windows/samba Network Resources ** X-Nautilus-desktop: ///-desktop project and Icon * file: //-local file * trash: //-local recycle bin directory * ftp: //-FTP folder * SSH: //-ssh folder * fonts: //-font folder.
1. File Management # ls-A lists all files in the current directory, including hidden files with A. header.
File Management # ls-l or ll lists the details of files in the current directory
File Management # PWD view the absolute path of the current directory
File Management # CD .. back to the upper-level directory of the current directory
File Management # cd-back to the last directory
File Management # Cd ~ Or CD back to the current user's home directory
File Management # Cd ~ The user name is returned to the specified user's home directory.
2. File Management # create a directory with the mkdir directory name
File Management # mkdir-P recursively create some nested Directories
File Management # rmdir empty directory name to delete an empty directory
3. File Management # delete one or more files by RM file name
File Management # rm Rm-RF non-empty directory name recursively deletes everything in a non-empty directory, without the mention of-F
4. File Management # view the file content on a single screen with Cat file names
5. File Management # View File Content by page for more file names
6. File Management # The file content can be viewed on Controllable pages with less-than file names
7 file management # grep character file names view part of the file content based on character matching
8. File Management # Move the files under the music/video path/file path to the absolute path
File Management # change the name of the MV file in the current directory
9 file management # cp CP/path/file./move files under absolute path to the current directory
10 file management # Find find path-name "string" to find the files and directories that match the string in the path
11 file management # ln Source File Link name creates a hard link to the source file of the current directory
Ln/home/test/usr/test1 create a hard link for/home/test under/usr
12 file management # ln-s a B create the symbolic link B of A in the current directory
13 file management # Touch touch file1 file2 create two empty files
14 disk management # DF is used to report the total capacity, usage, and remaining capacity of the file system.
15 disk management # Du-B/home view the current/home directory capacity (K) and sub-directory capacity (k ).
16 disk management # fdisk-l view system partition information
17 disk management # fdisk/dev/SDB is used to partition a new SCSI hard disk.
18 disk management # mkfs. ext3 mkfs. ext3/dev/sdb1
Format the first primary partition of the first SCSI hard disk
Ext3 File System
Mkfs. ext2 mkfs. ext2/dev/sdb2 format to ext2 File System
19 disk management # mount Mount-T file system type device access path disk management # file system type
Iso9660 optical drive File System
Vfat FAT file system (Windows)
Mount the optical drive # Mount-T iso9660/dev/CDROM/mnt/CDROM
Mount fat # Mount-T vfat/dev/hda5/mnt/CDROM to mount the fifth logical partition of the first ide
17 disk management # umount/mnt/CDROM unmount/mnt/CDROM is empty
18 file permissions # chmod U + s file adds special permissions to the file owner
Chmod g + R file: Add read permission to the file group
Chmod o + W file adds write permission to other users of File
Chmod A-X file: all users of the file minus the execution permission.
Chmod 765 The owner of file is set to full permission, and the owner group is set to read/write permission. Other users have read and execute permissions.
19 File Permission # chown root/home change/home owner to root user
20 file permissions # change the/home group to the root group for chgrp root/home
21 print management # RedHat-config-printer-tui enter the printer installation Interface
22 print management # LP Lp-D hptr file print file to the hptr printer
23 print management # lpq-P printer name view printer status
24 print management # lprm-P printer name a delete print jobs in the printer
25 print management # disable-R "Changing paper" hptr disables the printer and prompts the cause
26 print management # enable hptr re-enable disabled
27 user management # useradd create a new user
28 user management # groupadd group name to create a new group
29 user management # passwd user name creates a password for the user
30 user management # passwd-D passwd-d the user name can also be logged in if you delete the User Password
31 user management # passwd-l user name locking account and password
32 user management # passwd-u user name unlock account password
33 user management # passwd-s user name query account and password
34. User Management # usermod-l new username old username changed to user name
35 user management # usermod-l usermod-L to lock the user name to lock the User Login
36 user management # usermod-u unlock user name unlock User Login
37 user management # usermod-u 501 Change User uid
38 user management # userdel-r user name delete all user information
39 user management # groupmod-N new username old username rename Group
40 user management # groupmod-G 501 Group Name Change Group GID
41 user management # groupdel the group name should first delete its users to delete the group
42 user management # gpasswd-A gpasswd-a username group name is added to the group
43 user management # ID user name query user information
44 software management # rpm-Qa | less query installed RPM
45 software management # rpm-Qa | grep FTP query specified rpm
46 software management # Check whether the RPM package has been installed by rpm-Q
47 software management # rpm-Q telnet-Server View telnet server package
48 software management # rpm-Qi software package name View Software Description
49 software management # query the file list of a software package by rpm-QL package name
50 software management # rpm-QF package name query the package to which a file belongs
51 software management # Full name of rpm-QP Software Package Query Information of uninstalled software packages
52 software management # delete a specific software package by rpm-e rpm-E Software Package name
53 software management # Full name upgrade of rpm-u rpm-uvh software package and display the process
54 software management # Full name of rpm-IVH software package installation package and display process
55 software management # rpm-V software package name verification package size and type
56 software management # tar-C create package-x release package-V display command process-Z represents the compressed package
57 software management # tar-CF tar-CVF benet.tar/home/Benet package the/home/Benet directory
58 software management # tar-CZF tar-zcvf benet.tar.gz/mnt package and compress the Directory
59 software management # tar-TF benet.tar: List of non-compressed files
60 software management # tar-tzf tar-TF benet.tar.gz view the file list of the compressed package
61 software management # tar-XF benet.tar non-compressed package file recovery
62 software management # extract and restore the files in the tar-zxvf benet.tar.gz compressed package
63 software management # tar-jxvf benet.tar.bz2
64 software management # diff file1 file2> patch name. Patch generates patch files for new and old files
65 software management # diff file1 file2 compares the differences between the two files
66 software management # patch file patch name. Patch patch
67 software management #./configure -- prefix =/usr/local/pre-compilation Configuration
68 software management # Make Compilation
69 software management # make install the compiled source code package
70 boot management # reboot init 6 restart Linux
71 start management # halt init 0 shutdown-H now disable Linux
72 start management # runlevel display system running level
73 startup management # init [0123456] changes the system running level, 7 types
74 start management # chkconfig -- list [service name] to view the service status
75 startup management # chkconfig -- level <running level> <service name> On | off | set sets the startup status of the service.
76 startup management # chkconfig <service name> On | off | set the startup status of a non-independent service
77 Process Management # top dynamic PS-Aux static process tree pstree view system processes
78 Process Management # program name & background running program
79 Process Management # FG transfers the processes running in the background back to the foreground
80 Process Management # BG transfers the processes running on the foreground to the background
81 Process Management # renice + 1 180 Add the priority of process No. 180 to 1
82 Process Management # Kill kill PID to terminate a PID Process
83 Process Management # execute/bin/ls at 5 + 3 days/bin/ls three days later at pm
84 Process Management # crontab-e uses VI to edit Automatic periodic tasks
85 Process Management # crontab-l view Automatic periodic tasks
86 Process Management # crontab-r Delete Automatic periodic tasks
87 Process Management # crond service crond immediately starts Automatic periodic service crond <START | stop | restart | status>
Implement Disk Quota (Note: Create/home partition when installing Linux)
Objective: To implement a disk quota of 5 kb for soft limit and 10 kb for Zhao in the/home directory.
Steps:
1. Modify the line containing/home, # vi/etc/fstab, and change it to defaults and usrquota. That is, the usrquota item is added. Save and exit.
2. Uninstall the/home directory # umount/home
3. Mount/home directory # Mount/home
4. Add User Zhao # useradd Zhao
5. Change the password # passwd Zhao
6. Generate quota information about the/home directory # quotacheck-cmug/home
# Quotacheck-vu/home
7. View information of all users # repquota-Au
8. Set the quota # edquota-u Zhao
Change soft and hard to 5 and 10 respectively.
9. Save and exit # WQ!
10. modification time # edquota-T
11. # WQ!
12. Enable the disk quota function on/home # quotaon/home
13. query the quota # quota-u Zhao