Transferred from: http://www.cnblogs.com/lcw/p/3159462.html
View software XXX installation content: dpkg-l XXX
Find software in the Software Library: Apt-cache search Regular expression
Find software in the Software Library: Aptitude Search Package
Find out which package the file belongs to: dpkg-s filename
Find out which package the file belongs to: Apt-file search filename
Query software xxx depends on which packages: Apt-cache depends xxx
Query software xxx by which package depends on: Apt-cache rdepends xxx
Add a disc Source: sudo apt-cdrom add
System upgrade: sudo apt-get update;sudo apt-get dist-upgrade
Purge deleted package's residual profile: dpkg-l |grep ^rc|awk ' {print $} ' |sudo Xargs dpkg-p
Lack of automatic processing of H files at compile time: sudo auto-apt run./configure
To view the temporary storage directory for the download package when installing the software: ls/var/cache/apt/archives
To back up a list of all packages that are currently installed on the system: Dpkg–get-selections | Grep-v deinstall > ~/somefile
Recover all packages from the list file of the backup installation package: Dpkg–set-selections < ~/somefile;sudo dselect
Clean up older versions of the software cache: sudo apt-get AutoClean
Clear all software caches: sudo apt-get clean
Remove orphaned 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
View kernel: uname-a
View Ubuntu version: Cat/etc/issue or lsb_release-a
View kernel-loaded modules: Lsmod
View PCI devices: LSPCI
View USB devices: Lsusb-v
View NIC status: Sudo ethtool eth0
View CPU Information: Cat/proc/cpuinfo
Display current hardware information: sudo lshw
Display system run Time: Uptime
To view the partition of a hard disk: sudo fdisk-l
Hard disk partition: sudo fdisk/dev/sda
Hard drive format: sudo mkfs.ext3/dev/sda1
Hard drive Check (please do not check the mounted partition, otherwise it is easy to corrupt the data): sudo fsck/dev/sda1
Partition mount: sudo mount-t file system type (-O Nls=utf8 or-o Iocharset=utf8) device path via access path
Partition uninstall: sudo umount directory name or device name
View IDE Hard disk information: sudo hdparm-i/dev/hda
View stat hard drive information: sudo hdparm-i/dev/sda or sudo blktool/dev/sda ID
To view the disk's remaining space: DF
View Directory footprint: Du-hs directory Name
The USB flash drive cannot be uninstalled: Sync;fuser-km/media/usbdisk
To view the current read and write status of the hard disk: sudo iostat-x 2
To view current memory usage: free
Dynamic display of Process execution: top
See which processes are currently in progress: PS-A
View Current process tree: Pstree
Abort a process: Kill process number or Killall process name
Force abort a process: kill-9 process number or killall-9 process name
Graphics abort a program: Xkill The skeleton logo mouse, click the need to abort the program can
To view files opened by a process: lsof-p
Shows the process of opening file Abc.txt: Lsof abc.txt
Shows what program Port 22 is running now: lsof-i: 22
Displays the files that the NSD process now opens: Lsof-c NSD
Running the program in the background, after exiting the login, does not end the program: Nohup Program &
Detailed display of the program's Operation information: Strace-f-f-o outfile
Increase the maximum number of open files for the system: ulimit-n 4096 or echo 4096 >/proc/sys/fs/file-max
Configuring Adsl:sudo pppoeconf
ADSL manual dialing: sudo pon dsl-provider
Activating Adsl:sudo/etc/ppp/pppoe_on_boot
Disconnect Adsl:sudo Poff
View dial logs: sudo plog
How to set up a dynamic domain name: w3m-no-cookie-dump ' Http://usere:[email protected]/dyndns/update?system=dyndns&hostname= Yourdns.3322.org '
According to IP check NIC address: arping IP Address
Check the computer name according to IP: NMBLOOKUP-A IP Address
View current IP address: ifconfig eth0 |awk '/inet/{split ($2,x, ":");p rint x[2]} '
To view the IP address of the current extranet: 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\} '
To view the currently listening 80 port program: lsof-i: 80
View the physical address of the current network card: arp-a | awk ' {print $4} '
Add a second IP address to the same NIC: sudo ifconfig eth0:0 1.2.3.4 netmask 255.255.255.0
Get network support now Nat:echo 1 | sudo tee/proc/sys/net/ipv4/ip_forward; sudo iptables-t nat-i postrouting-j Masquerade
View routing information: Netstat-rn or sudo route-n
Manually add a route: sudo route add-net 192.168.0.0 netmask 255.255.255.0 GW 172.16.0.1
Manually delete a route: sudo route del-net 192.168.0.0 netmask 255.255.255.0 GW 172.16.0.1
How to modify the NIC MAC address: sudo ifconfig eth0 hw ether 00:aa:bb:cc:dd:ee
Count the number of current IP connections: Netstat-na|grep Established|awk ' {print $} ' |awk-f: ' {print '} ' |sort|uniq-c|sort-r-n
Shielded Ipv6:echo ' blacklist ipv6′| sudo tee/etc/modprobe.d/blacklist-ipv6
View current network connection status and program: sudo NETSTAT-ATNP
View current traffic for ADSL: sudo ethstatus-i ppp0
View the registration status of the domain name: whois baidu.cn
To view the routing situation for a domain name: Tracepath baidu.cn
Get the IP address back from the server: sudo dhclient
Download website Documentation: WGET-R-p-np-k http://www.xxx.com
How to 5 Threads download: axel-n 5 Http://www.xxx.com/downloadfile.zip
Add a service: sudo update-rc.d service name defaults 99
Remove a service: sudo update-rc.d service name remove
Temporarily restart a service:/etc/init.d/Service Name restart
Temporarily shut down a service:/etc/init.d/service name stop
Temporarily start a service:/etc/init.d/service name start
Add User: sudo adduser user name
Delete User: sudo deluser user name
Modify the password for the current user: passwd
Modify user password: sudo passwd user name
Modify user profile: sudo chfn userid
How to disable an account: sudo usermod-l username or sudo passwd-l user name
How to enable an account: sudo usermod-u username or sudo passwd-u user name
Add user to Admin group: sudo usermod-g admin-a user name
Configure default Java to use which: sudo update-alternatives–config java
Terminal Setup Agent: Export http_proxy=http://xx.xx.xx.xx:xxx
Modify system logon information: sudo VIM/ETC/MOTD
Using Sun's Java compiler: sudo update-java-alternatives-s java-6-sun
Switch IME Engine: im-switch-c
Convert file name from GBK to Utf8:convmv-r-F cp936-t utf8–notest–nosmart *
Convert file contents from GBK to utf8:iconv-f gbk-t UTF8 $i > NewFile
Convert mp3 tag code: sudo apt-get install Python-mutagen;find. -iname ' *.mp3′-execdir mid3iconv-e GBK {} \;
Under Console display Chinese: sudo apt-get install ZHCON;ZHCON–UTF8–DRV=VGA
LFTP Login Remote Windows Chinese ftp:lftp: ~>set ftp:charset GBK
PDF file garbled: sudo apt-get install xpdf-chinese-simplified xpdf-chinese-traditional poppler-data
One-screen view of file contents: Cat file name
Paging to view file contents: more filename
Controllable paging to view file contents: Less file name
View part of a file based on string matching: grep string file name
Displays the file name containing the string: grep-l-R string Path
Display file names that do not contain strings: Grep-l-R string Path
Quick Find a file: Find directory-name file name
Create two empty files: Touch file1 file2
Recursively create some nested directories: MKDIR–P/TMP/XXS/DSD/EFD
Recursively delete nested directories: RM–FR/TMP/XXS
Back to the current user's host directory: CD ~
View the absolute path of the current directory: PWD
List all files in the current directory: Ls-a
Move file under Path and rename: MV Path/File/new Path/new file name
Copy files or directories: Cp-av original file or original directory new file or new directory
viewing file types: filename
Compare the differences between two files: diff file1 File2
Displays the contents of the 6 line of the xxx file: tail-n 6 xxx
Keep showing the latest content: Tail-n 10-f/var/log/apache2/access.log
View the contents of lines fifth through 10th of the file: Sed-n ' 5,10p '/var/log/apache2/access.log
Find out about XXX commands: apropos xxx or man-k xxx
Transfer files via ssh: scp-rp/path/filename [email Protected]:/path
Change the suffix of all files from RM to Rmvb:rename ' s/.rm$/.rmvb/' *
Change the capitalization of all filenames to lowercase: rename ' tr/a-z/a-z/' *
Delete file with special file name –help.txt: Rm-–help.txt or RM./–help.txt
View subdirectories of the current directory: ls-d */. or Echo */.
Move files that have been accessed in the last 30 days to the parent back directory: Find. -type f-atime-30-exec MV {}.. /back \;
Displays the file containing XXXX within one hour: find. -type f-mmin-60|xargs-i grep-l xxxx ' {} '
Displays files from the last 2 hours to 8 hours: find. -mmin +120-mmin-480-exec more {} \;
Delete files that were modified up to 30 days ago: Find. -type f-mtime +30-mtime-3600-exec rm {} \;
Delete files created up to 30 days ago: Find. -type f-ctime +30-ctime-3600-exec rm {} \;
Delete the guest's file ending with AVI or RM: Find. -name ' *.avi '-o-name ' *.rm '-user ' guest '-exec rm {} \;
Delete files that are not used for 7 days not ending with Java and XML: Find. ! -name *.java! -name ' *.xml '-atime +7-exec rm {} \;
Delete all the. SVN directories: Find. -name. Svn-type d-exec rm-fr {} \;
Delete all temporary files ending with "~": Find. -name ' *~ '-exec rm {} \;
Count the current number of files: ls. | Wc-w
Statistics current directory number: Ls-l |grep ^d|wc-l
Displays the file name of the 2006-01-01 in the current directory: ls-l |grep 2006-01-01 |awk ' {print $8} '
Synchronizing remote data to a local directory using SSH: rsync-pa-i–size-only–delete–timeout=300 remote_ip:/home/ubuntu/backup
Added 7Z compression software: sudo apt-get install p7zip p7zip-full p7zip-rar
Add RAR software compression and decompression support: sudo apt-get install rar unrar
Decompression XXX.TAR.GZ:TAR-ZXVF xxx.tar.gz
Decompression XXX.TAR.BZ2:TAR-JXVF xxx.tar.bz2
Compression AAA BBB Catalog for XXX.TAR.GZ:TAR-ZCVF xxx.tar.gz AAA BBB
Compression AAA BBB Catalog for XXX.TAR.BZ2:TAR-JCVF xxx.tar.bz2 AAA BBB
Added LHA support: sudo apt-get install LHA
Add Solution CAB file support: sudo apt-get install cabextract
Show Calendar: Cal
Set Date: Date-s mm/dd/yy
Set time: Date-s hh:mm
Write Time to CMOS:HWCLOCK–SYSTOHC
View CMOS time: Hwclock–show
Read CMOS time: Hwclock–hctosys
Sync time from server: sudo ntpdate ntp.ubuntu.com
Set your PC's time zone to Shanghai: sudo cp/usr/share/zoneinfo/asia/shanghai/etc/localtime
Turns off UTC and writes the current time to CMOS. : sudo sed-ie ' s/utc=yes/utc=no/g '/etc/default/rcs;sudo HWCLOCK–SYSTOHC
Modify the root password of MySQL: sudo mysqladmin-u root-p password ' Your new password '
How to turn off a monitor with a command: xset DPMS Force off
To set the CPU frequency: sudo apt-get install Cpufrequtils;sudo cpufreq-info
Command shutdown: sudo halt
Now off: sudo shutdown-h
11 O'Clock Auto Power off: sudo shutdown-h 23:00
Shutdown after 60 minutes: sudo shutdown-h +60
command to restart your computer: sudo reboot
Restart your computer now: sudo shutdown-r
Turn off the touchpad for your notebook: synclient touchpadoff=1
Touch pad to open notebook: Synclient touchpadoff=0
Count how often each word appears and sort: awk ' {arr[$1]+=1}end{for (i in arr) {print arr[i] "\ t" i} ' file_name | Sort-rn
Count 80 port connections and sort: Netstat-na|grep:80|awk ' {print $} ' |awk-f: ' {print $} ' |sort|uniq-c|sort-r-n
Add terminal to right-click menu: sudo apt-get install nautilus-open-terminal
How to delete totem movie player's playback history: RM ~/.recently-used
How VIM displays color characters: sudo cp/usr/share/vim/vimcurrent/vimrc_example.vim/usr/share/vim/vimrc
Let vim directly support editing. gz files: sudo apt-get install Vim-full
How VIM Displays line numbers:: Set number
To view the startup program in session settings: LS ~/.config/autostart
Increase the reaction speed of wine: sudo sed-ie '/gbk/,/^}/d '/USR/SHARE/X11/LOCALE/ZH_CN. Utf-8/xlc_locale
Make ISO file: Mkisofs-o test.iso-jrv-v test_disk/home/carla/
Delay 10 seconds Capture: gnome-screenshot-d 10
Delay 5 seconds Catch current activation window: gnome-screenshot-w-D 5
How to command line burn: cdrecord-scanbus;cdrecord-v-eject speed=8 dev=1,1,0 test.iso
Where to Recycle Bin: ~/.local/share/trash/
Where is the default open mode configuration file: ~/.local/share/applications/mimeapps.list
How to view HTTP headers: W3m-dump_head http://www.xxx.com
Continuous monitoring of memory usage: watch-d free
How to switch to root account: SUDO-HS
Read-only mount NTFS partition: sudo mount-t ntfs-o nls=utf8,umask=0/dev/sdb1/mnt/c
writable mount NTFS partition: sudo mount-t ntfs-3g-o locale=zh_cn.utf8,umask=0/dev/sdb1/mnt/c
Mount FAT32 partition: sudo mount-t vfat-o iocharset=utf8,umask=0/dev/sda1/mnt/c
Mount shared files: sudo mount-t smbfs-o Username=xxx,password=xxx,iocharset=utf8//192.168.1.1/share/mnt/share
Mount ISO file: sudo mount-t iso9660-o Loop,utf8 xxx.iso/mnt/iso
Display the contents of a file with a line number: NL file name
Bulk convert RMVB to avi:for i in *; Do MENCODER-OAC mp3lame-lameopts vbr=3-ovcxvid-xvidencopts fixed_quant=4-of avi $i-o ' echo $i | Sed-e ' s/rmvb$/avi/'; Done
Convert SVG in batches to png:for i in *; Do inkscape $i –export-png= ' echo $i | Sed-e ' s/svg$/png/'; Done
Bulk shrink images to 30%:for i in *; Do convert-resize 30%x30% $ sm-$1; Done
Batch convert JPG to png:for i in *; Do convert $i ' echo $i | Sed-e ' s/jpg$/png/'; Done
Get the extended information for JPG (Exif): Identify-verbose xxx.jpg
View all listening ports for the current system: Nc-zv localhost 1-65535
Remove the ^m:cat filename from the file | tr-d "^m" > NewFile
Remove the ^m:sed-e "s/^m//g" in the file filename > NewFile
Convert bin/cue to ISO file: sudo apt-get install bchunk;bchunk image.bin image.cue image
Convert directory to ISO file: Mkisofs dirname-o Isofile.iso
Convert CD to ISO file: DD if=/dev/cdrom of=isofile.iso
Ape Convert to Flac:sudo apt-get install FLAC shntool;shntool split-t "%n.%p-%t"-F example_utf-8.cue-o FLAC example.ape-d FlacO Utputdir
Ape Convert to Mp3:sudo apt-get install FLAC shntool lame;shntool split-t "%n.%p-%t"-f example_utf-8.cue-o ' Cust Ext=mp3 lame–r 3mix-b 320–quiet–%f ' example.ape-d mp3outputdir
Check if there is a security risk on your local: sudo apt-get install Rkhunter;rkhunter–checkall
How to install anti-virus software: sudo apt-get install clamav;clamscan-r ~/
View Network connection Status: Netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, s[a]} '
Memory consumption of the statistical program: Ps-eo Fname,rss|awk ' {arr[$1]+=$2} END {print i,arr[i]}} ' |sort-k2-nr
Show current memory size: free-m |grep "Mem" | awk ' {print $} '
Sort processes by memory from large to small: Ps-eo "%c:%p:%z:%a" |sort-k5-nr
Sort processes from large to small by CPU utilization: Ps-eo "%c:%p:%z:%a" |sort-nr
Statistics the size of all JPG files in the current directory: Find. -name *.jpg-exec wc-c {} \;|awk ' {print $} ' |awk ' {A+=$1}end{print A} '
Clear Zombie Process: Ps-eal | awk ' {if ($ = = "Z") {print $4}} ' | sudo kill-9
CD capture rail for MP3 (lossy): sudo apt-get install Abcde;abcde-o mp3-b
CD capture track for Flac (lossless): sudo apt-get install Abcde;abcde-o flac-b
Displays statistics for the system installation package: Apt-cache Stats
Displays the name of the system all available packages: Apt-cache Pkgnames
Display the package information: Apt-cache show k3b
"Linux Technology" Ubuntu common Commands "turn"