Linux command Line Daquan

Source: Internet
Author: User
Tags arithmetic parent directory readable time and date uppercase letter

Date Displays the current time and date Cal displays the current month of the Calendar DF View the number of free memory on the disk in the available PWD print current working directory CD switch directory LS list Folder contents absolute path: Start root relative path: Start at the working directory. Working Directory parent Directory CD-Change directory to previous working directory CD ~ Switch to home directory ls-l results in long mode output-t option sorted by file modification time--reverse results will be output in reverse order-a more friendly way to display-a list all files including hidden files fil e filename Print file content simple description Less filename View the contents of the file, you can scroll back and forth, press Q to exit the directory comment/root directory, the origin of everything. The/bin contains the binaries that are necessary for the system to start and run. /boot contains the Linux kernel, the initial RAM disk image (required for startup), and the boot loader. Interesting file:/boot/grub/grub.conf or Menu.lst, which is used to configure the boot loader. /boot/vmlinuz,linux kernel. /dev This is a special directory that contains device nodes. "Everything is a document" and also applies to devices. In this directory, the kernel maintains a list of all devices. /etc This directory contains all system-level configuration files. It also contains a series of shell scripts that turn on each system service when the system starts. Any file in this directory should be a readable text file. Interesting files: Although any files in the/etc directory are interesting, here are just a few of the files I've always liked:/etc/crontab, defining tasks that run automatically. /etc/fstab, which contains a list of storage devices and the mount points associated with them. /ETC/PASSWD, which contains a list of user accounts. /home in a typical configuration environment, the system assigns a directory to each user under/home. Ordinary users can only write files in their own directory. This restriction protects the system from bad user activity. /lib contains the shared library files used by the core system programs. These files are similar to dynamic-link libraries in Windows. /lost+found This directory is available for each formatted partition or device that uses the Linux file system, such as the Ext3 file system. This directory is used when a damaged file system is partially restored. Unless the file system is truly corrupted, this directory will be an empty directory. /media in today's Linux system,The/media directory contains mount points for removable media, such as USB drives, CD-ROMs, and so on. After the media is connected to the computer, it is automatically mounted under this directory node. /mnt in earlier Linux systems, the/mnt directory contains mount points for removable media. /opt This/opt directory is used to install "optional" software. This is primarily used to store commercial software products that may be installed in the system. /proc This/proc directory is very special. It is not a real file system from the meaning of the file stored on the hard disk. Instead, it is a virtual file system maintained by the Linux kernel. It contains files that are the peephole of the kernel. These files are readable and they tell you how the kernel regulates the computer. /root the home directory of the root account. /sbin This directory contains a "system" binary file. They are programs that perform major system tasks, and are usually reserved for super users. /tmp this/tmp directory is the place to store temporary files created by various programs. Some configurations cause the system to empty the directory each time it restarts. /usr in a Linux system, the/usr directory may be the largest. It contains all the programs and files required by the ordinary user. The/usr/bin/usr/bin directory contains the executable program installed by the system. Typically, this directory contains many programs. /usr/lib contains shared libraries that are used by programs in the/usr/bin directory. /usr/local This/usr/local directory, the non-system release version comes with, but intends to let the system use the installation directory of the program. Typically, a program compiled by the source code is installed in the/usr/local/bin directory. In a newly installed Linux system, this directory will exist, but it is an empty directory until the system administrator puts something into it. /usr/sbin contains many hypervisor programs. The/usr/share/usr/share directory contains many shared data that is used by programs in the/usr/bin directory. This includes such things as default profiles, icons, desktop backgrounds, audio files, and so on. /usr/share/doc most of the packages installed in the system will contain some documentation. In the/usr/share/doc directory, we can find documents categorized by package. /var In addition to the/TMP and/home catalogs, relatively speaking, the directories we see at the moment are static, which means that their content will not change. The/var directory is where you may need to change the file storage. Various databases, spool files, user mail, and so on, are all located here. /var/This/var/log directory contains log files and records for various system activities. These files are important and should always be monitored. One of the most important files is/var/log/messages. Note that for system security, in some systems, you must be a superuser to view these log files.   Wildcard * matches any number of characters (including 0 or one)? Match any one of the characters (not including 0) [characters] matches any one of the characters in the character set [!characters] matches any character that is not in the character set [[: Class:]] matches any one of the characters that belong to the specified character class in the characters commonly used character Category: [: Alnum:] matches any one letter or number [: Alpha:] matches any one of the letters [:D Igit:] matches any one of the numbers [: Lower:] matches any one lowercase letter [: Upper:] matches any uppercase letter mkdir directory Gen Build directory mkdir dir1 dir2 dir3 Create three directories cp file1 file2 copy files file1 content to file file2. If file2 already exists, the content of File2 will be rewritten by file1 content. If File2 does not exist, File2 is created. Cp-i file1 file2 This command, like the above command, prompts the user to confirm the message, except if the file File2 exists, before the file file2 is rewritten. CP file1 file2 dir1 copy files file1 and file file2 to directory Dir1. Directory Dir1 must exist. CP dir1/* DIR2 uses a wildcard character, and all files in the directory Dir1 are copied to the directory Dir2. Dir2 must already exist. Cp-r dir1 Dir2 Copy the contents of the directory Dir1 to the directory Dir2. If the directory Dir2 does not exist, create the directory Dir2, and when the operation is complete, the contents in the directory Dir2 are the same as in Dir1. If the directory Dir2 exists, the directory Dir1 (and the contents of the directory) will be copied to Dir2. MV File1 file2 move file1 to File2. If file2 exists, its contents will be rewritten by File1 's content. If File2 does not exist, the file2 is created. In each case, the File1 no longer exists. Mv-i file1 File2 except if File2 exists, before File2 is rewritten, the user will be prompted with the message, which is the same as the above option. MV File1 file2 dir1 move file1 and file2 into the directory Dir1. Dir1 must already exist. MV Dir1 DIR2 If the directory Dir2 does not exist, create a directory Dir2, and move the contents of Dir1 to directory DIR2 while deleting the directory Dir1. If the directory Dir2 exists, move the directory Dir1 (and its contents) to the directory Dir2. RM file1 silently deletes the file rm-i file1 in addition to prompting the user to confirm the message before deleting the file, as with the command above. Rm-r file1 Dir1 Delete the contents of the file File1, directory Dir1, and Dir1. RM-RF file1 Dir1, RM will continue to execute except if the file File1, or the directory Dir1 does not exist. ln-Create hard links and Symbolic Links ln File link creates a hard link Ln-s file line creates a soft link hard link compared to a more modern symbolic link, the hard link is the way that Unix initially created the link. Each file will have a hard link by default, and this hard link gives the file a name. Every hard link we create creates an additional catalog entry for a file. There are two important limitations to hard links: 1. A hard link cannot associate a file other than the file system it resides in. This means that a link cannot be associated with a file that is not on the same disk partition as the link itself. 2. A hard link cannot be associated with a directory. When a hard link is deleted, the link is deleted, but the contents of the file itself still exist. Symbolic links are similar to Windows shortcuts, and if you write to a symbolic link, the associated file is also written. However, when you delete a symbolic link, only the link is deleted, not the file itself. If the file is deleted before the symbolic link, the link still exists but does not point to anything. In this case, this link is called a bad link. Type command displays the types of commands which the location of an executable program LS--help--help option, this option is a reference manual that shows the syntax and options supported by the Command Man Command view command Whatis comm and displays a very concise command stating that the info command info info file is a tree structure, differentiated into individual nodes, each containing a topic. Whatis CommanD shows a very concise command description alias name= ' command string ' to alias Ls-l/usr/bin > Ls-output.txt redirect output less ls-output.txt view output content ls-l/usr /bin >> Ls-output.txt using the ">>" redirection, append content a program can produce output on any of several numbered file streams. Although we have referred to the top three of these file streams as standard input, output, and error, the shell internally describes them as file descriptors 0, 1, and 2 respectively. The shell uses a file descriptor to provide a notation for redirecting files. Because of the standard error and file descriptor 2, we use this notation to redirect the standard error: Cat movie.mpeg.0* > Movie.mpeg Append the Eligible file Ls-l/usr/bin | The ability of the less command to read data from standard input and deliver it to standard output is exploited by a shell feature called a pipe line. Adding filters to the pipeline Sortls/bin/usr/bin | Sort | The LESSWC (Word count) command is used to display the number of rows, words, and bytes that the file contains. For example: WC ls-output.txt7902 64566 503634 ls-output.txtgrep pattern [file ...] find matching text Ls/bin/usr/bin | Sort | Uniq | grep zip case-sensitive Ls/bin/usr/bin | Sort | Uniq | Grep-i Zip ignoring case grep "standard" Standard.txt > Grep.out 2>& 1 finds the standard string in file Standard.txt, redirects the lookup result to grep.out if found, and redirects the error message to Grep.out if it is not found. Head-n 5 ls-output.txt Look at the beginning five elements tail-n 5 ls-output.txt See the end of the five elements the wavy line character ("~") has a special meaning. When it is used at the beginning of a word, it expands into the name of the specified user's home directory. If no user name is specified, the current user's home directory is expanded. [[email protected] ~]$ echo ~foo/home/foo arithmetic expression expansion usingThis format: $ (expression)) [[email protected] ~]$ echo $ ((2 + 2)) 4 in arithmetic expressions The hollow lattice is not important, and expressions can be nested. [[email protected] ~] echo $ (($ ((5**2) * 3)) 75 through it, you can create multiple text strings from a pattern that contains curly braces. [[email protected] ~]$ echo front-{a,b,c}-backfront-a-back front-b-back front-c-back[[email protected] ~]$ echo number_{1..5}number_1 number_2 number_3 number_4 number_5[[email protected] ~]$ echo {Z ... A}z Y X W V U T S R Q P O N M L K J I H G F E D C B a curly brace nested: [[email protected] ~]$ echo a{a{1,2},b{3,4}}baa1b aa2b aB3 b ab4b Batch Create a directory named "year-month" as a number [[email protected] ~]$ mkdir pics[[email protected] ~]$ CD pics[[email  Protected] pics]$ mkdir {2007..2009}-0{1..9} {2007..2009}-{10..12}[[email protected] pics]$ ls2007-01 2007-07 2008-01 2008-07 2009-01 2009-072007-02 2007-08 2008-02 2008-08 2009-02 2009-082007-03 2007-09 2008-03 2008-09 2009-03 2009 -092007-04 2007-10 2008-04 2008-10 2009-04 2009-102007-05 2007-11 2008-05 2008-11 2009-05 2009-112007-06 2007-12 2008-06 2 008-12 2009-06 2009-12 command substitution allows us to use the output of a command as an expansion mode: [[email protected] ~]$ echo $ (LS) Desktop Documents ls-output.txt Music Pictures Public Templatesvideosbash also supports this syntax. It uses inverted quotes instead of dollar signs and parentheses: [[[email protected] ~]$ ls-l ' which cp '-rwxr-xr-x 1 root root 71516 2007-12-05 08:58/bin/cp Remember, in double quotes , parameter expansion, arithmetic expression expansion, and command substitution are still valid: [[[Email protected] ~]$ echo "$USER $ (()) $ (CAL)" Me 4 February 2008Su Mo Tu We Th Fr sa below Examples are unreferenced, double quotes, and single quote comparison results: [[email protected] ~]$ echo text ~/*.txt {A, B} $ (echo foo) $ ((+)) $USERtext/home/me/ Ls-output.txt a B foo 4 me[[email protected] ~]$ echo "text ~/*.txt {A, B} $ (echo foo) $ (()) $USER" text ~/*.txt { A, B} foo 4 me[[email protected] ~]$ echo ' text ~/*.txt {A, B} $ (echo foo) $ ((+)) $USER ' text ~/*.txt {A, B} $ (echo fo O) $ ((+)) $USER backslash escape character [[email protected] ~]$ mv bad\&filename good_filename View historical Information History |  Less history command Execution!! Repeats the last command executed. It may be easier to press the UP ARROW key and the ENTER key.!number the command that repeats the number line in the History list.!string repeats the command that starts with this string in the recent history list. String repeats the command that contains the string in the recent history list. PS –Report Current process Snapshot top– display task jobs– list active Tasks bg– put a task in the background execution fg– put a task in the foreground execute kill– send a signal to a process killall– kill the process of the specified name shutdown– shutdown or restart the system process state: R in operation. This means that the process is running or ready to run. S is sleeping. The process is not running, but is waiting for an event, such as a button or network grouping. D do not interrupt sleep. The process is waiting for I/O, let's say, a disk drive I/O. T has stopped. The process has been instructed to stop running. More on this later. Z a dead process or "zombie" process. This is a child process that has been terminated, but its parent process has not yet emptied it. (The parent process has no handle process removed from the process table) < A high-priority process. This may grant a process more important resources, giving it more CPU time. This property of the process is called niceness. A process with a high priority is said to be bad, because it takes up more CPU time, leaving little time for other processes. N low-priority process. A low-priority process (a "good" process) will get processor time only when other high-priority processes are serviced. Another popular option combination is "aux" (without the beginning of the "-" character).     This will give us more information: [[[email protected] ~]$ PS auxuser PID%cpu%MEM VSZ RSS TTY STAT START time Commandroot     1 0.0 0.0 2136 644?     Ss Mar05 0:31 initroot 2 0.0 0.0 0 0? s< Mar05 0:00 [kt] dynamically view process background execution with the top command: After the program command, add the "&" character [[email protected] ~]$ Xlogo &[1] 28236 background command pair with keyboard Input immunity, cannot be interrupted, use FG to move the command to the front end. After the FG command, follow a percent semicolon and the task sequence number (called Jobspec).        [[email protected] ~]$ jobs[1]+ RunningXlogo &[[email protected] ~]$ FG%1xlogo 

  

Linux command Line Daquan

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.