Basic commands for Linux (2)

Source: Internet
Author: User

New:

View CPU bits: getconf long_bit

View CPU information: More (CAT)/proc/cpuinfo

View CPU dynamic usage: Top

View memory: More (CAT)/proc/meminfo

View all memory: grep memtotal/proc/meminfo

1. Man provides help explanations for familiar or unfamiliar commands

For example: man ls, you can view the LS-related usage.

Note: Press Q or Ctrl + C to exit. in Linux, you can use Ctrl + C to terminate the current program.

2. ls view the directory or file owner * and list the files under any directory

Eg: ls/usr/man

Ls-l

A. D indicates the directory. If it is a "-", it indicates a file. If it is l, it indicates a connection file (link)

B. Permission for file or directory permission. Read (R), write (w), and run (x) respectively ).

3. Copy files using CP

Eg: CP filename1 filename2 // copy filename1 to filename2

CP 1.C netseek/2.c // copy 1.C to the netseek directory and name it 2.c.

4. rm delete files and directories

Eg: Rm 1.C // Delete the. c file.

5. Remove the directory or change the file name.

Eg: MV filename1 filename2 // rename filename1 to filename2

MV qib. tgz ../qib. tgz // move to the upper-level directory

6. Change the current directory pwd on CD to view the complete path of the current directory

Eg: Pwd // view the current directory path

CD netseek // enter the netseek directory

CD // exit the current directory

7. Cat, more command

Displays the content of a file. The two commands are different: cat prints the file content all the time, and more is displayed on the split screen.

For example; CAT> 1.C // You can paste the code into the. c file and press Ctrl + D to save the code.

Cat 1.C or more 1.C // you can view the content in it.

Gcc-O 1 1.C // compile 1.C into the. exe file. We can compile the Code with this command.

8. Modify the CHMOD command permission usage: chmod one-digit octal number filename.

Eg: chmod U + x filenmame // you only want to run the command for yourself.

// U indicates the file owner. G indicates the group of the file. O indicates others; r table readable; W table writable; X table can run

Chmod g + x filename // the same group of people to execute

9. Clear, date command

Clear: clear screen, equivalent to CLS in DOS; date: displays the current time.

10. mount a hardware device

Usage: Mount [parameter] device load point to be loaded

Eg: Mount/dev/CDROM

CD/mnt/CDROM // enter the CD directory

11. Su switches to another person's identity without logging out.

Usage: su-l user name (if the user name defaults, the user name is switched to the root state)

Eg: su-l netseek (switch to the netseek user and the user will be prompted to enter the password)

12. whoami, whereis, Which, ID

// Whoami: confirm your identity

// Whereis: queries the directory where the command is located and the directory where the help document is located

// Which: query the directory where the command is located (similar to whereis)

// ID: print your UID and GID. (UID: the unique ID of a user. GID: the unique ID of a user group. Each user can have only one unique UID and gid)

Eg: whoami // display your login user name

Whereis bin: the directory where the bin is located. The directory is/usr/local/bin.

Which Bin

13. grep, find

Grep: Text Content Search; find: file or directory name and permission owner matching search

Eg: grep success */* Find all files in the current directory that contain success characters

14. Kill can kill a running or DEST process.

Eg; PS ax

15. passwd can be used to set a password

16. commands used by the history user

Eg: History // displays the commands used by the user in the past.

17 .!! Execute the last command

18. mkdir command

Eg: mkdir netseek // create the netseek directory

19. Tar decompression command

Eg: tar-zxvf nmap-3.45.tgz // extract this to the nmap-3.45 directory

20. Finger allows users to query data of other users

Eg: Finger // view usage information of all users

Finger root // view the Root Information

21. uname-[Option]: view system information

22. df-H view disk Information

23. In the text editor, you can use "/" + in command mode to search for text content.

24. In the text editor, you can use Shift + G in command mode to quickly locate the end of the text.

25. In putty, "/ls" can be used to display text in white. Easy to view.

26. You can enter only some file names and press the tab key twice to automatically fill in the complete file name. This is very useful! This method can also be used when you forget the full name of a command!

27. view memory in free mode

28. Top View Task Manager

29. view the Linux release version

CAT/etc/RedHat-release // for Redhat

CAT/etc/issue

CAT/proc/version (view the Linux kernel version)

30. W command to view the status of online users.

31. chfn modify the user's finger information

32. wget download from the Internet

33. Yum-y install (RedHat series online installation package)

34. Tar xzvf decompress the tar.gz package and tar xvjfdecompress the tar.bz2 package.

35. Content in bzcat tar.bz2.

36. Scanner NMAP: Usage: NMAP 192.168.0.253 (only scan for TCP ports), NMAP-SS-su-Sr NMAP (SCAN both TCP and UDP ports and RPC-based services)

37. sniffer tcpdump: Usage: TCPDUMP-I eth0-X DST 192.168.0.253 or tcpdump-I eth0-X DST 192.168.0.253 and DST port 21 indicates capturing packets on port 21 only.

38. Log Server syslog: Usage: 1. First modify the/etc/syslog. conf configuration file 2. Service syslog restart 3. first check the log file/var/log/* Recommended Log Analysis Software

Swatch. There are also lire and other analysis software.

39. Tail filename: view the content at the end of the file. You can add the-F parameter, such as tail-f filename, to monitor system changes.

40. packet Processing Method: for example, iptables-A input-p icmp-J accept (Set firewall rules: accept all ICMP packets ), iptables-F (clear the configured firewall rules), iptables-l-N

41. Host hostname resolves a host name to an Internet address or an Internet address to a host name.

42. Cat-N filename (-N indicates that the row number is added ).

43. Tail + 16 file1> file2 (that is, the content after the first row of file1 is appended to file2 ).

44. smbtree-B. smbclient, NSlookup, dig, host, route-N, dhclient,

45. rpm-Q packet (check whether a package is installed), rpm-Qa | grep packet (check whether all packages containing the packet name are installed ). Rpm-uvh/-IVH packet (installation packet)

Rpm-e packet (delete and detach a package that has already been installed) and rpm-e -- nodeps packet (delete and detach a package while ignoring the dependency of the package ).

46. CP file1 file2 (copy file1 to file2 ).

47. Rename the file or directory: MV. Create File: Touch filename or> filename

48. view the host name hostname-V newhostname and modify the Host Name

49.> output redirection, <input redirection,> redirect appending, | MPs queue

50. netstat-tnl

51. View emails via mail

52. chkconfig XXX on/off start/close a service chkconfig XXX -- list to check whether a service is enabled

53. grep Hello/etc/test.txt search for text containing the hello string in test.txt

54. Host-t mx hostname

55. md5sum-c xxx. MD5 checks the downloaded software.

56. common steps for installing software in Linux source code: 1 .. /configure (configure the compilation environment, generate the configuration file and MAKEFILE file) 2. make (compile and generate binary code) 3. make install (installation)

57. The. So library file in Linux is similar to the. dll library file in win.

58. Make &> make. log & (redirects the compilation process to the make. Log File and runs it in the background). You can use tail-F make. log to monitor the log file.

59. mkfs format the file system and fdisk-l view the partition information. Fdisk disk partition

60. Links http://www.google.cn or Lynx http://www.google.cn access a website

61. If the website provides an MD5 check code instead of an MD5 check code file, you can use the md5sum xxx.tar.gz command to compare the MD5 obtained from the website with the MD5 on the website to see if it is consistent.

62. ID Username: Check the user ID or whether the user exists.

63 ../configure -- help | more view the configure script help.

64. useradd-D/usr/local/var MYSQL: Create a MySQL user and specify/usr/local/VaR as its home directory.

65. Su-Username)

66. Make; make install two commands, make and make install, can be executed using semicolons in the middle. Or multiple commands.

67. Service XXX start/stop/restart/status start/stop/restart/view a service.

68. locale view the current system language and code. Locale-a view the currently supported languages and Their encoding. Change the language environment: Export lang = "en_US.UTF-8"

69. Tail-N 20 filename to view the content of the last 20 lines of the document.

70. killall-hup httpd restart the HTTPd service.

71. mkdir dir1 dir2 dir3 creates multiple directories.

72. The LS-L/-lH LS-lda directory displays the details of this directory.

73. Echo $ shell displays the Current Shell

74. umask Directory: 7-umask file: 7-umask-1 if it is umask 022, the permission is 755 for the Directory and 644 for the file.

75. Hard link: ln soft connection: ln-S

76. Alias eth0: view the alias of eth0.

77. Touch 'myfile' to create a file named myfile. (Single quotes ).

78. lspci: view the NIC model. Lspci | grep Ethernet

79. dmesg view hardware information. Dmesg | grep ETH view Nic information.

80. lsmod View module.

81. ifconfig/All (ifconfig-a) view all network adapters and MAC addresses of the system. ifconfig/release releases the IP address, ifconfig/Renew retrieves the IP address again, And ifconfig eth0 displays the eth0 information of the network adapter. IFUP eth0, ifdown eth0, ifconfig eth0 down, ifconfig eth0 up. Stop/start the NIC.

83. pstree-p | more view the process tree

84. tty local terminal

PTS/2 Remote Terminal

85. Echo $? If the program is correctly executed, 0 is displayed; otherwise, 127 is displayed.

Echo $ display process number

86. The process PID is the core process of the system and cannot be killed. (PS-Aux | more)

PS-Ef | more

87. switchdesk TWM

88. vmstat

89. gnome-system-monitor graphical Process Monitoring

Kinfocenter (requires KDE) Graphical Process Monitoring

Ksysguard (requires KDE) Graphical Process Monitoring

90. fg bg jobs

91. kill-HUP 1 restarts process 1.

92. Kill-l view Signal

93. Press the K key to run the TOP command to kill the process.

94. PS-Ef | more

95. Kill-9 PID (process ID) kills the process whose process is PID.

96. The plus sign of jobs indicates the new process. -Indicates the process that is near.

97. Service xinetd restart the system service.

98. view system services in a graphical manner using ntsysv.

99. During Linux installation, press Alt + F2 on the partition interface to enter the character interface. You can use the fdisk command to partition. After partitioning, press Alt + F1 to return to the installation page.

100. chkconfig -- list to view all the system services enabled.

Chkconfig -- list httpd: Check whether the HTTPd service is enabled.

Chkconfig httpd On/Off enable/disable the HTTPd service.

Chkconfig -- add/-- del XXX Add/Delete the xxx service.

101. Service XXX start/restart the xxx service.

102. Shift + Pageup/Pagedown page flip.

103. CP-r/-

104 temporarily disable a user: change the password mark X of the corresponding user under/etc/passwd! You can. The user cannot log on.

105. Modifying the User Shell under/etc/passwd can also prevent users from logging on, for example, changing/bin/sh to/bin/passwd.

106. delete a user: userdel XXX deletes the user account, but the user's main directory still exists. Therefore, the application userdel-r XXX deletes the user completely.

107. useradd-u 550-D/tmp/user-S/bin/sh-P 123456 superxgl customizes user attributes when creating a user, such as user uid, Home Directory, shell, and password.

108. When a root user logs on, the root environment variable is used when Su AAA switches to AAA. You can use echo $ path to view the variable. Therefore, we should use Su-AAA to switch the environment variables with general user AAA (switching between common users ). We recommend that you do not use root logon. Switch to root when necessary.

109. How to prevent other users from logging on in a multi-user environment: Add a nologin file like touch/etc/nologin to prevent normal users from logging on. Delete the file when it is removed.

110. RedHat-config-users: Enter the user account management interface.

111. query XXX packages by rpm-q xxx.

Rpm-Qa | grep XXX queries whether the RPM package of XXX is installed or detailed information about the package, such as the version number.

112. ext3 has more log support than ext2.

113. Set to view local variables.

114. Read-only-P to view Read-Only variables.

115. A logon process is called a parent process, and all user processes executed in shell are called Child processes.

116. You can use env to view environment variables in export settings, or directly use export to view the environment variables.

117. To view the PS, you can use set | grep "Ps", and then use PS1 = "-Bash-3.2" to change the prompt. PS2 is used for loop.

118. Sh-version to view the shell version.

119. Du, Du-S, or Du-K lists the space occupied by a directory.

Du-S | sort-N can quickly find that the directory is the largest.

120. use DF to view the space and remaining space of the installed file system. DF-H

121. Quota-V to view the user's disk space information, if you use quota to limit the user space size.

122. File/sbin/init: Check whether the machine is a 32-bit or 64-bit machine.

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.