Common commands in Linux development

Source: Internet
Author: User
Tags decompress file echo message
Source: Zhongguancun Online Basic Operation Command: ------------------------------------------------------------------------------------------------------------------------------- ------------- ls # Source: Zhongguancun Online


Basic operation commands:
--------------------------------------------------------------------------------------------------------------------------------------------

Ls # display the current directory file list by default

Ls? A # show all files, including hidden files

Ls? L # display file attributes, including the size, date, and symbolic connection, whether the file can be read/written, and whether the file can be executed

Ls -- color = never *. so> obj # the text color is not displayed, and all so files are recorded in the obj file.

----------------------------------------------------------------------

Cd dir # switch to the dir directory under the current directory

Cd/# switch to the root directory

Cd .. # switch to the upper-level Directory

Cd.../... # switch to the upper-level Directory

Cd ~ # Switch to the user directory. for example, if it is a root user, switch to/root.

----------------------------------------------------------------------

Rm file # Delete an object

Rm-fr dir # delete the entire directory named dir in the current directory

----------------------------------------------------------------------

Cp source target # copy the file source to target

Cp/root/source. # copy the file source under/root to the current directory.

Cp? Av soure_dir target_dir # copy the entire directory. the Two directories are identical.

Cp? Fr source_dir target_dir # copies the entire directory in non-link mode. when the source directory has a symbolic link, the two directories are different.

----------------------------------------------------------------------

Mv source target # rename the file source to target

---------------------------------------------------------------------

Diff dir1 dir2 # compare whether the list of files in directory 1 and directory 2 is the same, but does not compare the actual content of files.

Diff file1 file2 # compare whether file 1 and file 2 have the same content. if a file is in text format, different contents are displayed, if the code is binary, the two files are different.

Comm file1 file2 # compare files and display different contents of the two files

---------------------------------------------------------------------

Echo message # display a string of characters

Echo "message message2" # display discontinuous strings

Cat:

Cat file # displays the file content, which is the same as the DOS type.

Cat file | more # display the content of the file and transfer it to the more Program for pagination. use the command less file to implement the same function.

More # Paging command, generally pass the content to it through pipelines, such as ls | more

----------------------------------------------------------------------

Export LC_ALL = zh_CN.GB2312 # set the environment variable LC_ALL to zh_CN.GB2312.

Export DISPLAY = 0: 0 # with this setting, the graphics program running on the current character terminal can run directly on Xserver

Date # display the current date and time

Date-s 20:30:30 # set the system time to 20:30:30

Date-s # set the system period to-3-5

Clock? R # read time parameters from the system Bios

Clock? W # write the system time (such as the time set by date) to the Bios

----------------------------------------------------------------------

Eject # umout: drop the CDROM and bring up the CD, but the cdrom cannot be in the busy status; otherwise, it is invalid.

---------------------------------------------------------------------

Du # calculate the current directory capacity

Du-sm/root # Calculate the capacity of the/root directory in MB

Find-name/path file # search in the/path directory to see if there is any file

Grep-ir "chars" # search for the character string chars in all files in the current directory, and ignore case sensitivity.-I is case sensitivity and-r is the next level Directory.

----------------------------------------------------------------------

Vi file # Edit a file

BASIC vi usage and commands:

Press ctrl + c to enter the command, and then enter: x (exit),: x! (Exit and save): w (Write file),: w! (Write files without inquiry),: r file (read file),: % s/oldchars/newchars/g (replace all strings with oldchars newchars ).

----------------------------------------------------------------------

Man ls # read help about ls commands

Man ls | grep color # read help about the ls command and use the grep program to find the color string

----------------------------------------------------------------------

Startx # environment for running Linux images

Xfree86 # run only X graphics server

----------------------------------------------------------------------

Reboot # restart the computer

Halt # shut down the computer

Init 0 # Close all applications and services and enter the pure Operating Environment

Init 1 # restart applications and services

Init 6 # restart the computer

----------------------------------------------------------------------

Extended Commands

--------------------------------------------------------------------------------------------------------------------------------------------

Tar xfzv file. tgz # decompress file. tgz

Tar xfzv file. tgz-C target_path # decompress file. tgz to the target_path directory.

Tar cfzv file. tgz source_path # compress the file source_path to file. tgz

Tar c directory> directory.tar pack directory directoryinto uncompressed directory.tar

Gzip directory.tar # overwrite the original file generated and compressed directory.tar.gz

Gunzip directory.tar.gz # overwrite the original file and decompress it to generate a non-compressed directory.tar.

Tar xf directory.tar # uncompress files

----------------------------------------------------------------------

Dmesg # display kernle startup and driver loading information

Uname # display the operating system type

Uname-R # display the version of the operating system kernel

----------------------------------------------------------------------

Strings file: displays the ASCII characters in the file.

----------------------------------------------------------------------

Rpm-ihv program. rpm # install program and display the installation process

Rpm2targz program. rpm program. tgz # convert files in rpm format to the tarball format

----------------------------------------------------------------------

Su root # switch to Super User

Sulogin/dev/tty4 # on tty4, that is, alt + F4, wait for the user to log on or directly log on to start a shell.

Chmod a + x file # set the file to executable. you must set the script file in this way. Otherwise, you must use bash file to execute the file.

Chmod 666 file # set the file to read/write

Chown user/dir # set the/dir directory to all

----------------------------------------------------------------------

Mknod/dev/hda1 B 3 1 # Create a block device hda1, master device number 3, slave device number 1, that is, the first partition of the master hard disk

Mknod/dev/tty1 c 4 1 # Create a character device tty1, the main device number is 4, the public device number is 1, that is, the first tty terminal

----------------------------------------------------------------------

Touch/tmp/running # Create a temporary file running under/tmp and disappear after restart

----------------------------------------------------------------------

Sleep 9 #9 seconds of system suspension

----------------------------------------------------------------------

Lpd stop or cups stop # stop The Print Service Program

Lpd start or cups start # start The Print Service Program

Lpd restart or cups restart # restart the Print Service Program

Lpr file.txt export print file file.txt

----------------------------------------------------------------------

Fdisk/dev/hda # just like the fdisk that executes dos

Cfdisk/dev/hda # A little more friendly than the fdisk interface

Mount-t ext2/dev/hda1/mnt # load/dev/hda1 to the/mnt Directory

Df # display information about file system loading

Mount-t iso9660/dev/cdrom/mnt/cdrom # attach the optical drive to the/mnt/cdrom directory.

Mount-t smb // 192.168.1.5/destination dir/mnt-o username = tomlinux, password = tomlinux # load the windows shared directory to the/mnt/smb Directory. the username and password are all tomlinux.

Mount-t nfs 192.168.1.1:/1_dir/mnt # load the shared directory of nfs to the/mnt/nfs Directory

Umount/mnt # unmount the/mnt Directory. The/mnt directory must be idle.

Umount/dev/hda1 # Uninstall the/dev/hda1 device. the device must be empty.

Sync # synchronize the content in the cache with the disk. copy the file in Linux. Generally, the file is written only when the system is idle.

E2fsck/dev/hda1 # check whether/dev/hda1 has a file system error and the system prompts how to fix it.

E2fsck-p/dev/hda1 # Check for/dev/hda1 errors. If yes, it is automatically repaired.

E2fsck-y/dev/hda1 # check errors. all questions are executed in the yes mode.

E2fsck-c/dev/hda1 # check whether the disk has a bad partition

Mkfs/dev/hda1 # Format/dev/hda1 in ext2 format

Mkfs. minix/dev/hda1 # Format/dev/hda1 as a file system in minix format

Mfks/dev/hda9 # lattice/dev/hda9 is in Linux swap format

Swapon/dev/hda9 # load swap partitions as memory

Swapoff/dev/hda9 # unmount the swap partition

----------------------------------------------------------------------

Lilo # run the lilo program
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.