Ubuntu Common Commands Encyclopedia

Source: Internet
Author: User
Tags filegroup locale rar readable filezilla phpmyadmin

Ubuntu Common Commands Encyclopedia

View Software XXX Installation content
#dpkg-L XXX

Find software
#apt-cache Search Regular Expressions
Find out which package the file belongs to
#dpkg-s filename apt-file search filename

Query software xxx depends on which packages
#apt-cache depends xxx

Query software xxx by which packages depend
#apt-cache rdepends xxx

Add a disc source
#sudo apt-cdrom Add

System upgrade
#sudo apt-get Update
#sudo Apt-get Upgrade
#sudo Apt-get Dist-upgrade

Clear so delete the remaining configuration files of the package
#dpkg-L |grep ^rc|awk ' {print $} ' |tr ["" N "] [" "]|sudo xargs dpkg-p-

Automatic processing of H files is missing at compile time
#sudo auto-apt run./configure

To view the temporary storage directory for downloading packages when installing 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 installed packages backed up above
#dpkg –set-selections < ~/somefile sudo dselect

Clean up older versions of the software cache
#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 | Cut-d "'-f2

system

View Kernel
#uname-A

View Ubuntu version
#cat/etc/issue

View kernel-loaded modules
#lsmod

View PCI Devices
#lspci

View USB Devices
#lsusb

View Network card Status
#sudo Ethtool eth0

View CPU Information
#cat/proc/cpuinfo

Display current hardware information
#lshw

HDD

To view the partition of a hard disk
#sudo fdisk-l

Viewing IDE hard disk information
#sudo hdparm-i/dev/hda

View Stat Drive Information
#sudo hdparm-i/DEV/SDA
Or
#sudo Apt-get Install Blktool
#sudo BLKTOOL/DEV/SDA ID

To view the remaining space on your hard disk
#df-H
#df-H

View Directory Footprint
#du-HS Directory Name

The USB drive can't be uninstalled
#sync Fuser-km/media/usbdisk

Memory

To view current memory usage
#free-M

ProcessSee which processes are currently in progress
#ps-A

Abort a process
#kill the process number (that is, the number of the first column in ps-a) or the Killall process name

Force abort of a process (used when the process abort above is unsuccessful)
#kill-9 Process number or killall-9 process name

To abort a program in a graphical manner
#xkill the mouse with the skeleton logo, click on the program you want to abort.

View the real-time status of the current process
#top

To view files opened by a process
#lsof-P

ADSL Configuration ADSL
#sudo pppoeconf

ADSL manual dialing
#sudo Pon Dsl-provider

Activating ADSL
#sudo/etc/ppp/pppoe_on_boot

Disconnecting ADSL
#sudo Poff

View the Dial Log
#sudo Plog

How to set up dynamic domain names
#首先去http://www.3322.org apply for a dynamic domain name
#然后修改/etc/ppp/ip-up Increase dialing when updating the domain name Directive sudo vim/etc/ppp/ip-up
#在最后增加如下行 W3m-no-cookie-dump

Network

According to IP check the network card address
#arping 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-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 currently listening 80 port program
#lsof-I: 80

View the physical address of the current network card
#arp-A | awk ' {print $4} ' ifconfig eth0 | head-1 | awk ' {print $} '

Let the network support NAT now
#sudo echo 1 >/proc/sys/net/ipv4/ip_forward
#sudo iptables-t nat-i Postrouting-j Masquerade

Viewing routing information
#netstat-rn sudo route-n

Manually add 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 network card MAC address
#sudo ifconfig eth0 down network card
#sudo ifconfig eth0 hw ether 00:aa:bb:cc:dd:ee
and change the address.
#sudo ifconfig eth0 up then start the NIC

Count the number of current IP connections
#netstat-na|grep Established|awk ' {print $} ' |awk-f: ' {print '} ' |sort|uniq-c|sort-r-n
#netstat-na|grep Syn|awk ' {print $} ' |awk-f: ' {print '} ' |sort|uniq-c|sort-r-n

To count the IP addresses in the current 20,000 IP packets that are larger than 100 IP packets
#tcpdump-tnn-c 20000-i eth0 | Awk-f "." ' {print $1″. ' $2″. " $3″. " $4} ' | Sort | uniq-c | Sort-nr | awk ' $ > 100 '

Shielded 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 shut down a service
#/etc/init.d/Service Name Stop

Temporarily start a service
#/etc/init.d/Service Name Start

Set

Configure default Java to use which
#sudo update-alternatives–config Java

Modify User Profile
#sudo CHFN UserID

Set up an agent for apt
#export http_proxy=http://xx.xx.xx.xx:xxx

Modify system Logon Information
#sudo VIM/ETC/MOTD

English

Convert file name from GBK to UTF8
#sudo apt-get Install CONVMV convmv-r-F cp936-t utf8–notest–nosmart *

Bulk conversion of all file contents under 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 file contents 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 under console
#sudo apt-get Install Zhcon use, enter Zhcon to

file

Quickly find a file
#whereis filename
#find Directory-name file name

View File types
#file filename

Displays the contents of the last 6 lines of the xxx file
#tail-N 6 xxx

Keep tail up to date with the latest content
#tail-N 10-f/var/log/apache2/access.log

View the contents of the fifth line (including) to line 10th (included) in the middle of the file
#sed-n ' 5,10p '/var/log/apache2/access.log

Find files that contain XXX strings
#grep-L-r xxx.

Full File Search (Desktop visualization)
Gnome-search-tool

Find the commands about XXX
#apropos xxx man-k xxx

Transferring files via SSH
#scp-rp/path/[email Protected]:/path
#将本地文件拷贝到服务器上
#scp [Email Protected]:/path/filename/path
#将远程文件从服务器下载到本地

See which applications a file is read and write to
#lsof file name

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 files, such as 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 current directory for the last 30 days to the parent back directory
#find. -type f-atime-30-exec MV {}.. /back ";

Displays files in the current directory within the last 2 hours to 8 hours
#find. -mmin +120-mmin-480-exec More {} ";

Delete all files that were modified up to 30 days ago
#find. -type f-mtime +30-mtime-3600-exec rm {} ";

Find the Guest user's file ending in AVI or RM and delete
#find. -name ' *.avi '-o-name ' *.rm '-user ' guest '-exec rm {} ';

Find files that do not end in Java and XML and are not used for 7 days deleted
#find. ! -name *.java! -name ' *.xml '-atime +7-exec rm {} ";

Count the current number of files
#ls/usr/bin|wc-w

Count the current number of directories
#ls-L/usr/bin|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} '

FTP

Upload Download File tool-filezilla
#sudo Apt-get Install FileZilla

FileZilla can't list Chinese catalogs?
Custom, Character set, site--type: GBK

Local Chinese interface
1) download FileZilla Chinese package to local directory, such as ~/
2) #unrar x Filezilla3_zhcn.rar
3) If you do not have Unrar, please install RAR and Unrar first
#sudo apt-get install RAR unrar
#sudo ln-f/usr/bin/rar/usr/bin/unrar
4) first back up The original language pack, and then install, the actual is to copy a language pack.
#sudo Cp/usr/share/locale/zh_cn/filezilla.mo/usr/share/locale/zh_cn/filezilla.mo.bak
#sudo CP ~/locale/zh_cn/filezilla.mo/usr/share/locale/zh_cn/filezilla.mo
5) Restart FileZilla, you can!

Unzip

Decompression xxx.tar.gz
#tar-ZXVF xxx.tar.gz

Decompression xxx.tar.bz2
#tar-JXVF xxx.tar.bz2

Compression AAA BBB directory for xxx.tar.gz
#tar-ZCVF xxx.tar.gz AAA BBB

Compression AAA BBB directory for XXX.TAR.BZ2
#tar-JCVF xxx.tar.bz2 AAA BBB

Extracting RAR Files
1) Install first
#sudo apt-get install RAR unrar
#sudo ln-f/usr/bin/rar/usr/bin/unrar
2)
Unzip
#unrar x Aaaa.rar

Unzip the ZIP file
1) Install first
#sudo apt-get Install zip unzip
#sudo ln-f/usr/bin/zip/usr/bin/unzip
2)
Unzip
#unzip x Aaaa.zip

Nautilus

Show hidden files
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 items and icons
*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 the installation
* themes:/// -System Theme Folder

Viewing installed Fonts
Enter "fonts:///" in the Nautilus's address bar to see all the fonts on this machine

program

Verbose display of program run information
#strace-F-f-o outfile

Date and time

Set Date
#date-S Mm/dd/yy

Set the time
#date-S HH:MM

Write Time to CMOS
#hwclock –SYSTOHC

Read CMOS time
#hwclock –hctosys

Synchronizing time from the server
#sudo ntpdate time.nist.gov
#sudo ntpdate time.windows.com

Control Desk

switching between different consoles
Ctrl + alt +←ctrl + Alt +→

Specify the console switch
Ctrl + ALT + Fn (n:1~7)

Console roll-down screen
SHIFT + Pageup/pagedown

Console Grab Chart
#setterm-dump N (n:1~7)

Database

MySQL database is stored in the local
#/var/lib/mysql

Exporting and importing data from MySQL
#mysqldump database name > file name
#导出数据库
#mysqladmin CREATE database name #建立数据库
#mysql Database name < file name #导入数据库

What if I forget the root password of MySQL?
#sudo/etc/init.d/mysql Stop
#sudo Mysqld_safe–skip-grant-tables
#sudo mysqladmin-u user password ' NewPassword "
#sudo mysqladmin Flush-privileges

Modify the root password of MySQL
#sudo mysqladmin-uroot-p password ' Your new password '

other

Download Web site Documentation
#wget-R-p-np-khttp://www.21cn.com
· R: Establish the server-side directory structure in this machine;
· -P: Download all images showing HTML files;
· -NP: Download Only the contents of the specified directory and its subdirectories for the target site;
· -K: Converts non-relative links to relative links.

How to delete the playback history of a totem movie player
#rm ~/.recently-used

How to change the shortcut keys for GNOME programs
Click on the menu, mouse over a menu, keyboard input any of the keys you need, can be a combination of keys, will take effect immediately; If you want to clear the shortcut, use BACKSPACE

How VIM displays color characters
#sudo CP/USR/SHARE/VIM/VIMCURRENT/VIMRC_EXAMPLE.VIM/USR/SHARE/VIM/VIMRC

How to delete a startup program in a session setting at the command line
#cd ~/.config/autostart RM needs to be removed from startup program

How to increase the reaction speed of wine
#sudo sed-ie '/gbk/,/^}/d '/USR/SHARE/X11/LOCALE/ZH_CN. Utf-8/xlc_locale

#chgrp
[Syntax]: CHGRP [-r] Filegroup file ...
[description]: The GID of the file represents the file group, the filegroup can be expressed as a number, or a valid group name, this command changes the GID of a file, see Chown.
-R recursively changes the access mode of all files under all subdirectories
[Example]:
#chgrp Group file changes the filegroup of file files to group

#chmod
[syntax]: chmod [-r] schema file ...
or chmod [Ugoa] {+|-|=} [rwxst] file ...
[description]: Change the access mode of the file, the access mode can be expressed as a number or a string of symbols, for example:
#chmod nnnn file , the number of n is 0-7, meaning as follows:
4000 runtime can change UID
2000 Runtime can change GID
1000 sticky bit
0400 file primary readable
0200 file main writable
0100 file main executable
0040 same group user readable
0020 same group user writable
0010 same group user can execute
0004 Other user-readable
0002 Other users can write
0001 other user-executable
nnnn is the addition of the above numbers, for example, chmod 0777 file refers to the files access to all user-readable writable executable.
-R recursively changes the access mode of all files under all subdirectories
U file primary
G same group of users
O other users
a all users
+ Add columns Permissions
-post-column Permissions
= post-column permissions
R readable
W writable Br>x executable
S runtime-configurable UID
T runtime-configurable GID
[Example]:
#chmod 0666 file1 file2 set file File1 and file2 to all user-readable writable #chmod u+x file to add the main executable permission to file files
#chmod o-rwx Remove all permissions from other users for file files

#chown
[Syntax]: chown [-r] File main file ...
[description]: The UID of the file represents the file master, the file master can be represented by a valid user name, this command changes the UID of a file, only if the file master or Superuser can use this file.
-R recursively changes the access mode of all files under all subdirectories
[Example]:
#chown Mary file changes the file owner of the file to Mary
#chown To change the UID of file to 150

Modify network configuration under Ubuntu command line

Taking eth0 as an example
1. Configuring the NIC in DHCP mode
Edit File/etc/network/interfaces:
#sudo vi/etc/network/interfaces
Replace the line with the following line for eth0:
# The primary network Interface-use DHCP to find our address
Auto Eth0
Iface eth0 inet DHCP
Use the following command to make the network settings effective:
#sudo/etc/init.d/networking Restart
Of course, you can also enter the following command directly under the command line to get the address
#sudo dhclient eth0

2. Configure a static IP address for the network card
Edit File/etc/network/interfaces:
#sudo vi/etc/network/interfaces
Replace the line with the following line for eth0:
# The Primary network interface
Auto Eth0
Iface eth0 inet Static
Address 192.168.3.90
Gateway 192.168.3.1
Netmask 255.255.255.0
Network 192.168.3.0
Broadcast 192.168.3.255
Replace the above IP address with the information you have.

Use the following command to make the network settings effective:
#sudo/etc/init.d/networking Restart

3. Set a second IP address (virtual IP address)
Edit File/etc/network/interfaces:
#sudo vi/etc/network/interfaces
Add the following line to the file:
Auto Eth0:1
Iface eth0:1 inet Static
Address 192.168.1.60
Netmask 255.255.255.0
Network x.x.x.x
Broadcast x.x.x.x
Gateway x.x.x.x
Fill in all information, such as Address,netmask,network,broadcast and gateways, based on your situation.
Use the following command to make the network settings effective:
#sudo/etc/init.d/networking Restart

4. Set the 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:
#sudo/bin/hostname newname
When the system starts, it reads the name of the host from/etc/hostname.

5. Configure DNS
First, you can add some host names and IP addresses for these host names in/etc/hosts, which is a static query that uses native computers simply.
To access the DNS server for querying, you need to set the/etc/resolv.conf file.
Assuming that the IP address of the DNS server is 192.168.3.2, then the contents of the/etc/resolv.conf file should be:
Search test.com
NameServer 192.168.3.2

Installing the AMP service

If you start the installation with the Ubuntu Server CD, you can choose to install it, which automatically installs the APACHE2,PHP5 and MYSQL5. The following are the main instructions if you are not installing the Ubuntu Server installation method.
Using the command to set up the lamp under Ubuntu is very simple and is done with a single command. Enter the following command at the terminal:
#sudo apt-get Install apache2 mysql-server php5 php5-mysql php5-gd #phpmyadmin
After the installation,MySQL administrator is root, no password , through the http://localhost/phpmyadmin can access MySQL

Modify MYSQL Password
Under Terminal input:
#mysql-U Root
#mysql > GRANT All privileges on * * to root@localhost identified by "123456″;
' 123456 ' is the root password that can be set freely, but it is best to set a security point.
#mysql > quit; Quit MySQL

Operation Commands for Apache2
Start:#sudo/etc/init.d/apache2 start
Restart:#sudo/etc/init.d/apache2 Restart
Close:#sudo/etc/init.d/apache2 Stop
Default home directory for apache2:/var/www/

Ubuntu Common Commands Encyclopedia

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.