1.df Command
# df-ha
Show the use of all files and partitions
# df-h/DEV/SDA1
Show SDA1 disk usage
# df-t
Displays the file system name belonging to each partition. The format type of the zone (for example, ext3)
Note: The H-parameter representation is converted to M. G and other people often use disk space units display
2.du Command
# du-h SRC
Displays the disk space occupied by individual files (or files) in the SRC folder
# DU-HS/USR
Displays the total size of all files in the USR folder
# du-h TEST.c
Displays the disk space occupied by the test.c file
3.dd Command
DD is a very useful command under Linux/unix, which is to copy a file with a block of the specified size and make the specified conversion at the same time as the copy.
# DD If=/dev/hdb | gzip >/root/image.gz
Backup/DEV/HDB the overall data. and use the Gzip tool for compression. Save to specified path
Note: "|" Represents a pipe command, which means "|" The left execution result is the input condition or range to the right. such as: History | grep date refers to a command that includes a "date" in the results from the history command execution
# Gzip-dc/root/image.gz | DD Of=/dev/hdb
Restores a compressed backup file to a specified disk
# dd If=/dev/fd0 of=disk.img bs=4m
Backup floppy disk. Block size of Read and write is 4M
4.# uname-a
View the Ubuntu version number
5.cat Command
# cat-n TEST.c
Displays the contents of the entire test.c and numbers the contents by row
6.lsmod Command
# Lsmod
Show all modules loaded in the kernel
# Lsmod | grep MPTSPI
Displays all modules loaded by the kernel including MTPSPI
7.# Lsusb
View USB Devices
8.# Cat/proc/cpuinfo
View the status of the CPU
9.# lshw
View hardware Information
10.# fdisk-l
To view disk information
# FDISK/DEV/SDA
Operate on disk SDA (note that not sda1,sda1 is a partition of SDA) and include the new partition. Delete the partition, etc., followed by the prompt option.
11.# free-m
View current Memory usage
12.# ps-a
See which processes are currently on the system
13.# Kill Process Number
Abort a process
14.# kill-9 Process number
Forces a process to abort. Can use when the kill process number is unsuccessful
15.# Top
View the real-time status of the current process
# top-p 786
Real-time execution status of process with process number 786 displayed
16.ifconfig Command
# ifconfig
Display information about the NIC
# ifconfig eth0 up
Open eth0 NIC
# ifconfig eth0 Down
Turn off the eth0 NIC
# infonfig Eth0 192.168.1.1
Set the IP address of eth0 to 192.168.1.1
17. Start the Stop service command
#/etc/init.d/Service Name Restart/stop/start
Restart/stop/start a service
18.# whereis file name
Find a file at high speed
19.# Find folder-name file name
Find files in a folder for a file name
Find-name ' *fb* '
Look for files in the current folder that contain the words "FB" in the file name
Find/usr-name ' *fb* '
Find files with the word "FB" in the file name under the/USR folder
20.# tail-n 6 file name
Assume that the value is preceded by A + (plus sign). Writes a file to standard output starting at the number of cells specified at the beginning of the file. Suppose the value is preceded by a-(minus sign). The file is written to standard output starting at the number of cells specified at the end of the file. Suppose the value is preceded by A + (plus sign) or-(minus sign). Then read the file from the unit number specified at the end of the file.
# tail-n 6 File name = = # tail-n-6 file name
21.grep Command
# grep ' Test ' d*
Displays the lines that contain test in all files that begin with D.
# grep ' Test ' AA bb cc
Displays the line in the AA,BB,CC file that matches test.
# ls |grep d*
Displays the content that begins with D in the LS command result.
grep ' REQUEST_IRQ ' *-r
Finds all files under the current folder, including the contents of the "REQUEST_IRQ" string in the folder,-R means recursive lookup
grep ' Request_irq ' kernel-r
Represents a lookup in the kernel folder
22.hostname command
# hostname
View the host name.
# hostname ABC
Change the host name to ABC. Fails after reboot.
# Vim/etc/hostname
Permanent changes to the host name. Save and exit when you are finished editing.
23.LSHW command
# Lshw-short
View the hardware configuration of the host.
24.apt-get command
# Apt-get Install Vim
Install the VIM editor.
25.PWD command
# pwd
Displays the parent folder.
26.CD command
# CD/USR
Go to the/usr folder.
# CD ~
Go to the home folder of the current user.
27.ls command
# ls-l
Displays all of the files under the current folder (not including hidden files).
# Ls-al
Displays all files (including hidden files) under the current folder.
Note: the-l and-a represent an abbreviated option, assuming that-the full name of the optional option is required. Like--help.
28.echo command
# echo $LANG
Displays the languages supported by the current system.
# Lang=en_us
The change language is English (Chinese is zh_cn. UTF-8).
29.# BC
Bring up the calculator, enter sacle=3 to set the number of decimal places to 3 digits, enter quit and exit the calculator.
30.exit command
# exit
Close the middle. The effect is equivalent to pressing CTRL+D.
31. See how many instructions you have in common
#
Do not enter anything, simply press the TAB key two times in a row. are displayed.
32. Switch to Super User:
# sudo-s
Switch from Superuser to normal User:
# exit
33.# Find/-name test.c
Under the root folder, look for files with file names called TEST.c.
# which test
Find a running file. The file name according to the executable file. The ability to use this command to determine which folder to use is the command.
34. Open a new terminal in the terminal
Hold Shift+ctrl+n
Exit a terminal
# exit
35.ubuntun Connection USB flash drive
Today's Ubuntu systems are typically mounted on their own, assuming you're plugged into a USB flash drive. And Ubuntu does not have its own initiative to mount the words, then it needs to be manually mounted.
# Fdisk-l//view the drive letter of the U-disk. After the U-disk is connected, Ubuntu can recognize it, but it can't be opened without a mount.
# MKDIR/MNT/USB//Build mount point, of course, can also hang in an existing directory
# mount-t VFAT/DEV/SDB/MNT/USB//Mount command
Unloading the U-disk
# Umount/mnt/usb//mount+ Mount folder
Note: After unloading, it is generally safe to unplug the USB stick.
36.cd ~ (or just a simple input CD) goes back to the user's home folder, which depends on what user you are logged into. Assume that you are logged in as root, after running this command, go back to the/root/folder, assuming that the other users, such as the record, it is back to the/home/folder,!! Is the result of running and displaying the previous command.
37. Open a new terminal
Ctrl+alt+t
38. View System Permissions Mask
# umask-s
39. Pipeline Command The
Pipeline command operator is: "|", which can only handle the correct output from the previous instruction, that is, the standard output information, for stdandard error information does not have direct processing power. And then. Passed to the next command as standard input.
Note:
A, the pipeline command only handles the correct output of the previous command. Error output
B, Pipeline command Right command is not processed. You must be able to receive the standard input stream command.
Instance:
Cat test.sh | Grep-n ' echo '
#读出test. sh file contents, forwarded to grep as input via pipeline
40. REDIRECT Command:>, <, >> (for append content)
The difference between a redirect command and a pipeline command:
1, the left command should have standard output | The command on the right should accept the standard input
The command on the left should have standard output > right can only be a file
The command on the left should require the standard input < The right can only be a file
2, Pipeline trigger two sub-process run "|" On both sides of the program, and redirects are run within a process
41.tar command
The TAR command has 4 functions, such as packaging, unpacking, compressing and decompressing, and there are two types of compression and decompression methods that are used frequently: gzip and bzip2. Files that end with ". Gz", ". Z" are compressed by gzip, and files ending with ". bz2" are compressed in bzip2 manner, with the word "tar" in the suffix, which indicates that this is a compressed file package.
The TAR command has 5 frequently used options:
(1) "C": Indicates creation, used to generate package.
(2) "X": Indicates extraction. Extract the files from the package.
(3) "Z": Processed using gzip, which is combined with "C" to indicate compression. Combined with "X" means decompression.
(4) "J": Processed using the Bzip2 method. It is combined with "C" to represent compression, and "X" is combined to represent decompression.
(5) "F": Indicates the file. You need to follow a file name later.
Examples:
(1) Make a folder Dira as a compressed package.
#tar czf dirA.tar.gz dira//Dira compressed to dirA.tar.gz in gzip mode
#tar CJF dirA.tar.bz2 dira//Dira compressed to dirA.tar.bz2 in bzip2 manner
(2) Unpack a compressed package file.
#tar XZF dirA.tar.gz//Unzip the file and unpack it in the current folder using gzip
#tar XJF dirA.tar.bz2//Extract files and packages in bzip2 mode under current folder
#tar xzf dira.tar.gz-c <dir>//Extract the files to the <dir> folder
#tar XJF dira.tar.bz2-c <dir>//Extract the files to the <dir> folder
42.diff and Patch commands
Diff commands are often used to compare files and folders, and can also be used to make patch files. So-called "patch Files". Is the difference between the "modified file" and the "original file".
The diff command frequently uses options such as the following:
(1) "-U": Indicates that some of the same rows are in the output context in the comparison results, which facilitates manual positioning.
(2) "-R": Represents a recursive comparison of files under individual subfolders.
(3) "-N": The nonexistent file is treated as an empty file.
(4) "-W": Ignores the comparison of whitespace.
(5) "-B": ignores the comparison of empty rows.
For example, if the linux-2.6.22.6 folder is the original kernel. Linux-2.6.22.6_ok folder is a changed kernel, can use the following command to make patch file Linux-2.6.22.6_ok.diff (original folder before, changed folder after).
#diff-urnwb linux-2.6.22.6 linux-2.6.22.6_ok > Linux-2.6.22.6_ok.diff
Since linux-2.6.22.6 is a standard code that can be downloaded freely from the Internet, it is only necessary to provide patch files Linux-2.6.22.6_ok.diff (usually smaller patches) to publish changes made in LINUX-2.6.22.6_OK.
Patch commands are used for patching-the original files are changed according to the patch file. For the example above, you can use the following command to apply the patch file Linux-2.6.22.6_ok.diff to the original folder linux-2.6.22.6 up (if linux-2.6.22.6 and linux-2.6.22.6_ Ok.diff in the same folder).
#cd linux-2.6.22.6
#patch-p1 <. /linux-2.6.22.6_ok.diff
The most important option in the patch command is "-PN": the path to the file to be changed is indicated in the patch file, and "-PN" indicates that the folder before the nth slash in the path is ignored. If the following lines are in the Linux-2.6.22.6_ok.diff:
DIFF-URNWB linux-2.6.22.6/a/b/c.h linux-2.6.22.6_ok/a/b/c.h
---linux-2.6.22.6/a/b/c.h 2007-08-31 02:21:01.00000000-0400
+ + + linux-2.6.22.6_ok/a/b/c.h 2007-09-20 18:11:46.00000000-0400
... ...
When patching with the above command, the patch command looks for the source file according to "Linux-2.6.22.6/a/b/c.h", "-p1" means that the folder before the 1th slash is ignored, so the source file to be changed is the current folder: A/b/c.h.
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Ubuntu frequently used command summary