This time used to liunx things, learning a write application, just beginning unfamiliar with liunx from the page to start using, later began to use the shell command to operate. First, record the command line used:
I. File/folder Management
LS lists the current directory file (excluding hidden files)
Ls-a list current directory files (including hidden files)
Ls-l list the files in the current directory for more information
Cd.. Back to the top-level directory of the current directory
CD-Back to the same directory
CD ~ or CD back to the current user's host directory
mkdir directory name Create a directory
RmDir Empty directory name Delete an empty directory
RM FileName File name Delete a file or multiple files
RM-RF non-empty directory name delete everything under a non-empty directory
MV Path/Document/warp/file movement relative to the path of the file to the absolute path
MV FileName New name renamed in current directory
Find Road via-name "string" finds paths in the range of files and directories that meet string matches
Second, System Management
Fdisk fdisk-l viewing system partition information
FDISK FDISK/DEV/SDB partition a new SCSI hard drive
Chown chown Root/home Change the owner of/home to the root user
CHGRP chgrp root/home Change the home/home group to the root group
Useradd Create a new user
Groupadd group name to create a new group
PASSWD User name create password for user
passwd-d User name Delete user password can also login
Passwd-s User name Inquiry account password
Usermod-l new username old user name renamed to User
Userdel–r User name Delete user everything
Service [ServiceName] Start/stop/restart system service Control operation
/etc/init.d/[servicename] Start/stop/restart system service Control operation
Uname-a Viewing the kernel version
Cat/etc/issue View Ubuntu version
LSUSB Viewing USB devices
sudo ethtool eth0 view NIC status
Cat/proc/cpuinfo Viewing CPU information
LSHW Viewing current hardware information
sudo fdisk-l viewing disk information
Df-h viewing the remaining space on the hard disk
Free-m View Current Memory usage
PS-A See which processes are currently in progress
Kill process Number (the number of the first column in ps-a) or killall process name (kills a process)
Kill-9 process number forces a process to be killed
Reboot Init 6 Restart Linux system
Halt Init 0 shutdown–h now shut down the Linux system
three, packaging/decompression
TAR-C Create Package –x release Package-v Display command procedure –z represents a compressed package
TAR–CVF benet.tar/home/benet Pack The/home/benet directory
TAR–ZCVF BENET.TAR.GZ/MNT Package and compress the directory
TAR–ZXVF benet.tar.gz Compressed Package file decompression and recovery
TAR–JXVF benet.tar.bz2 Decompression
Iv. make compilation
Make compilation
Make install installs the compiled source package
Five, Apt command
Apt-cache Search Package
Apt-cache Show package for information about packages, such as description, size, version, etc.
sudo apt-get install package
sudo apt-get Install package--Reinstall reinstall packages
sudo apt-get-f install fix "-F =–fix-missing"
sudo apt-get Remove Package
sudo apt-get Remove Package--purge delete packages, including deletion of configuration files, etc.
sudo apt-get update source
sudo apt-get upgrade update installed packages
sudo apt-get Dist-upgrade upgrade system
sudo apt-get dselect-upgrade using Dselect upgrade
Apt-cache depends package learn about using dependencies
Apt-cache Rdepends package is to see which packages are dependent on
sudo apt-get BUILD-DEP Package Installation-related compilation environment
Apt-get Source Package Downloads The source code for the bundle
sudo apt-get clean && sudo apt-get autoclean cleanup of useless packages
sudo apt-get check to see if there is a corrupted dependency
sudo apt-get clean cleans up all software caches (that is, the Deb packets that are cached in the/var/cache/apt/archives directory)
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
Hard disk
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
Process
See 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
#首先去申请一个动态域名
#然后修改/etc/ppp/ip-up Increase dialing when updating the domain name Directive sudo vim/etc/ppp/ip-up
#在最后增加如下行 W3m-no-cookie-dump
Internet
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 |grep-o ' [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\} '
#w3m-no-cookie |grep-o ' [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\} '
#w3m-no-cookie-dump |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 and 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 up
Configure default Java to use which
#sudo update-alternatives–config Java
Modify User Profile
#sudo CHFN UserID
Set up an agent for apt
#export
Modify system Logon Information
#sudo VIM/ETC/MOTD
Chinese
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
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 Files
* 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
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-k
· 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 ~nfig/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] Mode 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, n is a number 0-7, meaning the following:
4000 can change UID at runtime
2000 can change GID at runtime
1000-Position Adhesive
0400 File Master Readable
0200 File Master Writable
0100 File Main executable
0040 same group of user-readable
0020 the same group of users can write
0010 the same group of users can execute
0004 other users can read
0002 Other users can write
0001 Other users can perform
NNNN is the addition of the above numbers, such as chmod 0777 file, which refers to the files ' access rights to all user-readable writable executables.
-R recursively changes the access mode of all files under all subdirectories
U file Master
G Same group of users
o Other users
A All Users
+ Add post-column permissions
-Post-column permissions are canceled
= post-column permissions
R readable
W Writable
X executable
S run-time configurable UID
T runtime can be placed GID
[Example]:
#chmod 0666 file1 file2 file file1 and file2 to all user-readable writable
#chmod u+x file increases file main executable permission
#chmod o-rwx Remove all permissions from other users to 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/nf file.
Assuming that the IP address of the DNS server is 192.168.3.2, then the contents of the/etc/nf file should be:
Search
NameServer 192.168.3.2
Ubuntu Shell Common Commands