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
#首先去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
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-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 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 http_proxy=http://xx.xx.xx.xx:xxx
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
Ubuntu Common Commands Collection