"Linux" Linux common commands Summary

Source: Internet
Author: User
Tags bz2 locale rar set time svn mysql command line

View software XXX Installation content: Dpkg -l xxx find software in the Software Library:apt-cache search  regular expressions find software in the Software library: Aptitude search   Package find 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 is 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 Erase the deleted package's residual profile:dpkg -l |grep ^rc|awk  ' {print $2} '  |sudo xargs  dpkg -p the Automatic processing of H files is missing at compile time: Sudo auto-apt run ./configure View temporary storage directory for downloading packages when installing software: ls /var/ Cache/apt/archives back up the 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 software caches: Sudo apt-get autoclean clean up 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&Nbsp;| cut -d\ '  -f2 view kernel: uname -a view Ubuntu version:cat /etc/issue  or  lsb_release  -a view kernel-loaded modules: Lsmod View PCI device: LSPCI view USB device: Lsusb -v view NIC Status: Sudo ethtool eth0 View CPU Information: cat / Proc/cpuinfo Display current hardware information: SUDO&NBSP;LSHW Display system run time: Uptime View the partition of the hard disk: Sudo fdisk -l hard disk partition: sudo fdisk / DEV/SDA hard disk Format: SUDO&NBSP;MKFS.EXT3&NBSP;/DEV/SDA1 hard drive check (do not check the mounted partition, otherwise easily corrupt data): sudo fsck /dev/ SDA1 Partition mount:sudo mount -t  file system type   (-o nls=utf8  or  -o iocharset=utf8)   Device path   access road partition uninstall:sudo umount  directory name or device name View IDE hard disk information: SUDO&NBSP;HDPARM&NBSP;-I&NBSP;/DEV/HDA View stat hard Drive information  :sudo hdparm -I /dev/sda  or  sudo blktool /dev/sda  ID view hard disk spare space: DF View directory Footprint:du -hs  Catalog A famous dish cannot be uninstalled: Sync;fuser -km /media/usbdisk view the current read and write status of the hard disk:sudo  IOSTAT&NBSP;-X&NBSP;2 View current Memory usage: Free dynamic display of Process execution: Top View what processes are currently in progress: PS&NBSP;-A View Current process tree: Pstree abort a process:kill  process number   or  killall  process name Force abort a process: KILL&NBSP;-9&NBSP; process number   or  killall -9  process name graphical method abort a program:xkill  the mouse with the skeleton flag, click the program you want to abort to see the file that the process opened: lsof - P Show the process of opening file Abc.txt  :lsof abc.txt show 22 Port now run what program  :lsof -i :22 show NSD process now open file  :lsof &NBSP;-C&NBSP;NSD running the program in the background, after exiting the login, does not end the program  :nohup  program  & detailed display of the program's running information  :strace -f -f  -o outfile increase the maximum number of open files in the system:ulimit -n 4096  or  echo 4096 > /proc/sys /fs/file-max Configuring &NBSP;ADSL&NBSP;:SUDO&NBSP;PPPOECONFADSL manual dialing: Sudo pon dsl-provider activation  adsl:sudo  /etc/ppp/pppoe_on_boot disconnecting  adsl :sudo poff viewing the dial-up log: Sudo plog How to set the dynamic Domain name: W3m -no-cookie  -dump  ' Http://usere:[email protected]/dyndns/update?system=dyndns&hostname= yourdns.3322.org ' IP check network card address &NBSP;:ARPING&NBSP;IP address according to IP check computer name &NBSP;:NMBLOOKUP&NBSP;-A&NBSP;IP address view current IP address   :ifconfig eth0 |awk  '/inet/ {split ($2,x, ":");p rint x[2]} ' 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\} ' view the program currently listening on port 80  :lsof -i :80 View the physical address of the current Nic:arp -a | awk  ' {print &NBSP;$4} ' adds a second IP address to the same NIC  :sudo ifconfig eth0:0 1.2.3.4 netmask  255.255.255.0 immediately let the network support 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 network card MAC address  :sudo ifconfig eth0  Hw ether 00:aa:bb:cc:dd:ee statistics current number of IP connections  :netstat -na|grep ESTABLISHED|awk  ' {print  $5} ' |awk -f:  ' {print $1} ' |sort|uniq -c|sort -r -n maskipv6 :echo  ' blacklist ipv6′ | sudo tee /etc/modprobe.d/ Blacklist-ipv6 View current network connection status and program &NBSP;:SUDO&NBSP;NETSTAT&NBSP;-ATNP check the current traffic of ADSL:sudo ethstatus -i  PPP0 View the registration status of the domain name: whois baidu.cn to see the routing of a domain name: tracepath baidu.cn re-obtains the IP address from the server  :sudo  Dhclient download Web site Documentation: wget -r -p -np -k http://www.xxx.com How to download 5 threads:axel -n 5  Http://www.xxx.com/downloadfile.zip Add a service:sudo update-rc.d  service name  defaults 99 Delete a service   :sudo update-rc.d  Service Name  remove temporarily restarts a service:/etc/init.d/service name  restart temporarily shuts down a service:/etc/init.d/service name   Stop temporarily starts a service:/etc/init.d/service name  start Add user:sudo adduser  user name delete user:sudo deluser  User name modifies the current user's password: passwd Modify user password:sudo passwd  user name Modify user profile: Sudo chfn userid How to disable an account: Sudo usermod  -L  user name   or  sudo passwd -l  user name How to enable an account:sudo usermod -u  user name   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 conversion  mp3  Tag Code  :sudo apt-get install python-mutagen;find . -iname  ' *.mp3′ - execdir mid3iconv -e gbk {} \; Console display Chinese  :sudo apt-get install  zhcon;zhcon –utf8 –drv=vgalftp  Login remote Windows Chinese ftp:lftp :~>set ftp:charset  gbkpdf  file garbled  :sudo apt-get install xpdf-chinese-simplified  Xpdf-chinese-traditional poppler-data One screen view file contents  :cat File Name Page view file contents:more  FileName Controllable paging view file contents:less  file name according to string matching to view the contents of the files:grep  string   file name displays the file name that contains the string:grep  -l -r  string   Path display file name with no string:grep -l -r  string   path quickly find a file:find  directory  -name   file name Create two empty files: Touch file1 file2 recursively create some nested directories: MKDIR&NBSP;–P&NBSP;/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 lists all files in the current directory: ls -a move the file under the path and rename:mv  path/file  / New Path/new file name copy file or directory:cp -av  original file or original directory   new file or new directory view file type: File filename Compare the differences between two files: Diff file1  file2 Displays the contents of the last 6 lines of the xxx file  :tail -n 6 xxx constantly displaying the latest content  :tail -n 10 -f  /var/log/apache2/access.log View the contents of line fifth to 10th of the file  :sed -n  ' 5,10p '  /var/log/apache2/ Access.log find commands about xxx  :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 special file name  –help.txt  file:rm - –help.txt  or  rm ./– Help.txt View the subdirectory of the current directory:ls -d */.  or  echo */. Move the files that you have accessed in the last 30 days to the parent back directory  :find . &NBSP;-TYPE&NBSP;F&NBSP;-ATIME&NBSP;-30&NBSP;-EXEC&NBSP;MV&NBSP;{}&NBSP, .... /back \; displays files containing  xxxx  within one hour: find . -type f -mmin -60|xargs -i  grep -l xxxx  ' {} ' displays files within the last 2 hours to 8 hours: find . -mmin +120 -mmin -480  -exec more {} \; Delete files that were modified 30 days ago  :find . -type f -mtime +30  -mtime -3600 -exec rm {} \; Delete files created 30 days ago  :find . -type f  -ctime +30 -ctime -3600 -exec rm {} \; Delete 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 without ending in Java and XML  :find . ! -name *.java ! -name  ' *.xml '  -atime +7 -exec rm {} \; Delete all  .svn  Catalog  :find . -name .svn -type d -exec rm -fr {} \; Delete all to "~ "End of temporary files  :find . -name  ' *~ '  -exec rm {} \; statistics current number of files: ls .| WC&NBSP;-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} ' synchronizes remote data to a local directory using SSH  :rsync -pa -i – Size-only –delete –timeout=300 remote_ip:/home/ubuntu /backup add  7Z  compress 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 &NBSP;XXX.TAR.BZ2&NBSP;:TAR&NBSP;-JXVF&NBSP;XXX.TAR.BZ2 Compressed AAA&NBSP;BBB directory is xxx.tar.gz :tar -zcvf  XXX.TAR.GZ&NBSP;AAA&NBSP;BBB Compressed AAA&NBSP;BBB MeshRecorded as xxx.tar.bz2 :tar -jcvf xxx.tar.bz2 aaa bbb add  lha  support  :sudo  Apt-get install lha Add Solution  cab  File support  :sudo apt-get install  Cabextract Display 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 the computer's time zone to Shanghai: Sudo cp /usr/share/zoneinfo/asia/shanghai /etc/localtime turn off UTC, Writes the current time to the 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 use the command to turn off the monitor  :xset dpms force off set CPU frequency  :sudo apt-get install  Cpufrequtils;sudo cpufreq-info command shutdown: Sudo halt now off: Sudo shutdown -h now 11 o'clock Auto Power off: sudo  shutdown -h 23:0060 minutes after the shutdown: sudo shutdown -h +60 command to restart your computer: Sudo reboot Now restart your computer: Sudo shutdown -r now turn off your notebook's touchpad  :synclient  touchpadoff=1 Open the Notebook's touchpad: synclient touchpadoff=0 count the frequency of each word and sort  :awk  ' {arr[$1]+=1 }end{ for (I in arr) {print arr[i] "\ t" i} '  file_name | sort -rn statistics 80 port connection and sort   :netstat -na|grep :80|awk  ' {print $5} ' |awk -f:  ' {print $1} ' |sort|uniq  -c|sort -r -n Add the terminal to the right-click menu:sudo apt-get install  Nautilus-open-terminal How to delete totem movie player's play History  :rm ~/.recently-usedvim  how to display color characters &NBSP;:SUDO&NBSP;CP &NBSP;/USR/SHARE/VIM/VIMCURRENT/VIMRC_EXAMPLE.VIM&NBSP;/USR/SHARE/VIM/VIMRC  vim  Direct support for editing  .gz   File  :sudo apt-get install vim-fullvim  How to display line numbers:: Set number View the startup program in session settings: LS  ~/.config/autostart improves wine response speed  :sudo sed -ie  '/gbk/,/^}/d '  /usr/share/x11/ Locale/zh_cn. Utf-8/xlc_locale production ISO file: mkisofs -o test.iso -jrv -v test_disk /home/carla/delay 10 seconds grab Figure:gnome-screenshot -d  10 delay 5 seconds Catch current activation window: gnome-screenshot -w -d 5 How to: cdrecord -scanbus;cdrecord -v - Where is the Eject speed=8 dev=1,1,0 test.iso 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  How to switch to root account: SUDO&NBSP;-HS read-only mount NTFS partition: sudo mount -t ntfs -o nls=utf8,umask=0 / DEV/SDB1&NBSP;/MNT/C writable NTFS partition: Sudo mount -t ntfs-3g -o locale=zh_cn.utf8,umask=0 &NBSP;/DEV/SDB1&NBSP;/MNT/C mount FAT32 Partition: Sudo mount -t vfat -o iocharset=utf8,umask=0 &NBSP;/DEV/SDA1&NBSP;/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 the file with line number: nl  file name Batch   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 to png:for i in *; do in bulk  inkscape  $i  –export-png= ' echo  $i  | sed -e  ' s/svg$/png/';  Done batch shrink pictures to 30%:for i in *; do convert -resize 30%x30% $1 sm-$1;  done Batch conversion jpg to png:for i in *; do convert  $i   ' echo  $i  |  sed -e  ' s/jpg$/png/';  done gets the extended information for JPG (EXIF): identify -verbose xxx.jpg View all the listening ports for the current system: NC  -zv localhost 1-65535 Remove ^m:cat filename | tr -d  "^M" from the file  >  newfile Remove ^m:sed -e  "s/^m//g" from the file  filename > newfile convert bin/cue to ISO file: sudo  apt-get install Bchunk;bchunk image.bin image.cue image converting directories to ISO files:mkisofs dirname -o  Isofile.iso convert CD to ISO file:dd if=/dev/cdrom of=isofile.isoape  to Flac:sudo apt-get install  flac shntool;shntool split -t "%n.%p-%t"  -f example_utf-8.cue -o flac Convert from  example.ape -d flacoutputdirape 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 –r3mix -b 320–quiet – %f '  example.ape -d  Mp3outputdir Check for local security vulnerabilities: 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 statistics program: ps - eo fname,rss|awk  ' {arr[$1]+=$2}&nbsp end {for  (I in arr)  {print i,arr[i]}} ' |SORT&NBSP;-K2&NBSP;-NR show current memory size:free  -m |grep  "Mem"  | awk  ' {print $2} ' sort processes from large to small in memory:ps -eo  "%c : %p  : %z : %a "|sort -k5 -nr by CPU utilization from large to small process:ps -eo "%c : %p  : %z : %a "|SORT&NBSP;-NR Statistics the size of all JPG files in the current directory: Find . -name *.jpg -exec  wc -c {} \;|awk  ' {print $1} ' |awk  ' {a+=$1}end{print a} ' clears zombie process:ps  -eal | awk  ' { if  ($2 ==  "Z")  {print $4} '  | sudo  kill -9cd  capture rail for  mp3  (lossy): Sudo apt-get install abcde;abcde -o mp3  -bCD  capture rail 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 all available packages for the system: Apt-cache pkgnames displays information about the package:apt-cache show  K3b



Original address: "Linux" Linux common command summary
Tags: linux commands

Smart recommendations
    • MYSQL command line display garbled solution
    • Nginx rewrite parameters and examples
    • The most useful tips for Linux command exercise
    • A good man's life is not safe
    • My first experience of "home projector without screen TV"

"Linux" Linux common commands Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.