Common linux Commands

Source: Internet
Author: User
Common linux commands do not forget to note the commonly used basic linux commands. these days, when I have been drum up linux, some basic commands have not been used for a long time, but sometimes it will be used, and it will inevitably be forgotten after a long time, and then it will take time to find... common linux commands do not forget to note the commonly used basic linux commands. these days, when I have been drum up linux, some basic commands have not been used for a long time, however, some occasionally used commands, which will inevitably be forgotten after a long time, and then take the time to search. this is a waste of time. now I want to record some commands that I usually use and are easy to forget, for future query, use 1.pwd to display the current directory path 2. mkdir dir create directory 3.cd dir enter directory cd .. back to the parent directory cd/Back to the root directory cd ~ /Cd returns to the current user's home directory 4.ls to display directory files. Generally, this can be used to list all files in the directory by ls-a, including. the results of ls-t generated by ls-h in chronological order help to browse ls-l to list the details of the file ............ For example: ubuntu @ ip-10-250-31-239 :~ $ Ls-lhta total 12 M drwx ------ 2 ubuntu 4.0 K Apr 11. ssh-rw-r -- 1 root 12 M Dec 12 2012 node-v0.8.16.tar.gz ...... ...... ...... 1st Field: The file attribute field consists of 10 letters in total. The first letter indicates the file type. if the letter is a minus sign "-", the file is a common file. the letter "d" indicates that the file is a directory, the letter "d", is the abbreviation of dirtectory (directory. 2nd Field: number of hard links to a file or number of subdirectories 3rd Field: file owner 4th Field: Group of file owner 5th Field: file size (in bytes) 6th field: file creation month 7th Field: file creation date 8th Field: file creation time 9th Field: file name (if it is a symbolic link, there will be a "->" arrow symbol, followed by a file to which it points) 5.du: all directories and file sizes. du-m is displayed in 1 MB. 6.cp: copy the file filename1. copy the file to filename2 cp filename1 filename2 cp config/cache_store.yml.example config. /Cache_store.yml cp-f file1 file2 copy file1 to file2 because the target file already exists, therefore, use the forced reset mode cp-R file1 file2 to copy the directory dir1 to the directory dir2 7. mv moves or renames an existing file or directory. Mv file1 file2 change the name of file1 to file2 mv file1/opt to move file1 to the opt directory, the mv file1/opt/file2 is not renamed. move file1 to opt and change file1 to file2 mv file1/*/opt/file2. move all files under file1 to 8.rm under file2 to delete files and directories. parameters: -I confirm the deletion one by one before deletion-f will be deleted even if the original file attribute is set to read-only, you do not need to confirm one by one.-r also deletes the rm filename directory and the following files to delete the rm-rf filename File one by one. exercise caution when using this command, before deleting an important file, you 'd better back up it. if you accidentally delete a file, try to use the debugfs tool that comes with the system to fix it. refer: http://jingyan.baidu.com/article/2f9b480d6c2bcd41cb6cc223.html?qq-pf-to=pcqq.c2c http://loamy.iteye.com/blog/422462 9. tar backup file tar czvf backupfilename.tar filename decompress the backup tar zxvf backfilename.tar 10. find parameters: -name filename # find the file named filename-perm # search by execution permission-user username # search by file owner-group groupname # search by group-mtime-n + n # searching for files by file change time, -n indicates n days or less, and + n indicates n days before.-atime-n + n # Query GIN by file access time: 0px ">-ctime-n + n # search for a file based on the file creation time.-n indicates that the file is within n days, + n indicates that-nogroup # No valid Group file was found n days ago. that is, the file group does not exist in/etc/groups.-nouser # No valid owner file is found, that is, the file owner does not store-newer f1 in/etc/passwd.! F2 file search,-n refers to n days or less, + n refers to n days ago-ctime-n + n # search for files by file creation time,-n refers to n days or less, + n indicates that-nogroup # No valid Group file was found n days ago. that is, the file group does not exist in/etc/groups.-nouser # No valid owner file is found, that is, the file owner does not store-newer f1 in/etc/passwd! F2 # Query files whose change time is earlier than f1 but earlier than f2-type B/d/c/p/l/f # Query Block devices, directories, character devices, pipelines, symbolic link, normal file-size n [c] # check the file with a length of n [or n bytes]-depth # search the local directory before entering the subdirectory-fstype # Check the files whose change time is earlier than f1 but earlier than f2-type B/d/c/p/l/f # check the block devices, directories, character devices, pipelines, and symbols link, common file-size n [c] # check the length of the file to n [or n bytes]-depth # make the search to find the local directory before entering the subdirectory-fstype # query files in a certain type of file system, these file system types can usually be found in/etc/fstab-mount # The File query does not span the file system mount point-follow # If you encounter a symbolic link file, trace the file-cpio %; # query the files in a certain type of file system. These file system types can be found in/e -Mount found in tc/fstab # The file does not span the mount point of the file system-follow # If you encounter a symbolic link file, keep track of the file referred to by the link-cpio # Use the cpio command on the matched file and back them up to the tape device-prune # ignore a directory such as ubuntu @ ip-10-250-31-239: /$ sudo find-name apache2. /etc/init. d/apache2. /etc/logrotate. d/apache2. /etc/cron. daily/apache2. /etc/apache2. /etc/default/apache2. /usr/sbin/apache2 ............ 11. grep is a powerful text search tool that uses regular expressions to search for text and print matching rows. to make good use of the grep tool, you must write a regular expression $ ls-l | grep '^ A' to filter the ls-l output content through the pipeline, show only the rows starting with a $ grep 'test' d *. the rows containing test in the files starting with d $ grep 'test' aa bb cc are displayed in aa, bb, cc file line expansion command egrep command, search file acquisition mode. 12. man Linux provides a variety of help manuals. when you need to view the parameters of a command, you don't have to go online to search for it everywhere. just man. For example: ubuntu @ ip-10-250-31-239:/$ man ls shows ls usage and parameter Manual page ls (1) line 1 (press h for help or q to quit) it is best to enter q to exit the 13.ps command to display the status of A running process. each process has A specific id as the PID parameter:-A: all processes are displayed, it has the same effect as-e;-a: All processes not related to terminal;-u: process related to valid users; x: usually used with the parameter a to list complete information. Output format planning: l: list the PID information in a long and detailed manner; j: Job format-f: make a more complete output. Ps aux lists all programs currently in memory. ps-l lists the current PID and related information that you have logged on to. it is usually used with grep and 14. kill is used to kill processes that are irrelevant or have no response. to kill a process, you need to know the PID of the process. ps-ef view all processes under the current user ps-ef | grep httpd/ps-A | grep-I apache2 view the httpd pid and kill-pid end process * killall command kill all processes in the same process Group. It allows you to specify the name of the process to be terminated, rather than the PID. # Killall httpd # kill-hup pid: this command disables Linux and the slow execution process, and then restarts immediately. This command is convenient when you configure the application. you can execute this command when you need to restart the process after modifying the configuration file. 15. the whereis command is used to locate the command location, including the execution file, source code, and manual page File (locate the binary, source, and manual page files for a command ). If you want to find the location of any file, you can use the locate or find command whereis [-s] [-B] [-m] [-u] [{-S |-B |-M} Directory... }... -f] the file name to be searched-B searches for the binary part of the file. -M: The manual part of the search file. -S: Search for the source part of the file. -U files without instructions such as ubuntu @ ip-10-250-31-239 :~ $ Whereis postgresql:/etc/postgresql/usr/lib/postgresql/usr/include/postgresql/usr/share/postgresql 16. service commands control the start, stop, and restart of a service, it allows you to enable, stop, or restart a service without restarting the entire system. for example, service apache2 start service apache2 restart service apache2 stop 17. alias is a system-built shell command that allows you to specify aliases for long or frequently used commands such as: ubuntu @ ip-10-250-31-239 :~ $ Alias l = 'ls-L' ubuntu @ ip-10-250-31-239 :~ $ L total 11632 drwxr-xr-x 14 root 4096 Apr 18 10 canvas drwxr-xr-x 10 24561 staff 4096 Apr 18 node-v0.8.16-rw-r -- 1 root 11899509 Dec 12 2012 node-v0.8.16.tar.gz remove 'L' alias, to use the unalias command for example: ubuntu @ ip-10-250-31-239 :~ $ Unalias l ubuntu @ ip-10-250-31-239 :~ $ L: command not found ubuntu @ ip-10-250-31-239 :~ $ 18.df reports the disk usage of the system. It is useful for common users and system administrators to track disk usage. 'Df 'works by checking the directory size, but this value gets updated ubuntu @ ip-10-250-31-239 only when the file is closed :~ $ Df Filesystem 1K-blocks Used Available Use % Mounted on/dev/xvda1 8256952 2690192 5147332 35%/udev 294136 12 294124 1%/dev tmpfs 120872 200 120672 1%/run none 5120 0 5120 0%/run /lock none 302180 0 302180 0%/run/shm ubuntu @ ip-10-250-31-239: ~ $19. echo Show text ubuntu @ ip-10-250-31-239 :~ $ Echo "dian di yun" dian Diyun ubuntu @ ip-10-250-31-239 :~ $20. wget is a free tool for non-interactive (such as the background) file download. supports HTTP, HTTPS, FTP, and HTTP proxies such as wget url 21. free display memory status detailed explanation: function description: display memory status. Syntax: free [-bkmotV] [-s] Supplementary Note: The free command displays the memory usage, including the physical memory, virtual swap document memory, and shared memory segments, together with the buffer zone used by the system core. Parameter:-B displays memory usage in bytes. -K displays memory usage in KB. -MB: memory usage is displayed in MB. -O does not display the buffer adjustment column. -S: continuously observe the memory usage. -T: displays the total memory column. -V displays the version information. For example: ubuntu @ ip-10-250-31-239 :~ $ Free-m total used free shared buffers cached Mem: 590 572 17 0 130 256-/+ buffers/cache: 185 405 Swap: 0 0 0 22. ifconfig command for displaying or configuring a network device (network interface card) ubuntu @ ip-10-250-31-239 :~ $ Ifconfig eth0 Link encap: Ethernet HWaddr 22: 00: 0a: fa: 1f: ef inet addr: invalid Bcast: 10.250.31.255 Mask: invalid bandwidth limit 192 inet6 addr: fe80: 2000: aff: fefa: 1fef/64 Scope: Link up broadcast running multicast mtu: 1500 Metric: 1 RX packets: 3481075 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 1382616 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 1000 RX bytes: 3836200331 (3.8 GB) T X bytes: 194867450 (194.8 MB) Interrupt: 25 lo Link encap: Local Loopback inet addr: 127.0.0.1 Mask: 255.0.0.0 inet6 addr: 1/128 Scope: Host up loopback running mtu: 16436 Metric: 1 RX packets: 3294499 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 3294499 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen: 0 RX bytes: 1025117298 (1.0 GB) TX bytes: 1025117298 (1.0 GB) 23. netstat is used to display various network-related information, Parameters such as network connection, route table, Interface status (Interface Statistics), masquerade connection, and Multicast member (Multicast Memberships):-a (all) shows all options, by default, LISTEN-t (tcp) is not displayed. only tcp-related options-u (udp) are displayed. only udp-related options are displayed.-n indicates that aliases are not displayed. all numbers are converted to numbers. -L only list servers with Listen (Listener? MB? Nbsp;-p: the program name that establishes the relevant link-r: The route information is displayed, and route table-e: the extended information is displayed, for example, uid and other-s are counted according to each protocol.-c runs the netstat command at every fixed time. Tip: The LISTEN and LISTENING statuses can only be seen with-a or-l to list all ports netstat-a to list all tcp ports netstat-at to list all udp ports netstat-au
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.