Basic Ubuntu commands

Source: Internet
Author: User
Tags domain name registration

Sudo:
How to Set/change/enable the password of the root user: sudo passwd Root
When you use sudo passwd-l root, the root account will be locked.
How to switch to the root identity in Terminal Mode: Sudo-s-h

Online installation program: sudo apt-Get install g ++
Most common Pt-GET parameters:
Update -- Update the package list with your software source (listed in/etc/APT/sources. List ).

Run
Upgrade-compare the source software library obtained by the update with the locally installed one (if you need to upgrade it)

Level
Install -- install the software package (you can use tab to complete the software package name, which is more convenient)
Remove -- uninstall the Software Package
Purge -- uninstall the software package and delete the configuration file of the software.
Source -- download the software package source code from the source to the current directory (the directory for executing this command) and decompress it (unless-

Download-only parameter)
This address is specified by the Deb-Src line in/etc/APT/sources. List.
Check -- used to (automatically) fix (installed) dependencies between software packages
Clean -- clear/var/Cache/APT/archives/cache of all software packages including its sub-directory partial/
Autoclean -- is more commonly used than clean. My understanding is to delete the cache of a lower version and keep the higher version (

Network Connection: Automatic Ethernet connection (after VMware is installed, a new Wired connection is created and deleted)

Shutdown: shutdown-H halt init 0
Restart: shutdown-r reboot init 1

View the installation content of software xxx
Dpkg-l xxx
Find the software in the software library
Apt-cache search Regular Expression
Find the software in the software library
APTITUDE search package
Find the package of the file
Dpkg-s filename
Find the package of the file
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
Add a CD Source
Sudo apt-CDROM add
System Upgrade
Sudo apt-Get update; sudo apt-Get dist-Upgrade
Clear the residual configuration file of the deleted package
Dpkg-L | grep ^ RC | awk '{print $2}' | sudo xargs dpkg-P
Automatic Processing of H files is missing during compilation
Sudo auto-apt run./configure
View the temporary directory for storing downloaded packages during software installation
Ls/var/Cache/APT/Archives
Back up the list of all packages installed in the current system
Dpkg-get-selections | grep-V deinstall> ~ /Somefile
Recover all packages from the list of backup installation packages
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 the address of the package on the server
Apt-get-QQ -- print-Uris Install SSH | cut-d \ '-F2
View the kernel
Uname-
View Ubuntu version
CAT/etc/issue or lsb_release-
View the modules loaded by the kernel
Lsmod
View PCI devices
Lspci
View USB devices
Lsusb-V
View Nic status
Sudo ethtool eth0
View CPU Information
CAT/proc/cpuinfo
Display current hardware information
Sudo lshw
Display System running time
Uptime
View Hard Disk Partitions
Sudo fdisk-l
Hard Disk Partition sudo fdisk/dev/SDA
Hard disk formatting
Sudo mkfs. ext3/dev/sda1
Hard Disk check (do not check the mounted partitions; otherwise, data is easily damaged)
Sudo fsck/dev/sda1
Partition mounting
Sudo Mount-T file system type (-o nls = utf8 or-O iocharset = utf8)
Detach a partition
Sudo umount directory name or device name
View IDE Hard Disk Information
Sudo hdparm-I/dev/hda
View stat hard disk Information
Sudo hdparm-I/dev/SDA or sudo blktool/dev/SDA ID
View the remaining disk space
DF
View space occupied by Directories
Du-HS directory name
The USB flash drive cannot be detached.
Sync; Fuser-km/Media/usbdisk
View the current read/write status of the hard disk
Sudo iostat-x 2
View Current memory usage
Free
Dynamically display process execution status
Top
View Processes
PS-
View the current process tree
Pstree
Abort a process
Kill process number or killall process name
Force stop a process
Kill-9 process number or killall-9 process name
Graphically abort a program
Xkill the mouse with the skeleton icon. Click the program to be aborted.
View files opened by a process
Lsof-P
Displays the process of opening the abc.txt file.
Lsof abc.txt
Display what programs are running on port 22
Lsof-I: 22
Displays the files currently opened by the NSD process.
Lsof-C NSD
Run the program in the background. After logging out, the program does not end.
Nohup Program &
Detailed display of program running information
Strace-f-o OUTFILE
Increase the maximum number of opened files in the system
Ulimit-N 4096 or ECHO 4096>/proc/sys/fs/file-max
Configure ADSL
Sudo pppoeconf
ADSL Manual dialing
Sudo Pon DSL-provider
Activate ADSL
Sudo/etc/PPP/pppoe_on_boot
Disconnect ADSL
Sudo poff
View dialing logs
Sudo plog
How to Set dynamic domain names
W3m-no-cookie-dump 'HTTP: // usere: pass@members.3322.org/dyndns/update?

System = dyndns & hostname = yourdns.3322.org'
Query Nic addresses based on IP addresses
Arping IP Address
Check the computer name based on the IP address
Nmblookup-a ip Address
View current IP Address
Ifconfig eth0 | awk '/inet/{split ($2, X, \ ": \"); print X [2]}'
View the IP address of the current Internet
W3m-no-cookie-dump www.123cha.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
Lsof-I: 80
View the physical address of the current Nic
ARP-A | awk '{print $4 }'
Add a second IP address for the same Nic
Sudo ifconfig eth0: 0 1.2.3.4 netmask 255.255.255.0
Enable the network to support NAT now
Echo 1 | sudo tee/proc/sys/NET/IPv4/ip_forward; sudo iptables-T nat-I postrouting

-J Masquerade
View route information
Netstat-Rn or sudo route-n
Manually add a route
Sudo route add-net 192.168.0.0 netmask 255.255.255.0 GW 172.16.0.1
Manually delete a route
Sudo route del-net 192.168.0.0 netmask 255.255.255.0 GW 172.16.0.1
How to modify the MAC address of a NIC
Sudo ifconfig eth0 HW ether 00: AA: BB: CC: DD: EE
Count the number of current IP connections
Netstat-Na | grep established | awk '{print $5}' | awk-F: '{print $1}' | sort | uniq-c |

Sort-r-n
Mask IPv6
Echo 'blacklist IPv6 '| sudo tee/etc/modprobe. d/blacklist-ipv6
View the current network connection status and program
Sudo netstat-atnp
View the current traffic of ADSL
Sudo ethstatus-I ppp0
View domain name registration information
Whois baidu.cn
View the Routing Status of a domain name
Tracepath baidu.cn
Obtain the IP address from the server again
Sudo dhclient
Download website documentation
Http://www.xxx.com of wget-r-p-NP-K
How to download data from five threads
Axel-N5 http://www.xxx.com/downloadfile.zip

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

Add users
Sudo adduser User Name
Delete a user
Sudo deluser User Name
Change the password of the current user
Passwd
Change User Password
Sudo passwd User Name
Modify user information
Sudo chfn userid
How to disable an account
Sudo usermod-l user name or sudo passwd-l User Name
How to enable an account
Sudo usermod-u user name or sudo passwd-u User Name
Add a user to the admin Group
Sudo usermod-G admin-a username

Configure which Java is used by default
Sudo Update-alternatives-config Java
Terminal setting proxy
Export http_proxy = http://xx.xx.xx.xx: XXX
Modify system logon information
Sudo Vim/etc/motd
Use Sun's Java compiler
Sudo Update-Java-alternatives-s Java-6-sun
Switch Input Method Engine
Im-switch-C
Convert the file name from GBK to utf8
Convmv-r-F cp936-T utf8-notest-nosmart *
Convert the 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'-execdir mid3iconv-e GBK

{}\\;
Display Chinese characters in the console
Sudo apt-Get install zhcon; zhcon-utf8-DRV = VGA
Lftp logon Remote Windows Chinese FTP
Lftp: ~> Set ftp: charset GBK
PDF file garbled
Sudo apt-Get install xpdf-Chinese-Simplified xpdf-Chinese-traditional poppler-Data

View File Content on one screen
Cat file name
View File Content by PAGE
More file name
View File Content by PAGE
Less file name
View part of the file based on String Matching
Grep string file name
Display the name of the file containing the string
Grep-l-R string path
Display file names that do not contain strings
Grep-l-R string path
Quickly search for a file
Find directory-name file name
Create two empty files
Touch file1 file2
Recursively create some nested Directories
Mkdir-P/tmp/xxs/DSD/EFD
Recursively Delete nested Directories
Rm-fr/tmp/xxs
Return to the current user's home directory
Cd ~
View the absolute path of the current directory
PWD
List all files in the current directory
Ls-
Move the file in the path and rename it
MV path/file/New Path/New File Name
Copy a file or directory
CP-AV original file or original directory new file or new directory
View File Types
File filename
Compare the differences between two files
Diff file1 file2
Display the last six lines of XXX File
Tail-N 6 XXX
Keep displaying the latest content
Tail-N 10-F/var/log/apache2/access. Log
View the contents of rows 5 to 10th of the file
Sed-n'5, 10p'/var/log/apache2/access. Log
Query XXX commands
Apropos xxx or man-K xxx

Transfer files through SSH
SCP-RP/path/filename username @ remoteip:/path
Change 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 a special file named -help.txt
Rm--help.txt or RM./-help.txt
View subdirectories of the current directory
Ls-D */. Or echo */.
Move the files accessed in the last 30 days to the parent back directory.
Find.-Type F-atime-30-exec MV {} ../back \\;
Display XXXX files within one hour
Find.-Type F-mmin-60 | xargs-I grep-l xx '{}'
Show files in the last 2 hours to 8 hours
Find.-mmin + 120-mmin-480-exec more {}\\;
Delete Files modified 30 days ago
Find.-Type F-mtime + 30-mtime-3600-exec RM {}\\;
Delete files created 30 days ago
Find.-Type F-ctime + 30-ctime-3600-exec RM {}\\;
Delete the file ending with Avi or RM from guest.
Find.-Name '*. avi'-o-name' *. rm '-user 'guest'-exec RM {}\\;
Delete Files Not used seven days after the end of Java and XML
Find .! -Name *. Java! -Name '*. xml'-atime + 7-exec RM {}\\;
Delete all. SVN Directories
Find.-Name. svn-type D-exec Rm-fr {}\\;
Delete all Temporary File ending
Find.-name '*~ '-Exec RM {}\\;

Count the number of current files
Ls. | WC-W
Count the number of current directories
Ls-L | grep ^ d | WC-l
Display the file name of 2006-01-01 in the current directory
Ls-L | grep 2006-01-01 | awk '{print $8 }'
Use SSH to synchronize remote data to a local directory
Rsync-pa-I-size-only-delete-Timeout = 300 remote_ip:/home/Ubuntu/backup

Added 7z compression software
Sudo apt-Get install p7zip p7zip-full p7zip-rar
Added support for RAR software compression and decompression.
Sudo apt-Get install RAR unrar
Decompress 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
Compress AAA bbbdirectory as xxx.tar.bz2
Tar-jcvf xxx.tar.bz2 aaa bbb

Added LHA support
Sudo apt-Get install LHA
Added support for resolving CAB files
Sudo apt-Get install cabextract

Show Calendar
Cal
Set date
Date-s mm/DD/yy
Set Time
Date-s hh: mm
Write time to CMOS
Hwclock-systohc
View CMOS time
Hwclock-show
CMOS read time
Hwclock-hctosys
Synchronize time from the server
Sudo ntpdate ntp.ubuntu.com
Set the computer time zone to Shanghai
Sudo CP/usr/share/zoneinfo/Asia/Shanghai/etc/localtime
Disable UTC and write the current time to CMOS.
Sudo sed-ie's/UTC = Yes/UTC = No/G'/etc/default/RCS; sudo hwclock-systohc

Modify the root password of MySQL
Sudo mysqladmin-u root-P password 'your new password'
How to Use the command to disable the monitor
Xset dpms force off
Set the CPU frequency
Sudo apt-Get install cpufrequtils; sudo cpufreq-Info

Command Shutdown
Sudo halt
Shutdown now
Sudo shutdown-H now
Automatic shutdown
Sudo shutdown-H 23:00
Shut down 60 minutes later
Sudo shutdown-H + 60
Command to restart the computer
Sudo reboot
Restart your computer now
Sudo shutdown-R now
Close notebook touchpad

Synclient touchpadoff = 1
Enable notebook touchpad
Synclient touchpadoff = 0
Count and sort the frequency of each word
Awk '{arr [$1] + = 1} end {for (I in ARR) {print arr [I] \ "\ t \" I} 'file_name | sort-Rn
Collect and sort port 80 connections
Netstat-Na | grep: 80 | awk '{print $5}' | awk-F: '{print $1}' | sort | uniq-c | sort-R

-N
Add the terminal to the right menu
Sudo apt-Get install Nautilus-open-Terminal
How to delete the playback history of a totem player
Rm ~ /. Recently-used
How to display color characters in VIM
Sudo CP/usr/share/Vim/vimcurrent/vimrc_example.vim/usr/share/Vim/vimrc
Let Vim directly support editing. GZ files
Sudo apt-Get install vim-full
How does Vim display row numbers?
: Set number
View the Startup Program in the session settings
Ls ~ /. Config/autostart
Improve wine response speed
Sudo sed-Ie '/GBK/,/^}/D'/usr/share/X11/locale/zh_CN.UTF-8/xlc_locale
Create an ISO file
Mkisofs-O test. iso-jrv-V test_disk/home/Carla/

10 seconds to capture images
Gnome-screenshot-D 10
5 seconds to capture the current activation window
Gnome-screenshot-w-D 5
How to burn data using command lines
Cdrecord-scanbus; cdrecord-v-eject speed = 8 Dev = 1, 1, 0 test. ISO
Where is the recycle bin?
~ /. Local/share/trash/
Where is the configuration file opened by default?
~ /. Local/share/applications/mimeapps. List
How to view HTTP headers
W3m-dump_head http://www.xxx.com
Continuously monitor memory usage
Watch-D free
How to switch to the root account
Sudo-HS

Read-Only mounting of NTFS partitions
Sudo Mount-t ntfs-o nls = utf8, umask = 0/dev/sdb1/mnt/C
Writable mounting of NTFS partitions
Sudo Mount-T ntfs-3g-O locale = zh_cn.utf8, umask = 0/dev/sdb1/mnt/C
Mount FAT32 partitions
Sudo Mount-T vfat-O iocharset = utf8, umask = 0/dev/sda1/mnt/C
Mount shared files
Sudo Mount-T smbfs-O username = xxx, password = xxx, iocharset = utf8 // 192.168.1.1/share

/Mnt/share
Mounting ISO files
Sudo Mount-T iso9660-o loop, utf8 XXX. ISO/mnt/ISO
Display the file content with a line number
NL file name
Convert rmvb to Avi in batches
For I in *; do mencoder-OAC mp3lame-lameopts VBR = 3-OVC XviD-xvidencopts

Fixed_quant = 4-of AVI $ I-o 'echo $ I | sed-E's/rmvb $/AVI/''; done
Convert SVG to PNG in batches
For I in *; do inkscape $ I-export-PNG = 'echo $ I | sed-E's/SVG $/PNG/''; done
Batch scale down images to 30%
For I in *; do converter-resize 30% x30 % $1 Sm-$1; done
Batch convert JPG to PNG
For I in *; do convert $ I 'echo $ I | sed-E's/jpg $/PNG/''; done
Get JPG extension information (EXIF)
Identify-verbose xxx.jpg
View All listening ports of the current system
NC-ZV localhost 1-65535
Remove ^ m from the file
Cat filename | tr-d \ "^ m \"> newfile
Remove ^ m from the file
Sed-e \ "S/^ m // G \" FILENAME> newfile
Convert bin/cue to ISO file
Sudo apt-Get install bchunk; bchunk image. Bin image. Cue Image
Convert directory to ISO file
Mkisofs dirname-O isofile. ISO
Convert CD to ISO file
Dd If =/dev/CDROM of = isofile. ISO
Ape to FLAC
Sudo apt-Get install FLAC shntool; shntool split-T \ "% N. % P-% t \"-F example_utf-

8. Cue-o flac example. Ape-D flacoutputdir
Ape to MP3
Sudo apt-Get install FLAC shntool lame; shntool split-T \ "% N. % P-% t \"-F

Example_UTF-8.cue-O 'cust ext = MP3 lame-r3mix-B 320-quiet-% F' example. Ape

-D mp3outputdir
Check for local security risks
Sudo apt-Get install rkhunter; rkhunter-checkall
How to install anti-virus software
Sudo apt-Get install ClamAV; clamscan-R ~ /
View network connection status
Netstat-N | awk '/^ TCP/{++ s [$ NF]} end {for (a in S) print a, s [a]}'
Memory consumption of the statistical program
PS-EO fname, RSS | awk '{arr [$1] + = $2} end {for (I in ARR) {print I, arr [I]} '| sort-K2

-NR
Display current memory size
Free-M | grep \ "mem \" | awk '{print $2 }'
Process by memory from large to small
PS-EO \ "% C: % P: % Z: % A \" | sort-K5-NR
Process by CPU utilization from large to small
PS-EO \ "% C: % P: % Z: % A \" | sort-NR
Measure the size of all JPG files in the current directory.
Find. -name *. jpg-exec WC-C {}\\; | awk '{print $1}' | awk '{A + = $1} end {print }'
Clear dead processes
PS-eal | awk '{if ($2 = \ "Z \") {print $4}' | sudo kill-9
CD captured on MP3 (lossy)
Sudo apt-Get install ABCDE; ABCDE-O MP3-B
CD: FLAC (lossless)
Sudo apt-Get install ABCDE; ABCDE-o flac-B
Displays the statistics of the system installation package.
Apt-Cache stats
Display the names of all available packages of the system
Apt-Cache pkgnames

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.