Common Commands under Linux

Source: Internet
Author: User
Tags bz2 create directory diff gz file sybase time and date pkill

============= mount and login command ======================================== reprint

Mount: Mount command. For example, mount the optical drive Mount/dev/cdrom/mnt/cdrom, you can view the contents under the directory/mnt/cdrom, you want to exit the disc, you must use the Umount command, otherwise the optical drive will remain in the deadlock state: #umount/mnt/cdrom. You can also mount the drive letter, such as Mount-t vfat/dev/uba1/mnt, you can switch to/mnt directory to view the content under Uba. Direct input to mount will display FS that has been mounted, displaying the contents by the following types: File system name mount point type, for example:

Rootfs/rootfs ro,relatime 0 0
Tmpfs/dev Tmpfs rw,nosuid,relatime,mode=755 0 0
Devpts/dev/pts devpts rw,relatime,mode=600 0 0
PROC/PROC proc Rw,relatime 0 0
Sysfs/sys Sysfs rw,relatime 0 0

Umount: Uninstall command, such as Umount/dev/cdrom, or umount/mnt.
Exit: Exit the terminal command.

Shutdown: Shut down the Linux system and add parameters later, such as shut down.

Reboot: Restart Linux.

Halt: Hangs the system but does not shut down.

Chsh: Change the shell that logged into the system.

TTY: Displays the file name of the terminal connection standard input device.
============= File Processing command ========================================

mkdir: Create directory. Mkdir-p XXX can create a multi-level directory, even if the directory path does not exist, can be conveniently used in some situations.

LS: Displays the current directory contents. The Add parameter path can display the specified directory contents, plus-l displays the details of the files in the directory, such as permissions. Add |more to display the directory file information, enter follow-up, Shift+page up/down page. Execution: ls-l/dev can display all the device details that are loaded under the current system, including the main device number and the secondary device number, if some files do not see the primary and secondary device number, and the first display DRW ..., which indicates that the file is a directory and that the directory can display multiple device information belonging to that class.

The most commonly used Ls-la are described below:

Drwxr-xr-x 3 Wangpeng wangpeng 4096 2011-09-20 19:58 Dummy

D for the directory, rwxrwxrwx for 9 permission settings, 3 for the number of files, Wangpeng Wangpeng on behalf of the user group, 4096 for the size, followed by the file setup time, and finally the filename.

Displays the number of files under the current folder, using Ls-lr|grep "-" |wc-l.

Recursively displays the relevant file information and paths under current and sub-directories, using LS-R.

Du: Displays the specific file size. Some folders are very large, you can use the Du-sk directory name, display the detailed space size. Du-sh is similar in meaning, but it is more intuitive to display the size in integer units.

RM: Delete the directory or file. Add parameter-rf Force recursion to delete a non-empty directory. For example, to delete the target file under the current file recursively, using: Find. -name "*.O" | Xargs RM-RF. Recursively delete the. SVN directory under the current directory, with find./-type d-name. SVN | Xargs RM-RF. Exclude a directory or file when deleting files, RM-RF! (kernel.img), in parentheses is the file name or directory name, is the directory name does not need to add/.

CD: Enter a directory. Add parameter to indicate path,/represent Linux root directory, CD ~ Return to user directory under home; CD. Return to the upper directory; CD-indicates that the directory before the switch directory is returned.

CP: Copy command. CP 1.txt usr/local/arm Copy the 1.txt file to the destination directory. Cp-r Dir1 Dir2 is used to copy directories, copy directories Dir1 to the DIR2 directory (dir1 copy), and Dir1 dir1 cp-r if you do not want to copy dir1/* with only DIR2 content.

-A: equivalent to the meaning of-pdr; D: If the source file is the attribute of the linked file, the link file property is copied instead of the file itself;-P: Copy the past with the attributes of the archive, not the default properties; Cp-rt >/dev/null $cust _dir /vendor/vendor/mediatek/product/2>&1,dev/null is an empty device, what content is not, generally used as emptying data; 2>&1,0 or 1 The General Convention is to return success, 2 is a failure, This means that both errors and successes flow to the null device.

CP xxx.h XXX.C The H file is copied to the C file and the contents of the two files are the same.

./: Executes the current directory application, followed by the application name to make parameters.

Cat: View the contents of a file followed by the file name directly. You can also view the Linux kernel version cat/proc/version, cat/proc/meminfo view the memory information, cat/proc/asound/cards view the sound card information; cat/proc/kmsg through ADB Shell print kernel information; cat/proc/interrupts view interrupt assignment information. Another feature is redirection, such as the cat > file name, which redirects the cat output to a file that is behind > and overwrites the file .

MORE: Similar to cat, but will be a page-by-page display to facilitate users to read pages, and the most basic instruction is to press the blank key (space) on the next page, press the B key will be back (back) a page display.

The use of the less:less command is similar to the more command and can be used to browse over a page of files. The difference is that the less command, in addition to pressing the SPACEBAR to display the file down, can also use the up and down keys to scroll the file. When you want to end the browsing, simply press the Q key under the ":" Prompt in the less command.
Mkdir: Create Directory command. such as MkDir dirname, a directory named after DirName is created under the current directory, or the next level directory under an existing directory path cannot be created at one time.

diff: The function compares two text files on a line-by-row basis, listing how the differences are consistent. For example: diff file1 File2, get n1,n2 C n3,n4. Where n1n2 refers to a number of lines in the first file, n3n4 refers to a number of rows in the second file. The middle letter A means add, d means delete, C refers to the modification.

Make Menuconfig: The graphical interface configures the system kernel parameters.

MV: Move or rename a file or directory. MV name1 PPP, rename name1 to PPP;MV name1/usr/move the file to the target directory.

Rename: Batch rename, rename ' S/tt hh/uu/' tt*, convert the TT HH character to the UU character at the beginning of the TT file.

Apt-get: Used to automatically find the installation software, update software, generally require root permissions. So the format is sudo apt-get install (installation), sudo apt-get remove (uninstall), sudo apt-get upgrade (upgrade). If the xx file is missing when compiling, you need to re-download the Linux kernel and use apt-get install Linux-source.

Add-apt-repository: The script adds the PPA to the current library, and then update it to install the desired software. For example: sudo add-apt-repository ppa:ailurus,sudo apt-get update,sudo apt-get Install Ailurus

Find: Finds files. The format is: Find. -name "*.java", where. Represents the current directory,-name represents a lookup by name, * that is, a wildcard character. You can use it to complete the operation of recursively deleting the SVN directory: find Xxxx-name SVN | Xargs RM-RF

grep: Find commands, including library files or the contents of compressed files can also be found. For example: Find./out/-name ' *.jar ' | Xargs grep ' afdatacallback ', meaning to find the jar library that contains the callback.

Fgrep: A global find command, such as a specific text string, to find specific string literals in all text in a specific directory: Fgrep "Unable to install HW params" external/alsa-lib/*-R. Similar to grep functionality. Similar to command: Find. /.. /kernel/-name "*.c"-exec grep-hn "GET_CUST_ALSPS_HW" {} \; (semicolon must add, tell-exec parameter to end)
|: Pipe command, usually the output of the left command of the pipeline is then entered as a command on the right side of the pipe.

Head: View the first few lines of the file, such as the first five head-5/etc/passwd of the file.

Tail: View the following lines of the file, such as viewing the following 10 lines of the file tail-10/etc/passwd.

Alsa_aplay: Play Test sound command, Alsa_aplay xxx.wav.

Alsa_amixer: Mixer information and commands.

Alsa_alsactl:alsa control.

Arecord: The plus-l parameter lists the current digital audio device, plus-l lists the current PCM device. arecord-d Device name Xxx.wav can be recorded.

LDD:LDD is not an executable program, but just a shell script, LDD shows the operation of the module dependency, the essence of which is through the ld-linux.so (Elf Dynamic Library loader) to achieve. For example: $ LDD a.out, the module dependency information such as linux-gate.so.1=> (0xb802b000) is displayed.

LN: Its function is to create a different link for one file in another location, without having to use disk space repeatedly. The most common parameter for this command is-s, which is the Ln-s source file destination file. For example: Ln-s/bin/less/usr/local/bin/less. Here are two points to note: first, the LN command will maintain the synchronization of each linked file, that is, no matter where you change, the other files will change the same; second, ln links and soft links and hard links two, soft link is ln-s * *, It will only generate a mirror image of a file in the location you selected, does not occupy disk space, hard link ln * *, no parameter-s, it will generate a file of the same size as the source file at the location you selected. It's useful: Also if you are on a new HDD Ubuntu system to hook up the old hard disk, and want to use the old hard disk data, if the old hard disk file system is/DEV/SDB1, mounted in/media/ D57949BF-2263-4BA3-A102-A25F8FFBF6C3, with Ln-s/home/liwei/media/d57949bf-2263-4ba3-a102-a25f8ffbf6c3/home/liwei (not verified).

Strace: Tracks system calls and received signals when the program executes. For example: Strace./a.out

Arm-linux-readelf: Displays information about an elf file. including dependent libraries, compiling machines, and so on. The format is: arm-linux-readelf-option xxx.

Touch: Update the file's access time and modification time to the current system time. For example: Touch/root, modify the access time and modification time of each file under the root directory to the current. You can also create a file, such as Touch test.cpp, to create a CPP text.

Sed: View some rows in a hit file. For example: Sed-n ' 45,50p ' kd_imgsensor_define.h, which is to look at 45 to 50 lines in a file.

Echo: Terminal Print command or output, such as echo "Hello World" >readme.txt, create a text file with content. echo "Git is cool" >>readme.txt, add another line at the end of the file. Also used to show whether the current login is bash or sh, such as Echo $SHELL, echoing/bin/bash.

md5sum: Generates a MD5 checksum for a file. For example: Md5sum-b update.zip >md5sum

Zip command: Package command, do not compress. Zip packages.zip update.zip md5sum, pack the latter two into Packages.zip. The zip format is decompressed with the unzip command.

WC: Count the number of rows, words, and bytes in the specified file. For example, the result is 1 4 minicom.log. -L Returns the number of rows, such as Cat/proc/cpuinfo | grep Processor | Wc-l feedback the current CPU core count.

AR: Create or modify a saved file, or extract files from a saved file. With parameter-x: Extracts a member from a library. If you do not specify a module to extract, all modules in the library are extracted. For example Ar-x SSS.A, you can release a number of. o files.

============= System Administration Command ========================================

PWD: Displays the full current working directory.

Source: Typically used to re-execute a newly modified initialization file for immediate effect without having to log off and log back on, for example, after modifying the play environment variable configuration, run source ~/.BASHRC.

LS Dev: Displays the system device.

Top: Displays resource status, similar to XP's resource manager.

Free: Displays system memory usage, including real memory and swap swap. The plus-m representation is in M bytes. In view of the large memory now, swap is rarely used and can not be allocated.

At: Performs a specific action at a specified time.

AddUser: Add a user in the home directory, multi-use. Generally not useradd, usage: Useradd Zhangcheng, it is strange to add the first directory is invisible.

Userdel: Delete a user, Userdel xxx

passwd: Add a password to the user directory. Usage: passwd Zhangcheng.

Groupadd: Create a new group.

Unzip: Unzip the zip file.

Gzip: Compress the file into a. gz file.

Gunzip: Unzip the. gz file.

Last: Lists information about the past and current users logged into the system.

LSPCI: Use Lspci-v to view the controller information on all PCI devices on the hardware chipset.

LSUSB: Displays device information on the system's USB bus. Bus 003 Device 006:id 067b:2303 Prolific Technology, Inc. PL2303 Serial Port. Which means that the/dev/bus/usb/003/006 on the 2303 USB to the serial device, but also see the new/dev/ttyusb0, the use of minicom can be achieved with the same function as the serial debugging assistant. Lsusb-v can display USB details

Usb-devices: Check the current USB device mounted driver information, such as PL2303 in ubuntu12.04, the default support, where is this driver? Will echo back such as: p:vendor=067b prodid=2303 rev=03.00,

S:manufacturer=prolific Technology Inc.s:product=usb-serial Controller

Depmod: Analyzes the dependencies that can be loaded into a module. For example: DEPMOD-A, analyze all available modules.

Lsmod: Displays the module information that the system has loaded. The format is the module name, the module size, the user.

Modinfo: Displays a specific module information. For example: Modinfo module name, display module path, GPL, configuration and other information.

Modprobe: Displays the path of the specific. Ko or. o file for all modules. For example: Modprobe-l. Modules can also be loaded, more powerful than insmod.

Uname: View system hardware and software information. Use Uname-r-m-p-I to get information such as kernel version and processor architecture.

Insmod: Load module, Linux has many functions is through the way of the module, when needed to load kernel.

Rmmod: Unload the module.

RPM: It functions like "Add/Remove Programs" in Windows and is widely used to install and remove software under Linux. such as: Rpm-q modutils, query system there is no modutils package.

DF: Hard disk space usage, and mount information. Like what:

Filesystem Size used free blksize
/dev 482M 52K 481M 4096
/mnt/secure 482M 0K 482M 4096
/system 640M 364M 276M 4096
/data 1008M 122M 885M 4096
/cache 124M 4M 119M 4096
/storage/sdcard0 1G 846M 989M 16384
/mnt/secure/asec 1G 846M 989M 16384
/storage/sdcard1 120M 4M 116M 2048

As you can see, you know what the external SD (120M) and internally partitioned SD mount points are. (many APK operation T card default path is Sdcard0, as described above will cause misoperation, so to do SD SWAP)

MPlayer: Use the toolkit to debug and use sounds. MPlayer xxx.wav, the audio file is played and the device used for the current audio is displayed. Of course, you can also specify to use OSS or ALSA to play, such as: Mplayer-ao Alsa xxx.wav, with ALSA audio components to play.

Fdisk: Displays partition information, such as Fdisk-l, which displays mount points, partition information, ID numbers, system types. If it is an IDE hard disk, the device name is:/DEV/HDA,/DEV/HDB,/DEV/HDC,/DEV/HDD, etc., if it is a SCSI hard disk, the device name is/dev/sda,/dev/sdb in turn. For example, the following information (part):

Device Boot Start End Blocks Id System
/DEV/SDA1 * 2048 201099263 100548608 Linux
/dev/sda2 201101310 209713151 4305921 5 Extended
/dev/sda5 201101312 209713151 4305920, Linux Swap/solaris

FSCK: Checks the file system for consistency and interactively repairs the file system.

The Parted:fdisk tool has a size limit on partitions, and it can only partition disks that are less than 2T. But now much of the disk space is already much larger than 2 T, you can use the parted tool we talked about today to achieve the GPT disk (GPT no four primary partition limit) to partition operations.

DMESG: Print kernel information, some print statements are output to the kernel rather than the terminal.

Lsof: Displays all processes that open the file, and so on. For example Lsof Abc.txt shows the process of opening the file abc.txt.

TTY: In the Linux operating system, all peripherals have their name and code names, which are stored in the/dev directory as a special file type. You can perform a TTY command to query the file name of the terminal you are currently using. For example: $tty, get/dev/pts/0.

Set: Displays all system environment variables. Like what:

Android_assets=/system/app
Android_bootlogo=1
Android_data=/data .....

Path=/sbin:/system/sbin:/system/bin:/system/xbin

$PATH: Displays the system's PATH value, separated by: and cannot be wrapped. Path=~/bin: $PATH, merge the new path into the path. This method can only temporarily set the environment variables, logout again after login has no effect.

File: Displays the types of files, using the command file to let you know whether a file is an elf-formatted executable, or a shell script file or any other format. Example: File BusyBox, display busybox:elf 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for Gnu/linux 2.6.14, Stri pped

Tree: is a Linux-listed gadget that lists all files in a specified directory, including files in subdirectories. Execution: tree/sys/bus/i2c/can list the adapter and device related information of i²c.

Pstree: Displays the process tree of the current system, which makes it easier to see the correspondence between the child process and the parent process.

PS: is the snapshot information for the current running process. Includes user number, process number, time, command, and so on. General use PS-EF, also can use PS aux. It can be used to quickly index the running process, for example: PS aux|grep ssh

Uptime: Displays system run time information. Showing: 17:12:47 up 1:38, 8 users, load average:0.94, 0.51, 0.47. Each represents the load balancing of the start time, state, total elapsed time of the system, number of users, past 1, 5, and 15 minutes, respectively.

Sleep: Causes the current system to delay operation for some time. Sleep 1, for example, delays one second. The parameter is the length of time, which can be followed by S, M, H, or D, where S is seconds, M is minutes, H is hours, and D is the number of days.

DPKG: Package management commands. Dpkg-l View all installed package information in the system. If you want to view installation information for a software, use the Dpkg-l file name, such as Dpkg-l Libc6-dev.

The Whereis:whereis directive looks for eligible files in a specific directory. The properties of these files should belong to the original code, binary files, or Help files. such as: Whereis File-roller.

Alias: Aliases for custom directives, such as alias[alias]=[directive name]. If you enter alias only, you can list all of the current alias settings. Alias is only valid for the login operation.

Who: Displays all logged-in users and their information on the current server.

W: Displays all logon user operation information on the current server, more detailed than who.

STARTX: Enter the Linux GUI from the command interface.

SU: Used to switch between users. such as Su Root, switch from another account to the root account.

Date: Modifies the system time and date. Set the system date to September 9, 2008 Date-s 20080909; Set the system time to 14:25:49 date-s 14:25:49.

Locate: File location command to quickly locate the location of a file on a Linux system. For example: Locate module.h.

============ Network Operation Command ========================================

Service Network restart: After configuring the network service, restart.

IP: Is the integration of the ifconfig and route two instructions.

Ping: The function is the same as XP. If you want it to stop, use CTRL + C.

The function of the Netstat:netstat command is to display network connections, routing tables, and network interface information to let users know which network connections are currently in operation. Run: Netstat-an|grep 20000, view the status of port number 20000, get TCP 0 0 0.0.0.0:20000 0.0.0.0:* LISTEN.

Telnet: Open the terminal stage job and log in to the remote host.

Rlogin:remote Login, open the terminal stage operation and log in to the remote host.

ftp: Log on to the FTP server.

Route: Displays the current system routing table information.

Finger: Displays information such as user name, home directory, stall time, logon time, login shell, etc. for a user in the system.

Mail: Message information.

W3m: Terminal is logged into the text version of the browser.

============= System security Command ===================================

passwd: Change Password.

SU: The role is to change the identity of other users, except the superuser, you need to type the user's password.

sudo: A tool that allows a system administrator to allow a normal user to perform some or all of the root commands, such as HALT,REBOOT,SU and so on. This not only reduces the login and administration time of the root user, but also improves security. such as: sudo echo 8 >/PROC/SYS/KERNEL/PRINTK you want to modify the log level of the console.

chmod: Change file permissions. For example chmod 777 cc, set cc permissions to 777. The first bit is the file owner permission, the second is the group permission, and the third is the other person's permission. The permission value for each bit is the sum of the Read permission (4) and the Write permission (2) and the Execute permission (1). If you are recursively modifying the properties of a folder and its subdirectories, use chmod-r 777 xxx.

Chown: Changes the owner and group associated with the file. such as Chown Jim:jim program.c, that is, PROGRAM.C user access and group permissions are applied to Jim;chown-r john:build/tmp/src, all files under the/TMP/SRC directory are associated to user John, Group build.

Pkill: Sometimes using the W command to see some invalid user logins shows that there is no logoff on the system and consumes PTS resources. Then you can log out of these accounts as root. First Use W to view the user name, and the TTY name. Then use Pkill-kill-t pts/x (x is the corresponding kill user number).

=============vi Editor Command ==================================

VI Editor Operation:
Exit: Press ESC and press SHIFT+:,Q. Where, q! forced to quit, Wq after saving.
Edit: Press I to enter the edit state, start editing from the front of the cursor, press A also into the edit state, but start editing after the cursor.
Find: Press ESC to exit edit mode, execute "/word" to find the string you are looking for, press N to find the next.
Copy: Press ESC to exit edit mode, to copy the current line, press yy; to copy n rows, jump cursor to the start line, enter Yny.
Paste: After copying jump cursor to the target location, press p. You can also paste directly in the SECURECRT.

Delete character: First click the ESC key to switch from edit mode to command line mode, press X to delete the previous character of the cursor, press X to delete the cursor after a character.

Delete Row: Click ESC to switch from edit mode to command line mode and delete the current line by DD.

Move cursor: Press ESC to exit Edit state, and then use the arrow keys.

File start: Press ESC to exit edit mode, press GG.

End of File: Press ESC to exit edit mode and press Shift+g.

Edit line directly: If you add a line number to the file after you use the VI command, the cursor can jump directly to the location you want to edit. For example, $ VI setlocalversion +148, directly edit the file's 148 lines.

============= compression and Decompression commands ==========================

(1) Tar: folder compression and decompression commands.

. tar.gz
Decompression: Tar zxvf FileName.tar.gz

Compression: Tar zcvf FileName.tar.gz DirName compresses the contents of DirName into a compressed document named FileName.

. tar.bz2
Decompression: Tar jxvf FileName.tar.bz2

Compression: Tar jcvf FileName.tar.bz2 DirName

. Tar (packaged without compression only)

Decompression: Tar xvf Filename.tar

Package: Tar cvf filename.tar DirName

. tgz

Decompression: Tar zxvf filename.tgz

. bz2

Unzip: Unzip the file system

(2) Gzip: File compression and decompression commands. The compression suffix is GZ format

Package: gzip-9 xxxx

Decompression: gzip-d xxxx.gz (if the decompression results output to the screen, plus-c)

(3) If you want to exclude a subdirectory when packaging, the command is as follows (note that the last side does not follow/sign)

Tar zcvf sybase-12.5-20111028.tar.gz sybase-12.5--exclude=sybase-12.5/data (last/cannot be followed, otherwise culling does not work), if multiple directories are excluded, Each directory needs to be--exclude= listed.

(4) If there are multiple separated numbered compression packages, such as:

ALPS.xxx_INHOUSE.tar (20110410). gz00
ALPS.xxx_INHOUSE.tar (20110410). gz01
ALPS.xxx_INHOUSE.tar (20110410). gz02
ALPS.xxx_INHOUSE.tar (20110410). gz03
ALPS.xxx_INHOUSE.tar (20110410). gz04

Then the decompression command is: Cat ALPS.xxx_INHOUSE.tar (20110410). GZ*|TAR-ZXV

(5) Zip command

Zip-r Mydata.zip MyData #压缩mydata目录
Unzip mydata.zip-d Mydatabak #解压到mydatabak目录
Unzip Wwwroot.zip #解压到当前目录

(6) Compression times tar:exiting with failure status due to previous errors

This may be due to individual file permissions or differences in user groups. Modify file permissions and user groups first, and then compress

============================================ file splitting and merging commands

Split: Split-b 1024m userall.tar.gz. -b Specifies a single file size

Merging: Cat xx* > userall.tar.gz

For multiple files such as xxx.tar.bz2.001,xxx.tar.bz2.002, the method of restoration is copy/b "xxx.tar.bz2.001" + "xxx.tar.bz2.001" "xxx.tar.bz2", File segmentation can be used ultra_file_splitter.

Common Commands under Linux

Related Article

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.