Ubuntu command Overview

Source: Internet
Author: User

 

The following Ubuntu command set is collected and organized for the network. It is mainly used for reference and may be continuously enriched:

APT (software management) usage reference
Apt-cache search package
Apt-Cache show package obtains package information, such as description, size, and version.
Sudo apt-Get install package installation package
Sudo apt-Get install package--reinstall re-installation package
Sudo apt-get-F install force Installation
Sudo apt-Get remove package Delete package
Sudo apt-Get remove package--Purge delete a package, including deleting a configuration file.
Sudo apt-Get Update update source
Sudo apt-Get upgrade updates installed packages
Sudo apt-Get dist-upgrade System
Sudo apt-Get dselect-upgrade using dselect
Apt-Cache depends package for dependency usage
Apt-Cache rdepends package to understand specific Dependencies
Sudo apt-Get build-dep package installation-related compilation environment
Apt-Get source package download the source code of the package
Sudo apt-Get Clean & sudo apt-Get autoclean clear the archive of the downloaded file

Sudo apt-Get check whether any corrupted dependency exists

Sudo chmod + x googleearthlinux. bin to install the binfile, googleearthlinux is an example. Remember to copy the file to your folder/home/yourname (My doff)

Permission command

Sudo Nautilus uses the super administrator permission to manage folders (after entering the command and password on the terminal, the folder automatically jumps out, and you can have the root permission)

Note the gap between commands. If you cannot run the command, check the case and halfwidth.

 

 

1. File Management # ls-A lists all files in the current directory, including hidden files with A. header.
File Management # ls-l or ll lists the details of files in the current directory
File Management # PWD view the absolute path of the current directory
File Management # CD .. back to the upper-level directory of the current directory
File Management # cd-back to the last directory
File Management # Cd ~ Or CD back to the current user's home directory
File Management # Cd ~ The user name is returned to the specified user's home directory.
2. File Management # create a directory with the mkdir directory name
File Management # mkdir-P recursively create some nested Directories
File Management # rmdir empty directory name to delete an empty directory
3. File Management # delete one or more files by RM file name
File Management # rm Rm-RF non-empty directory name recursively deletes everything in a non-empty directory, without the mention of-F
4. File Management # view the file content on a single screen with Cat file names
5. File Management # View File Content by page for more file names
6. File Management # The file content can be viewed on Controllable pages with less-than file names
7 file management # grep character file names view part of the file content based on character matching
8. File Management # Move the files under the music/video path/file path to the absolute path
File Management # change the name of the MV file in the current directory
9 file management # cp CP/path/file./move files under absolute path to the current directory
10 file management # Find find path-name "string" to find the files and directories that match the string in the path
11 file management # ln Source File Link name creates a hard link to the source file of the current directory
Ln/home/test/usr/test1 create a hard link for/home/test under/usr
12 file management # ln-s a B create the symbolic link B of A in the current directory
13 file management # Touch touch file1 file2 create two empty files
14 disk management # DF is used to report the total capacity, usage, and remaining capacity of the file system.
15 disk management # Du-B/home view the current/home directory capacity (K) and sub-directory capacity (k ).
16 disk management # fdisk-l view system partition information
17 disk management # fdisk/dev/SDB is used to partition a new SCSI hard disk.
18 disk management # mkfs. ext3 mkfs. ext3/dev/sdb1
Format the first primary partition of the first SCSI hard disk
Ext3 File System
Mkfs. ext2 mkfs. ext2/dev/sdb2 format to ext2 File System
19 disk management # mount Mount-T file system type device access path disk management # file system type
Iso9660 optical drive File System
Vfat FAT file system (Windows)
Mount the optical drive # Mount-T iso9660/dev/CDROM/mnt/CDROM
Mount fat # Mount-T vfat/dev/hda5/mnt/CDROM to mount the fifth logical partition of the first ide
17 disk management # umount/mnt/CDROM unmount/mnt/CDROM is empty
18 file permissions # chmod U + s file adds special permissions to the file owner
Chmod g + R file: Add read permission to the file group
Chmod o + W file adds write permission to other users of File
Chmod A-X file: all users of the file minus the execution permission.
Chmod 765 The owner of file is set to full permission, and the owner group is set to read/write permission. Other users have read and execute permissions.
19 File Permission # chown root/home change/home owner to root user
20 file permissions # change the/home group to the root group for chgrp root/home
21 print management # RedHat-config-printer-tui enter the printer installation Interface
22 print management # LP Lp-D hptr file print file to the hptr printer
23 print management # lpq-P printer name view printer status
24 print management # lprm-P printer name a delete print jobs in the printer
25 print management # disable-R "Changing paper" hptr disables the printer and prompts the cause
26 print management # enable hptr re-enable disabled
27 user management # useradd create a new user
28 user management # groupadd group name to create a new group
29 user management # passwd user name creates a password for the user
30 user management # passwd-D passwd-d the user name can also be logged in if you delete the User Password
31 user management # passwd-l user name locking account and password
32 user management # passwd-u user name unlock account password
33 user management # passwd-s user name query account and password
34. User Management # usermod-l new username old username changed to user name
35 user management # usermod-l usermod-L to lock the user name to lock the User Login
36 user management # usermod-u unlock user name unlock User Login
37 user management # usermod-u 501 Change User uid
38 user management # userdel-r user name delete all user information
39 user management # groupmod-N new username old username rename Group
40 user management # groupmod-G 501 Group Name Change Group GID
41 user management # groupdel the group name should first delete its users to delete the group
42 user management # gpasswd-A gpasswd-a username group name is added to the group
43 user management # ID user name query user information
44 software management # rpm-Qa | less query installed RPM
45 software management # rpm-Qa | grep FTP query specified rpm
46 software management # Check whether the RPM package has been installed by rpm-Q
47 software management # rpm-Q telnet-Server View telnet server package
48 software management # rpm-Qi software package name View Software Description
49 software management # query the file list of a software package by rpm-QL package name
50 software management # rpm-QF package name query the package to which a file belongs
51 software management # Full name of rpm-QP Software Package Query Information of uninstalled software packages
52 software management # delete a specific software package by rpm-e rpm-E Software Package name
53 software management # Full name upgrade of rpm-u rpm-uvh software package and display the process
54 software management # Full name of rpm-IVH software package installation package and display process
55 software management # rpm-V software package name verification package size and type
56 software management # tar-C create package-x release package-V display command process-Z represents the compressed package
57 software management # tar-CF tar-CVF benet.tar/home/Benet package the/home/Benet directory
58 software management # tar-CZF tar-zcvf benet.tar.gz/mnt package and compress the Directory
59 software management # tar-TF benet.tar: List of non-compressed files
60 software management # tar-tzf tar-TF benet.tar.gz view the file list of the compressed package
61 software management # tar-XF benet.tar non-compressed package file recovery
62 software management # extract and restore the files in the tar-zxvf benet.tar.gz compressed package
63 software management # tar-jxvf benet.tar.bz2
64 software management # diff file1 file2> patch name. Patch generates patch files for new and old files
65 software management # diff file1 file2 compares the differences between the two files
66 software management # patch file patch name. Patch patch
67 software management #./configure -- prefix =/usr/local/pre-compilation Configuration
68 software management # Make Compilation
69 software management # make install the compiled source code package
70 boot management # reboot init 6 restart Linux
71 start management # halt init 0 shutdown-H now disable Linux
72 start management # runlevel display system running level
73 startup management # init [0123456] changes the system running level, 7 types
74 start management # chkconfig -- list [service name] to view the service status
75 startup management # chkconfig -- level <running level> <service name> On | off | set sets the startup status of the service.
76 startup management # chkconfig <service name> On | off | set the startup status of a non-independent service
77 Process Management # top dynamic PS-Aux static process tree pstree view system processes
78 Process Management # program name & background running program
79 Process Management # FG transfers the processes running in the background back to the foreground
80 Process Management # BG transfers the processes running on the foreground to the background
81 Process Management # renice + 1 180 Add the priority of process No. 180 to 1
82 Process Management # Kill kill PID to terminate a PID Process
83 Process Management # execute/bin/ls at 5 + 3 days/bin/ls three days later at pm
84 Process Management # crontab-e uses VI to edit Automatic periodic tasks
85 Process Management # crontab-l view Automatic periodic tasks
86 Process Management # crontab-r Delete Automatic periodic tasks
87 Process Management # crond service crond immediately starts Automatic periodic service crond <START | stop | restart | status> achieves Disk Quota (Note: Create/home partitions when installing Linux)
Objective: To implement a disk quota of 5 kb for soft limit and 10 kb for Zhao in the/home directory.
Steps:
1. Modify the line containing/home, # vi/etc/fstab, and change it to defaults and usrquota. That is, the usrquota item is added. Save and exit.
2. Uninstall the/home directory # umount/home
3. Mount/home directory # Mount/home
4. Add User Zhao # useradd Zhao
5. Change the password # passwd Zhao
6. Generate quota information about the/home directory # quotacheck-cmug/home
# Quotacheck-vu/home
7. View information of all users # repquota-Au
8. Set the quota # edquota-u Zhao
Change soft and hard to 5 and 10 respectively.
9. Save and exit # WQ!
10. modification time # edquota-T
11. # WQ!
12. Enable the disk quota function on/home # quotaon/home
13. query the quota # quota-u Zhao
14. Verify the quota # Su-zhao
$ Touch myfile
From: Http://zweitian.blog.51cto.com/59324/48823Thanks to the original author! Install, install, and uninstall basic software (assuming the software already exists in the software source)
Sudo apt-Get install/remove XXX (only one installation or other installation/uninstall operations can be performed at the same time) to view the installation content of the software XXX (software name)
Dpkg-l XXX search software
Apt-cache search regular expression to find the package of the file
Dpkg-s filename apt-file search filename queries which packages the software XXX depends on
Apt-Cache depends XXX queries which packages depend on the software xxx
Apt-Cache rdepends XXX adds a CD Source
Sudo apt-CDROM add software source update 1. Back up the original file before update
Sudo CP/etc/APT/sources. LIST/etc/APT/sources. list_backup2, edit and update the source configuration file
Sudo gedit/etc/APT/sources. List as for the software source, You can Google it. Many of them are recommended to ping it in advance and select the fastest one. Otherwise, it will take a long time. System Upgrade sudo apt-Get updatesudo apt-Get upgrade (after updating the software source, remember to update the system package list. You can use this command or the next one) sudo apt-Get dist-upgrade clears the residual configuration file of the deleted package
Dpkg-L | grep ^ RC | awk '{print $2}' | tr ["\ n"] [""] | hfile missing during sudo xargs dpkg-p-Compilation automatic Processing
Sudo auto-apt run./configure
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 Cache
Sudo apt-Get autoclean clear all software caches
Sudo apt-Get clean Delete isolated software that is no longer used by the System
View the kernel in the sudo apt-Get autoremove System
Uname-a view Ubuntu version
CAT/etc/issue
Lsmod view PCI devices
Lspci viewing USB devices
Lsusb
Sudo ethtool eth0 view CPU Information
CAT/proc/cpuinfo displays current hardware information
Lshw hard disk view hard disk 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 disk space
DF-H view the space occupied by the Directory
The Du-HS directory name USB flash drive cannot be detached.
Sync Fuser-km/Media/usbdisk memory to view the current memory usage
Free-M Process
PS-A abort a process
Kill process number (that is, the number in the first column of PS-A) or killall process name forcibly stop a process (used when the process failed to be aborted)
Kill-9 process number or killall-9 process name
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 files opened by the Process
Lsof-padsl configure ADSL
Sudo pppoeconfadsl Manual dialing
Sudo Pon DSL-provider activates ADSL
Sudo/etc/PPP/pppoe_on_boot disconnect ADSL
View dialing logs using sudo poff
Sudo plog Network
Set IP
Sudo gedit/etc/Network/interfaces restart Nic
Sudo/etc/init. d/networking restart query the NIC address based on the IP address
Arping IP address to view the current IP Address
Ifconfig eth0 | awk '/inet/{split ($2, X, ":"); print X [2]}' view the IP address of the current Internet
W3m-no-Cookie -dumpwww.ip138.com | grep-o '[0-9] \ {1, 3 \}\. [0-9] \ {1, 3 \}\. [0-9] \ {1, 3 \}\. [0-9] \ {1, 3 \}'
W3m-no-Cookie -dumpwww.123cha.com | 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 add and delete a route entry
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 # change the address
Sudo ifconfig eth0 up # then enable 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: Count the IP addresses of the current 20000 IP packets larger than 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 close a service
/Etc/init. d/service name stop start a service temporarily
/Etc/init. d/service name start set which Java is used by default for configuration
Sudo Update-alternatives -- config Java modifies 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
Sudo apt-Get install convmv-r-F cp936-T utf8 -- notest -- nosmart * batch convert 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 converts MP3 tag Encoding
Sudo apt-Get install Python-mutagen find.-INAME "*. MP3"-execdir mid3iconv-e GBK {}\; Chinese characters are displayed in the console
When using sudo apt-Get install zhcon, enter zhcon to quickly 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 reading the latest content
Tail-N 10-F/var/log/apache2/access. log to view the content of the fifth line (inclusive) to the second line (inclusive) in the middle of the file
Sed-n'5, 10p'/var/log/apache2/access. Log find files containing XXX strings
Grep-l-r xxx. Find the command about XXX
Apropos XXX man-k xxx transfers files through SSH
SCP-RP/path/filenameusername @ remoteip:/path # copy the local file to the server
SCP-rpusername @ remoteip:/path/filename/path # download a remote file from the server to a local location to view which applications read and write a file
The 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 letters.
Rename 'tr/A-Z/a-z/'* Delete files with special file names, such as file names: --help.txt
Rm -- --help.txt or RM./--help.txt
Ls-D */. Or echo */. Move the files that have been accessed in the current directory for the last 30 days to the upper-level back directory.
Find.-Type F-atime-30-exec MV {} ../back \; display the files in the current directory for the last 2 hours to 8 hours
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 {} \; The searched file does not end with Java or XML and is 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 displays the file name of in the current directory
Ls-L | grep 2006-01-01 | awk '{print $8}' compressed and decompressed xxx.tar.gz
Tar-zxvf xxx.tar.gz decompress xxx.tar.bz2
Tar-jxvf xxx.tar.bz2: compress AAA bbbdirectory as xxx.tar.gz
Tar-zcvf xxx.tar.gz aaa bbb compression AAA bbbdirectory: xxx.tar.bz2
Tar-jcvf xxx.tar.bz2 AAA bbbnautilus show hidden files
CTRL + H display Address Bar
CTRL + L special URI address
* Computer: //-all mounted devices and networks * Network: //-view 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 topic folder to view the installed font
Enter "fonts: //" in the address bar of Nautilus to view the running information of all the fonts programs on the local machine.
Strace-f-o OUTFILE Date and Time set date
# Date-s mm/DD/yy set the time
# Date-s hh: Mm writes time into CMOS
Hwclock -- systohc read CMOS time
Hwclock -- hctosys synchronize time from the server
Sudo ntpdate time.nist.gov
Switch between different consoles on The sudo ntpdate time.windows.com Console
CTRL + ALT + ↓
CTRL + ALT + → specify console switch
CTRL + ALT + FN (N: 1 ~ 7) console scrolling
Shift + Pageup/Pagedown console screenshot
Setterm-dump n (n: 1 ~ 7) Place the database Mysql Data Inventory
/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
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' others (this part is rarely used by new users like me, even on the Internet) download website documents
Wget-r-p-NP-khttp: // www.21cn.com ·-R: Create a server directory structure on the local machine; ·-P: Download and display all images of HTML files; ·-NP: only download the contents of the specified directory and its sub-directories 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 replace the shortcut key of the gnome Program
Click the menu, move your mouse over a menu, and enter any key you need on the keyboard, which can be a combination key and will take effect immediately. If you want 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 wine response speed when the startup program needs to be deleted
Sudo sed-Ie '/GBK/,/^}/D'/usr/share/X11/locale/zh_CN.UTF-8/xlc_localechgrp
[Syntax]: chgrp [-R] File Group...
[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]:
Change the file group of the file to group.
Chmod [syntax]: chmod [-R] mode file...
Or chmod [ugoa] {+ |-| =} [rwxst] file...
[Note]: changes the file access mode. The access mode can be expressed as a number or a symbol string, for example:
Chmod NNNN file, where n is a number ranging from 0 to 7, has the following meanings:
4000 uid can be changed during runtime
2000 GID can be changed during runtime
1000 stick position
0400 file master readable
0200 file master writable
0100 file master executable
0040 readable for users in the same group
0020 users in the same group can write
0010 users in the same group can execute
0004 other user readable
0002 other users can write
0001 Executable by other users
NNNN is obtained by adding the numbers in the upper column. For example, chmod 0777 file sets the file access permission to readable and executable by all users.
-R recursively changes the access mode of all files in all subdirectories.
U file master
G same group users
O other users
A All Users
+ Added the post-column permission.
-Cancel the post-column permission
= Post-column permission
R readable
W writable
X executable
UID can be set during s operation
T indicates that GID can be set during running.
[Example]:
Chmod 0666 file1 file2 sets file1 and file2 as readable and writable for all users
Chmod U + X file adds the file master executable permission to the file
Chmod o-rwx cancels all permissions of other users on file
Chown [syntax]: chown [-R] File main 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 150

 

From: http://xaunicom.spaces.live.com/blog/cns! 4f276acb8925a211! 135. Entry thanks to the original author!

========================================================== ========================

Most of the content in this article is collected and collated by the Internet. repost must ensure that this article is complete and relevant original author information and links to this article

E-mail:Khler@163.com

QQ: 23381103

MSN:Pragmac@hotmail.com

Statement: This article is mostly collected and organized by the Internet, and reposted only to disseminate knowledge, so that more people can enjoy the crystallization of wisdom.

If you have any objection, please do it nowContact me, And will be deleted immediately.

I sincerely apologize!

========================================================== ========================

 

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.