Linux basic Commands

Source: Internet
Author: User
Tags clear screen create directory parent directory cpu usage

• Format of commands • Command "Options" "Parameters" • Note • 1. Use a space separator • 2. Supports up to 256 characters clear: Clean screen, you can use Ctrl+l. Pwd:print working Director (prints the current working directory) cd:change directory switch path. /:      root directory •: current directory ·: The parent directory of the current directory ~: Represents the current home directory CD "director name" (directory name) to take the path · 1) Absolute path: The path to begin traversing from the root directory. ·2) Relative path: The path to begin traversing from the current directory. ls: Displays the contents of the specified path ls  The path name ls–a Show hidden files. Ls–l Displays the details of the file. File types under Linux (see first letter) 1.-ordinary files, storing data in some format (binary text) 2.d catalog files, storing names of other files, and pointers to those files. 3.b block device file that provides the direction of the device with Buffering. 4.c character device file with no buffering. 5.P pipeline files, interprocess communication. 6.S the network traffic between socket sockets processes. 7.l Symbolic Link to another file (equivalent to a shortcut to Windows) • File permissions • rwx rw---x permissions are divided into three groups: • First group: Permissions of the file owner • Second group: Group permissions for the file owner • Third group: Other users R:read read 4                         0100 W:write Write 2                       0010 x:execution Execution 1            0001  permissions-related commands: chmod 1. Letter chmod [u/g/o/A][+/-][R/W/X] filename u:user g:group o:other a:all 2. Digitally • Set the file permission to owner read-write, group read, other read. You can use chmod 644 file to create a file with default permissions of 644. • When creating a directory, the default permission is 755. • Seven. Create a new file touch 1.touch filename 2.touch filename1 filename2 filename3   eight. Create directory mkdir mkdir directoryname mkdir test mkdir/tarena01/test/test01   Nine. echo Feedback Display • 10. Cat/more Cat filename Displays the contents of the specified file more displays the contents of the specified file cat/etc/passwd: Stores information for all users of the current system. root:x:0:0:root:/root:/bin/bash  root:x: 0:0: Root:/root:/bin/bash user name password User ID Group ID comment user home directory default shell type &nbs p; MoreSpace: Next ScreenEnter:   Next lineQ: Exit11 cp:copy CopyCP filename Dir-name Copy the file to the specified pathcp–r dir-name another-dir-name Copy a directory pastCp–all dir-name another-dir-nameCopy all content to the specified path according to the original dependency  12. MV Move (move) rename (rename) mv filename dir-name Move the file to the specified path MV filename newfilename Rename the file   13. RM Delete file rmdir Delete directory remove RM filename Delete file rm–f force hard Delete rm–r dir-name Delete directory (rmdir delete empty directory)   shortcut bash 1,ctrl+l clear screen 2,ctrl+a location To the beginning of the command 3,ctrl+e navigate to the end of the command 4,ctrl+c/z end/Suspend executing command 5,ctrl+m enter 6,date display time date cal calendar 7,SU: Upgrade rights (password)   14 History Command · Support up and DOWN ARROW keys to find executed commands history: Displays the history of the execution of commands ·! Number: The command that executes the specified numbers!! : Re-executes the last command once • 15. Head/tail head–number filename View the first few lines of a file tail–number filename View the last few lines of a file • 15. WC Document Statistics • Statistics specify the number of bytes, words, and lines of the file to be displayed. WC [options] filename wc–l filename Displays the number of rows wc–c filename bytes wc–w filename    16. Find directory Find [directory list] Match standard • Directory list: The collection of directories you want to find, separate by spaces • Match criteria: Match criteria for the files you want to find-name match names-atime n files accessed in the last few days-size n Files of size n Type x looks for files of type x   17. Wildcard • We can use wildcard characters when doing the same thing for multiple files. • Note: You can use it only if you need to get the moral content under the operating directory. *: Can represent any number of characters [] only one arbitrary character • 1). List all the characters that need to be wildcard. CP file0[123]./test 2). Gives the range of the wildcard   RM file[a-z A-Z 0-9]? Pass with an arbitrary character rm file? {} Combine multiple wildcard conditions {[condition 1],[condition 2]} and condition 1 or Condition 2 pass rm {[0-9],[a-z]} means as long as aOne on it.   18 Commands • 1. Restart reboot   Shutdown Poweroff   exit exit 2. Semicolon: Connect multiple commands to execute  1) CD ... LS 2) CP test.c./test;ls test       Exit;poweroff will not shut down   19, grep find the contents of the file · Searches for the specified string in the specified file list. grep The statistics of the rows that match the string [options]. • Options:-c Statistics of rows that match strings-h when multiple files are found without displaying filenames-l multiple file lookups only show filenames-n display matching lines and line numbers-i case-insensitive-v display unmatched row   20, Pipe: The output of the previous program or command as input to the next program or command. cat/etc/passwd |more 21, user-related users: the user currently logged on to the system. who: Log on to the local system user for more information. Who am I: Displays information for the current user. WhoAmI: The user name of the current user. • 22, Sleep Number: Creates a process that sleeps number seconds. &: Running in the background. Sleep Number & current command background execution • 23, kill PID: kills the process that specified the PID. Kill 9: Forces all processes to be killed. • 24, PS detects the working status of the process. PS, only the processes on the current terminal are displayed. Option:  -E: Displays all processes. -f: Displays detailed information. -h: The caption is not displayed. A: Displays all processes on the terminal. • R: Displays the running process. • X: Shows the process without control terminal. au: Displays detailed format PS au–e displays details of all processes. User: The owner of the process pid:pid%cpu: CPU usage%mem: Memory usage vsz: The size of the virtual memory RSS: The size of the actual memory TTY: The corresponding control terminal Stat: The status of the process   D: Non-interruptible • R: Run • S: Stop or Hibernate < (high priority) N (Low priority) S (parent process) + (foreground process)   L (page locked into memory) L (multithreading) • T: Pause run • Z: Zombie start: Start time of process time: Execution time of the process command: command of the process   25, JobsView the content that is running. kill%n: End Nth Task FG%n: Move nth task to foreground execution BG%n: Move nth task to foreground execution stop%n: Pause nth Task    26, man help manual    man [command] Q Exit/[Find content]: What to look for • Spaces: Next screen • Carriage return/direction keyboard, indicating move up or down man  number [command]  27, Network • IP address: The so-called IP address is an address assigned to each host on the network. • Netmask: netmask The network number extracted from the IP address is all 1 and the host number is a 0 mask. • Default gateway: An IP address that is directly connected to the IP router. ifconfig: Configure the network interface netstat: View the network status Ping if there is a network path between the IP test host and the IP address.   28, Linux environment variable • Use export to view the current environment variable echo $ environment variable name Home: Current user's directory pwd: Current working directory Path:shell execute command or program search command lang,: language · CC:/USR/BIN/GCC standard C compiler ccc:/usr/bin/g++ standard C + + compiler    Modify environment variable export environment variable name = specific value export ps1= "[\[email  Protected]\u \w] "• Only valid at the current terminal.   29, Ln creates a link for the file Linux the connection is broken into hard links and soft links. • Hard Links: Links through the index nodes of a file, the index point of a file can correspond to multiple filenames ln–d filename newfile hard-link file has two restrictions • 1), do not allow the directory to create hard links, 2), only the files in the same file system can create links between. • Soft Connect: Also known as symbolic link, the soft link file stores only the information location that points to the destination file. can be any file or directory that can link files from different file systems. ln–s filename newfilename  30, Linux under the main directory/boot: (bootloader) boot loading system boot related files. /grub: The general Linux kernel impression is also placed in this directory. /temp: A temporary file produced when the system is started. Temporary file for user/var/tmp/mnt: Mounts subdirectories of other systems./bin: Binary availableExecute commands  
/dev: maintains all device files on the current system/ETC: System administration and configuration files
/ETC/RC.D: Startup configuration files and scripts
/home: The base point of the household directory, such as the user's main directory is/home/user, you can use ~user to represent/lib: The standard programming library, also known as the dynamic Link Shared library (xxx.so), functions like the Windows. dll file/sbin: System administration commands, which are stored in the hypervisor used by the system administrator
/root: System administrator's home directory (hehe, privileged Class)/lost+found: This directory is usually empty, the system is not properly shut down and leave the "homeless" files (what is called under Windows. chk) is here/proc: The virtual directory is the mapping of the system memory. This directory can be accessed directly to obtain system information.
/var: overflow area for some large files, such as log files for various services/USR: The largest directory, applications and files to be used in almost all of this directory. These include:
/USR/X11R6: The directory where x window is stored
/usr/bin: a multitude of applications
/usr/sbin: Some management programs for Superuser/usr/doc:linux documentation
The header files required to develop and compile the application under/usr/include:linux
/usr/lib: Common dynamic-link libraries and package profiles
/usr/man: Help documentation
/USR/SRC: Source code, Linux kernel source is placed in/usr/src/linux
/usr/local/bin: Locally added command
/usr/local/lib: Locally added library/var: Data that has been modified by the system, including other process and module data/var/log: The system's record file log/var/run: Includes various operational information   /var/lib: Saves state information during the operation of the system or an application. Users are not allowed to change files in this directory/etc: System profile/etc/xll:x System configuration file/etc/init.d: Boot profile/ETC/RCS.D: Store some links to init.d inside the file   31, vi/ Vim Editor • Enter Vi/vim vi/vim filename Three modes of operation: • 1, text edit mode: I,a,o Enter text edit, press ESC to exit text Edit and convert to command mode. 1) I insert text at the cursor location. ·2) a The text is inserted at the next position where the cursor is located. ·3) o Insert a new line, and then insert the text at the beginning of • 2, Command mode • 1) i a O into the text editing mode. ·2) cursor movement, direction key: H left, J, K, L right • 3) position shortcut: Ctrl+b page backward ctrl+f backward shift+? • W move to the beginning of the next word • E move to the end of the next word ・the move to the beginning of the previous word • 0 (0) move to the beginning of the line where the cursor is located    3, Bottom line command mode • Press shift+: Convert to Bottom line command mode: • 1) Wq: Save Exit · 2) W: Save current content to file • 3) Q: Exit • 4) q! : Forced exit • 5)/name: Find name Content    6) Press/n spaces: Uncheck the character/string 7) Set NU list line number set Nonu Cancel line number 8) C-style indentation, set tabstop=3. Set tab Indent distance • 9) Jump to the specified line: line number + carriage return • 10) Replace string%s/original string/string to replace/g 11) Keep production new file Number1,number2 w newfilename line number 1, line number 2 save new file name   4, delete text • Small x: Delete a character after the cursor position • Large x: Delete one character before the cursor position n+x (small): Delete the n characters that follow the cursor position n+x (Large): delete the n characters preceding the cursor position DD: Delete the row where the cursor is located n+ DD: Delete the line with the cursor and the five lines below. (from the line where the cursor is located to the next five lines (including the cursor row)   5, copy and paste yw: Copy the current cursor to the end of the word to the buffer. yy:Copies the row of the current cursor into the buffer. n+yy: Copy the row of the current cursor to the following n rows into the buffer (including the line where the cursor is located) p paste: Pastes the contents of the buffer into the position where the cursor is located. • 6, replace (replace) the character • R the • R replacement cursor is replaced until you press esc  7, revert undo U undo • 8, and jump to the specified line. Ctrl+g Lists the line number of the line where the cursor is located n+g jumps to n rows, does not exist 0g, that is, there is no 0 line one said.  

Linux basic Commands

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.