Common console commands-Ubuntu

Source: Internet
Author: User
Tags ftp file filezilla
Common console commands-Ubuntu View software xxx installation content # dpkg-Lxxx search software # apt-cachesearch regular expression search file package # dpkg-Sfilenameapt-filesearchfilename query software xxx dependency which packages # apt-cac... common console commands-Ubuntu View software xxx installation content # dpkg-L xxx search software # apt-cache search regular expression search file package # dpkg-S filename apt-file search filename query software xxx dependent packages # apt-cache depends xxx query software xxx dependent packages # apt-cache rdepends xxx adds a CD source # sudo apt-cdrom add system upgrade # sudo apt-get update # sudo apt-get upgrade # su Do 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 storage directory of the downloaded package when installing software # 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 package address on the server # apt-get-qq-print-uris install ssh | cut-d "'-f2 system view Kernel # uname-a view Ubuntu version # cat/etc /issue View module loaded by kernel # lsmod view PCI device # lspci view USB device # lsusb view NIC status # sudo ethtool eth0 view CPU information # cat/proc/cpuinfo display current hardware information # lshw hard disk view partition # 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 to view the remaining space of the hard disk # df-h # df-H to view the space occupied by the Directory # du-hs directory name cannot be detached # sync fuser-km/media/usbdisk memory view current memory usage # free-m process View which processes are currently in use # ps-A stop A process # kill process number (ps-) number in the first column) or the killall process name forces a process to stop (used when the process failed to stop) # kill-9 process number or killall-9 process name graphical method to stop a program # xkill the mouse with the skeleton icon, click the program to be aborted to view the real-time status of the current process # top view the files opened by the process # lsof-pADSL configure ADSL # sudo pppoeconfADSL manual dialing # sudo pon dsl-provider activate ADSL # sudo /etc/ppp/pppoe_on_boot disconnect ADSL # sudo poff view dialing log # How to set dynamic domain name for sudo plog # go first http://www.3322.org Apply for a dynamic domain name # then modify/etc/ppp/ip-up to update the domain name command sudo vim/etc/ppp/ip-up when dialing. # add the following line w3m-no at the end. -cookie-dump: check the Nic address based on the IP address # view the current IP address by arping IP address # ifconfig eth0 | awk '/inet/{split ($2, x ,":"); print x [2]} 'view the IP address of the current Internet # w3m-no-cookie -dumpwww.edu.cn | grep-o' [0-9] "{1, 3 "}". [0-9] "{1, 3 "}". [0-9] "{1, 3 "}". [0-9] "{1, 3"} '# w3m-no-cookie -dumpwww.xju.edu.cn | 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 currently # lsof-I: 80 view the physical address of the current Nic # arp-a | awk '{print $4}' ifconfig eth0 | head-1 | awk '{print $5}' immediately enable network support for nat # 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 added delete a route # 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 Nic MAC address # sudo ifconfig eth0 down disable the Nic # sudo ifconfig eth0 hw ether 00: AA: BB: CC: DD: EE then change the address # sudo ifconfig eth0 up and then start the NIC to 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: calculate the IP addresses of 20000 of 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> 100 'block 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 closes a service #/etc/init. d/service name stop start a service temporarily #/etc/init. d/service name start set configuration default Java used # 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 login information # sudo vim/etc/motd Chinese conversion file name from GBK to UTF8 # sudo apt-get install convmv-r-f cp936-t utf8-notest-nosmart * batch convert the contents of 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 conversion 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 "-execdi R mid3iconv-e GBK {} "; Chinese is displayed in the console # When sudo apt-get install zhcon is used, enter zhcon to search for a file. # whereis filename # find Directory-name file name view file type # file filename displays the last six lines of the xxx file # tail-n 6 xxx keeps tail running the latest content of the location to be read # tail-n 10-f/var/log/apache2/access. log to view the content from the fifth line (inclusive) to the second line (inclusive) of the file # sed-n '5, 10p'/var/log/apache2/access. log to find the file that contains the xxx string # grep-l-r xxx. search all files (desktop visualization) gnome-search-tool for xxx commands # apropos xxx man-k xxx transfer files through ssh # scp-r P/path/filenameusername @ remoteIP:/path # Copy the local file to the server # scp-rpusername @ remoteIP: /path/filename/path # Download the remote file from the server to the local server to check which applications read and write a file # lsof file name changes the suffix of all files from rm to rmvb # rename's /. rm $ /. rmvb/'* replace uppercase letters in all file names with lowercase # rename 'TR/A-Z/a-z/' * to delete files with special file names, such as file names: -help.txt # rm--help.txt or rm. /-help.txt view the subdirectory of the current directory # ls-d */. or echo */. move the files accessed in the current directory for the last 30 days to the upper-level back Directory # find. -type f-atime-30-exec mv {}.. /back # Find. -mmin + 120-mmin-480-exec more {} "; delete all files modified 30 days ago # find. -type f-mtime + 30-mtime-3600-exec rm {} "; find and delete a guest user's file ending with avi or rm # find. -name '*. avi '-o-name '*. rm '-user' guest'-exec rm {} "; find files that 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 show the number of files in the current directory file name # ls-l | grep 2006-01-01 | awk '{print $8}' FTP file upload and download tool-filezilla # sudo apt-get install filezillafilezilla cannot list Chinese directories? Site-> character set-> Custom-> Input: GBK local Chinese Interface 1) Download the filezilla Chinese package to the local directory, such ~ /2) # unrar x Filezilla3_zhCN.rar3) if you do not have unrar, install rar and unrar # sudo apt-get install rar unrar # sudo ln-f/usr/bin/rar/usr/bin/unrar4) to back up the original language pack, install the package again. copy a language pack. # Sudo cp/usr/share/locale/zh_CN/filezilla.mo. bak # sudo cp ~ /Locale/zh_CN/filezilla.mo/usr/share/locale/zh_CN/filezilla. mo5) restart filezilla! Decompress xxx.tar.gz # tar-zxvf xxx.tar.gz decompress xxx.tar.bz2 # tar-jxvf xxx.tar.bz2 compress aaa Region # tar-zcvf xxx.tar.gz aaa bbb compress aaa Region # tar-jcvf xxx.tar.bz2 aaa bbb RAR) first install # sudo apt-get install rar unrar # sudo ln-f/usr/bin/rar/usr/bin/unrar2) unzip # unrar x aaaa.rar unzip ZIP file 1) first install # sudo apt-get install zip unzip # sudo ln-f/usr/bin/zip/usr/bin/unzip2) decompress # unzip x aaaa.zip Nautilus hide file Ctrl + h show address bar Ctrl + l special URI address * computer: //-all mounted devices and networks * network: ///-browse 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, you can drag the font file here to complete installation * themes: //-system theme folder. view the installed font and enter "fonts: //" in the address bar of nautilus. you can view the running information of all the fonts programs on the local machine. # strace-f-F-o outfile date and time setting date # date-s mm/dd/yy set time # date-s HH: MM writes time into CMOS # hwclock-systohc reads CMOS time # hwclock-hctosys synchronizes time from the server # sudo ntpdate time.nist.gov # sudo ntpdate time.windows.com switch between different consoles Ctrl + ALT + ↓ Ctrl + ALT + → specify the console to switch Ctrl + ALT + Fn (n: 1 ~ 7) SHIFT + pageUp/pageDown in the console capture # setterm-dump n (n: 1 ~ 7) database mysql data inventory placed in place #/var/lib/mysql export and import data from mysql # mysqldump database name> file name # export database # mysqladmin create database name # create database # mysql database name <file name # import database forgot mysql root password how to do # sudo/etc/init. d/mysql stop # sudo mysqld_safe-skip-grant-tables # sudo mysqladmin-u user password 'newpassword "# sudo mysqladmin flush-privileges modify mysql root password # sudo mysqladmin-uroot- p password 'Your new password' other download website documentation # wget-r-p-np-k http://www.21cn.com · R: create a directory structure on the server on the local machine. ·-p: download and display all images of HTML files. ·-np: download only the contents of the directories and their subdirectories of the target site; ·-k: convert non-relative links to relative links. How to delete the playback history of a Totem player # rm ~ /. Recently-used how to change the gnome program shortcut key click menu, move the mouse to a menu, enter any key you need on the keyboard, can be a combination of keys, will take effect immediately; to clear the shortcut key, use backspacevim to display color characters # sudo cp/usr/share/vim/vimcurrent/vimrc_example.vim/usr/share/vim/vimrc how to delete the startup program set in the session on the command line # cd ~ /. Config/autostart rm how to increase the response speed of wine by deleting the startup program # sudo sed-ie '/GBK /, /^}/d '/usr/share/X11/locale/zh_CN.UTF-8/XLC_LOCALE # chgrp [Syntax]: chgrp [-R] file group file... [Note]: the GID of a file indicates the file Group of the file. the file group can be represented by numbers or a valid group name. this command changes the GID of a file. For more information, see chown. -R recursively changes the access mode of all files in all subdirectories [example]: # chgrp group file change the file group of the file to group # chmod [Syntax]: chmod [-R] mode file... Or chmod [ugoa] {+ |-| =} [rwxst] file... [Note]: The file access mode can be changed. the access mode can be represented as a number or a symbol string, for example, # chmod nnnn file, where n is a number ranging from 0 to 7. the meaning is as follows: 4000 during runtime, the UID2000 runtime can be changed. the GID1000 can be set to stick bits. 0400 files can be read by the master. 0200 files can be written by the master. 0100 files can be read by users in the same group. 0040 files can be written by users in the same group. users can execute 0004 other users can read 0002 other users can write 0001 other users can execute nnnn, which is obtained by adding the preceding numbers, for example, chmod 0777 file sets the file access permission to be readable and executable by all users. -R recursively changes the access mode of all files in all subdirectories u File Master g same group user o other user a all user + add Post column permission-cancel Post column permission = set Post column permission r readable w writable x executable s can be set to GID when UIDt is run [example]: # chmod 0666 file1 file2 set file1 and file2 to readable and writable for all users # chmod u + x file add file Master executable permissions for file files # chmod o-rwx cancel file all permissions of other users # chown [Syntax]: chown [-R] file master file... [Note]: The file UID indicates the file master. The File Master can be represented by numbers or a valid user name. this command changes the UID of a file, only when the file master or super user of this file is available. -R recursively changes the access mode of all files in all subdirectories [example]: # chown mary file change the file master to mary # chown 150 file change the file UID to 150Ubuntu command line to modify the network configuration. take eth0 as an example. configure the NIC in DHCP mode to edit the file/etc/network/interfaces: # sudo vi/etc/network/interfaces and replace the eth0 row with the following line: # The primary network interface-use DHCP to find our addressauto eth0iface eth0 inet dhcp use The following command to make The network settings take effect: # sudo/etc/init. d/networking restart, of course, you can also directly enter the following command in the command line to obtain the address # sudo dhclient eth02. Configure the static IP address for the NIC to edit the file/etc/network/interfaces: # sudo vi/etc/network/interfaces and replace the eth0 line with the following line: # The primary network interfaceauto eth0iface eth0 inet staticaddress 192.168.3.90gateway 192.168.3.1netmask 255.255.255.0network 192.168.3.0broadcast 192.168.3.255 replace The above IP address and other information with your own. run the following command to make the network settings take effect: # sudo/etc/init. d/networking restart3. set the second IP address (Virtual IP address) to edit the file/etc/network/interfaces: # sudo vi/etc/network/inte Rfaces adds the following lines to the File: auto eth0: 1 iface eth0: 1 inet staticaddress 192.168.1.60netmask 255.255.255.0network x. x. x. xbroadcast x. x. x. xgateway x. x. x. x fill in all information such as address, netmask, network, broadcast, and gateways according to your situation. run the following command to make the network settings take effect: # sudo/etc/init. d/networking restart4. set host name (hostname) use the following command to view the host name of the current host: # sudo/bin/hostname use the following command to set the host name of the current host: # When The sudo/bin/hostname newname system is started, it reads the host name from/etc/hostname. 5. configure DNS first, you can Add some host names to/etc/hosts and the IP addresses corresponding to these host names. this is a simple static query on the local machine. to access the DNS server for query, you need to set/etc/resolv. conf file. assume that the IP address of the DNS server is 192.168.3.2, then/etc/resolv. the conf file should be: search test. comnameserver 192.168.3.2 install the AMP service. if you start installation with Ubuntu Server CD, you can choose to install the service. The system automatically installs apache2, php5, and mysql5. The following describes how to install Ubuntu server if it is not installed. Using a command to set up Lamp in Ubuntu is actually very simple. you can use a single command to complete it. In the terminal enter the following command: # sudo apt-get install apache2 mysql-server php5 php5-mysql php5-gd # phpmyadmin installed, mysql administrator is root, no password, through http://localhost/phpmyadmin Then you can access mysql and enter: # MySql-u root # mysql> grant all privileges on *. * TO root @ localhost identified by "123456"; '000000' is the root password and can be set freely, but it is best TO set a security point. # Mysql> quit; run the following command to exit mysqlapache2: # sudo/etc/init. d/apache2 start restart: # sudo/etc/init. d/apache2 restart: # sudo/etc/init. d/apache2 stopapache2 default home directory:/var/www/
Related Article

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.