Summary of commonly used linux commands in ubuntu, and customized tulinux commands
I have been in the lab for nearly a month and barely touched windows. I have been developing it in ubuntu. I would like to summarize the commonly used linux commands.
(0) su and sudo:Get root permission
Su switches to root user sudo command to root user, executes command, and then switches back to current user su liaohuqiang to normal user
(1) apt:Used to install software packages
Apt list lists software packages by name apt show software package details sudo apt install Installation Software Package sudo apt remove uninstall software package sudo apt-get check dependency sudo apt update available software package list sudo apt upgrade by Installation /upgrade the software to update the system.
(2) pip:Used to install the python module (not the default command in linux, you need to install sudo apt install pip on your own)
Pip install installation package pip uninstall package pip list Installed packages pip show information of installed packages pip check dependency pip -- version show pip version and position pip help view help pip help install view options of the install command
(3) ssh and scp:Inter-host communication
Ssh username @ ip login to remote host scp local_file username @ ip: remote_directory copy local file to remote host scp-r local_directory username @ ip: remote_directory copy local folder to remote host
(4) compression and decompression:Zip, unzip, tar
Zip-r target.zip. compress all the subfolders in the current directory and the current directory to zip target.zip. If there is a folder, It is not compressed (because-r is not added) unzip source.zip-d 'folder' decompress the package to unzip source.zip in the folder directory and decompress it to tar-zcvf target.tar.gz sorceFoler c in the current directory. z indicates compressed/decompressed with gzip, v detailed report processing information. f is required and the file name tar-zxvf source.tar.gz-C 'folder' is followed. decompress the file to the folder directory, where z indicates the gzip attribute and x indicates decompression, v indicates that the relevant information is output during decompression. f must be included and put to the end with a file name. Tar-xvf source.tar.gz: You can try it with less z. The effect is the same as above.
(5) view disk storage usage:Du; view the storage usage of the file system: df.
Du-s or -- summarize only displays the total, and only lists the last added total value. Du-h is in the unit of K, M, and G to improve information readability. Df-h is measured in K, M, and G units to improve information readability. Df-T x display file system type
(6) Search for commands
6.1 which searches for the location of a system command in the PATH specified by the PATH variable and returns the first search result.
6.2 whereis can only be used for searching program names, and only binary files (parameter-B), man description files (parameter-m), and source code files (parameter-s) can be searched ). If the parameter is omitted, all information is returned.
6.3 locate works with the database to view the file location. Linux records all files in the system in a database file, but the database is not updated in real time.
6.4 find the name of the file actually searched by the hard disk.
Find.-name '*. conf' the current directory searches for files with the extension of. conf. updatedb updates the locate string of the database and quickly finds the specified content in the system database.
Whereis python
Which python
(7) File Permissions
Chmod [ugoa] [+-=] [rwx] permission to change the specified directory or file by file name or path
U stands for the owner of the file, g stands for the same group of users of the file owner, o stands for other + stands for adding permissions,-stands for canceling permissions, = stands for unique set permissions r readable, w writable, x execute chmod u + x test. The owner of the file adds the executable permission to be represented by numbers. The r = 4, w = 2, x = 1, all three users of chmod 777 test grant the readable and executable permissions. chown username [: group name] File Name or directory changes the user of the specified directory or file.
(8) file and text operations
Grep str/tmp/test search strgrep ^ str/tmp/test in the file/tmp/test to find the line ls-ld */display starting with str in the file/tmp/test. all directory files in the current directory ls-l | grep '^ d' show all directory files in the current directory wc-l number of statistics file lines wc-w count word count ls-l | wc- l count the current number of files, note that the line cp-a dir1 dir2 under "total usage" should be subtracted from the copy directory mv dir1 dir2 to move/rename the directory mkdir-p/tmp/dir1/dir2 to create a directory tree rm-f file1 delete the rm-rf dir1 file to delete the Directory
(9) Process
Ps-e shows all processes ps-f display process ps-u 'liaohuqiang '| grep 'tmux' displays the processes executed by the specified user, and match the line of process kill-2 pid containing 'tmux '. The pid is similar to ctrl + C, and relevant data can be saved before the program ends, then exit kill-9 pid directly force stop process top dynamic display process information top-I no show any idle or useless process k kill a process n change display process count u show specified user p. sort by CPU usage q. Exit
(10) Network
Netstat displays network conditions netstat-a lists all ports netstat-l only displays the listening port netstat-t lists all tcp ports netstat-p displays the pid and program name netstat-n using this port directly use IP address, run netstat-anp | grep ssh to find the process running on the specified port without using the Domain Name Server: netstat-anp | grep ': 80' ifconfig to view the NIC Information
(11) Others
Date display time whoami display current user name who currently logged on to the system user information curl 'url'-O -- progress download file,-O indicates to save the file (if not, output to the screen ), -- progress indicates that the progress bar will be displayed (curl is not the default for linux, you need to install apt install curl) echo $ SHELL to check which shellecho $ PATH is used by the system to view the Environment Variables
These are some of the commands that I recently used.
Finally, we recommend a website for linux instruction learning and fast query: http://man.linuxde.net/