Ubuntu Terminal command Encyclopedia, Linux Command Encyclopedia __linux

Source: Internet
Author: User
Tags memory usage ide hard drive
Objective

Most of the following commands need to be entered under console/terminal/shell.

Console, terminal, and shell mean the same thing--a command-line interface that he can use to control the system.

To open a console:

Application--> Attachment--> Terminal

Any command that uses ' sudo ' as a prefix requires administrator (or root) access. So you will be prompted to enter your own password.

Install upgrade
View Software XXX Installation content
dpkg-l xxx

Find software in a software library
Apt-cache Search Regular Expression
Or
Aptitude Search Package

Display statistics for system installation packages
Apt-cache Stats

Displays the name of all available packages for the system
Apt-cache Pkgnames

Display the package information
Apt-cache Show k3b

Find out which package the file belongs to
Apt-file Search filename

To see which packages have been installed

Dpkg-l

Query software xxx depends on which packages

Apt-cache depends xxx

Query software XXX is dependent on which packages

Apt-cache rdepends XXX

Add a CD source

sudo apt-cdrom add

System upgrades

sudo apt-get update (This step updates the package list)

sudo apt-get dist-upgrade (Install all available updates in this step)
Or
sudo apt-get upgrade (This step installs application updates, does not install new kernels, etc.)

Clear the remainder profile for all deleted packages

Dpkg-l |grep ^rc|awk ' {print $} ' |sudo Xargs dpkg-p

If you report the following error, it is not necessary to worry that there is no residual configuration file in your system.

Dpkg:--purge needs at least one package Name argument

Type dpkg--help for help about installing and deinstalling packages; Use the ' dselect ' or ' aptitude ' for user-friendly package management;
Type Dpkg-dhelp for a list of dpkg debug flag values;
Type dpkg--force-help for a list of forcing options;
Type dpkg-deb--help for help about manipulating *.deb files;
Type dpkg--license for copyright license and lack of warranty (GNU GPL).
Options marked produce a lot of output-pipe it through ' less ' or ' more '!
Lack of automatic processing of H files at compile time

sudo auto-apt run./configure

View the temporary storage directory for downloading packages when installing software

Ls/var/cache/apt/archives

Back up the list of all packages currently installed on the system

Dpkg--get-selections | Grep-v deinstall > ~/somefile

Recover all packages from the list file of the installation package backed up above

Dpkg--set-selections < ~/somefile
sudo dselect

Cleaning up older versions of the software cache

sudo apt-get AutoClean

Clean up all software caches

sudo apt-get clean

Remove orphaned software that the system no longer uses

sudo apt-get autoremove

View the address of the package on the server

APT-GET-QQ--print-uris Install SSH | Cut-d\ '-f2

Remove Gnome completely

Apt-get--purge Remove Liborbit2

Completely remove KDE

Apt-get--purge Remove LIBQT3-MT libqtcore4

System
View Kernel

Uname-a

View Ubuntu version

Cat/etc/issue
or cat/etc/lsb-release
or lsb_release–d–s–c

View modules loaded by the kernel

Lsmod

View PCI Devices

Lspci

View USB Devices

Lsusb

#加参数-V can display a description table of USB devices (descriptors)
Lsusb-v

View NIC Status

sudo ethtool eth0

View CPU Information

Cat/proc/cpuinfo

Display current hardware information

sudo lshw

Show current memory size

Free-m |grep "Mem" | awk ' {print $} '

View hard disk temperature

sudo apt-get install hddtemp
sudo hddtemp/dev/sda

Show system Run time

$ uptime
11:47:04 up, 2:10, 1 user, load average:2.40, 2.18, 2.34

Hard disk
View partitions of the hard disk

sudo fdisk-l

Hard Disk partitions

#危险. Careful operation.
sudo fdisk/dev/sda

Hard disk Format

#危险. Format the first partition as a ext3 partition, Mkfs.reiserfs mkfs.xfs Mkfs.vfat
sudo mkfs.ext3/dev/sda1

Hard drive Check

#危险. Check the first partition, do not check the partitions that are already mounted, or you will easily lose and corrupt data
sudo fsck/dev/sda1

Partition mount

sudo mount-t file system type device path access path
#常用文件类型如下: iso9660 Optical Drive file system, VFAT FAT/FAT32 partition, NTFS NTFS partition, SMBFS Windows network share directory, ReiserFS, ext3, XFS Linux partition
#如果中文名无法显示尝试在最後增加-O Nls=utf8 or-o Iocharset=utf8
#如果需要挂载後, normal users can also use the back of the-o parameter to increase, umask=022 such as:-O nls=utf8,umask=022

Partition Uninstall

sudo umount directory name or device name

Read-only mount NTFS partitions

sudo mount-t ntfs-o nls=utf8,umask=0/dev/sdb1/mnt/c

Writable mounted NTFS partitions

sudo mount-t ntfs-3g-o locale=zh_cn.utf8,umask=0/dev/sdb1/mnt/c

Mount FAT32 Partition

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

Mount ISO file

sudo mount-t iso9660-o Loop,utf8 xxx.iso/mnt/iso

View IDE Hard drive information

sudo hdparm-i/dev/hda

View Soft RAID Array information

Cat/proc/mdstat

Refer to Hard RAID array information

DMESG |grep-i raid
Cat/proc/scsi/scsi

View SATA Hard Drive information

sudo hdparm-i/dev/sda
Or
sudo apt-get install Blktool
sudo blktool/dev/sda ID

View the hard drive remaining space

Df

Usage: DF [options] ... [File] ... Displays information about the file system where each < file > resides, by default, by displaying all file systems.

Parameters that must be used with long options are also required when using short options.
-A,--all includes a file system with a size of 0 blocks
-B,--block-size= size block in bytes specified < size >
-H,--human-readable print file system size in an Easy-to-understand format (e.g. 1K 234M 2G)
-H,--si is similar to-H, but takes 1000 of the second party instead of 1024
-I,--inodes display inode information rather than block usage
-K is--block-size=1k
-L,--local only displays the file system of this machine
--no-sync do not synchronize before obtaining usage data (default)
-P,--portability uses a POSIX-compliant output format
--sync to get the usage data before the synchronization action
-T, the--type= type prints only the information specified in the file system for the specified < type >
-T,--print-type print file system type
-X, the--exclude-type= type prints only the file system is not the specified < type > information
-V (ignored)
--HELP Display this help information and leave
--version display version information and leave

To view the space occupied by the directory

DU-HS Directory Name

USB flash drive can't unload

Sync
Fuser-km/media/usbdisk

Use files to increase swap space

#创建一个512M的交换文件/swapfile
sudo dd if=/dev/zero of=/swapfile bs=1m count=512
sudo mkswap/swapfile
sudo swapon/swapfile
#sudo Vim/etc/fstab #加到fstab文件中让系统引导时自动启动
/swapfile Swap Defaults 0 0

View the current read/write status of the hard disk

# First Install Sysstat package
sudo apt-get install Sysstat
#每2秒刷新一次
sudo iostat-x 2

Process
To view current memory usage

Free

Usage:free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c Count] [-v]

-b,-k,-m,-g show output in bytes, KB, MB, or GB
-L Show detailed low and high memory statistics
-O use old format (no-/+buffers/cache line)
-t display total for RAM + swap
-s update every [delay] seconds
-c update [count] Times
-V Display version information and exit

Continuous monitoring of memory usage

watch-d Free
# use Ctrl + C to exit

Dynamic display of Process execution

Top
The top command enters H or when running. Open the Help window and enter the Q exit directive.

See what processes are currently

Ps-afl

The memory consumption of the statistic program

Ps-eo Fname,rss|awk ' {arr[$1]+=$2} end {to (I in arr) {print i,arr[i]} ' |SORT-K2-NR

Arrange processes by memory from large to small

Ps-eo "%c:%p:%z:%a" |sort-k5-nr

Arrange processes from large to small by CPU utilization

Ps-eo "%c:%p:%z:%a" |sort-nr

View the current process tree

Pstree

Abort a process

Kill process Number (is the number of the first column in the ps-a)
or killall process name

Force abort a process (used when the above process abort is unsuccessful)

Kill-9 Process Number
or killall-9 process name

Graphical way to abort a program

Xkill appear skull Mark Mouse, click Need to abort the program can

To view files opened by the process
PID of Lsof-p Process

Shows the process of opening a file abc.txt
Lsof Abc.txt

Show 22 Ports What programs are running now
Lsof-i: 22

Show the file that the NSD process is now open
Lsof-c NSD

Running the program in the background, after exiting the login, does not end the program

Nohup Program &
#查看中间运行情况 Tail Nohup

To display the running information of a program in detail
Strace-f-f-o outfile <cmd>

Increase the number of system maximum open files
echo 4096 >/proc/sys/fs/file-max
#或者
Ulimit-n 4096

Clear Zombie Process
Ps-eal | awk ' {if ($ = = ' Z ') {print $}} ' | Xargs sudo kill-9

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.