Common Linux commands and tips

Source: Internet
Author: User
Tags control characters

Summary of common Linux commands:
I. Common commands:
1. Date: print or set the system date and time
2. stty-A: You can view or print control characters (CTRL-C, Ctrl-D, Ctrl-Z, etc)
3. passwd: change the password
4. logout and login: Shell logon and logout commands
5. pwd: view the current path
6. More, less, head tail: display or partial display of file content.
7. LP/lpstat/cancel, LPR/lpq/lprm: print the file.
8. Change file permissions: chmod U + X...
9. Delete non-empty directory: Rm-fr dir
10. Copy Directory: CP-r dir
11. FG jobid: You can place a background process to the foreground.
CTRL-Z can suspend the foreground process (suspend), and then use BG jobid to run it in the background.
Job & can directly run the job in the background.
12. The role of kill: send a signal to a process. eg: Kill-9 sends the sig_kill signal... You can view the specific signal sent by man kill.
13. PS usage, PS-E or PS-o pid, ppid, session, tpgid, comm (where session displays sessionid, tpgid shows the foreground Process Group ID, and comm displays the command name .)
Ii. Common Ubuntu commands:
1. dpkg: Package Manager for Debian
* Installation: dpkg-I package
* Uninstall: dpkg-r package
* Uninstall and delete the configuration file dpkg-p | -- purge package
* If a package is installed. Dependent on some databases. You can first apt-Get install somelib...
* View the package installation content: dpkg-l package
* Check which software package provides the file: dpkg-s filename
* In addition, dpkg also has dselect and aptitude frontend.
2. APT
* Installation: APT-Get install packs
* Apt-Get update: update source
* Apt-Get upgrade: upgrade the system.
* Apt-Get dist-Upgrade: Smart upgrade. Install new software packages and delete discarded software packages
* Apt-get-F install:-F = -- fix broken to fix Dependencies
* Apt-Get autoremove: automatically deletes useless software.
* Apt-Get remove packages: deletes software.
* Apt-Get remove package -- purge Delete the package and clear the configuration file
* Clear the residual configuration file of the deleted package: dpkg-L | grep ^ RC | awk '{print $2}' | tr ["/N"] [""] | sudo xargs dpkg-P
* Temporary directory for storing packages during software installation:/var/Cache/APT/Archives
* Clear the Directory: APT-Get clean
* Clear the old software cache of this directory: APT-Get autoclean
* Check the dependency package of some software: APT-Cache depends some
* Check which packages of software some depend on: APT-Get rdepends some
* Search software: APT-cache search name | Regexp
* View the function of the software package: APT-Cache show package
* View the compilation dependency library of a software: APT-Cache showsrc packagename | grep build-depends
* Download the software Source code : APT-Get source packagename (Note: Deb-SRC Source should exist in sources. List)
* When installing the software package source code, install its compiling environment: APT-Get build-dep packagename (with Deb-SRC Source)
* How to add a Local CD to the installation source list: APT-CDROM add
3. system command:
* View the kernel version: uname-
* Check the Ubuntu version: CAT/etc/issue.
* View the NIC status: ethtool eth0
* View the memory and CPU information: CAT/proc/meminfo; CAT/proc/cpuinfo
(/There is a lot of system information under proc)
* Print the usage of the file system space: DF-H
* View hard disk partitions: fdisk-l
* File size: Du-H filename;
* View the directory size: Du-HS dirname; Du-H dirname indicates the size of all files in the directory.
* View memory usage: Free-M |-G |-K
* View processes: PS-E or PS-Aux --> display users
* Kill the process: kill PID
* Force killall-9 processname
4. network problems:
* Configure ADSL: sudo pppoeconf
* ADSL Manual dialing: sudo Pon DSL-provider
* Activate ADSL: sudo/etc/PPP/pppoe_on_boot
* Disconnect ADSL: sudo poff
* Query NIC address based on IP Address: arping IP Address
* Local network information (including IP addresses) for production: ifconfig | ifconfig eth0
* View route information: netstat-R
* Disable the NIC: sudo ifconfig eth0 down
* Enable NIC: sudo ifconfig eth0 up
* Add a service: sudo update-rc.d service name defaults 99
* Deleting a service: sudo update-rc.d service name remove
* Temporarily restart a service:/etc/init. d/service name restart
* Temporarily close a service:/etc/init. d/service name stop
* Start a service temporarily:/etc/init. d/service name start
* The console displays Chinese characters: sudo apt-Get install zhcon
* Find a file: whereis filename or find directory-name file name
* Transfer files through SSH
SCP-RP/path/filename username @ remoteip:/path # copy the local file to the server
SCP-RP username @ remoteip:/path/filename/path # download the remote file from the server to the local device
5. Compression:
* Decompress a.tar.gz: Tar zxvf a.tar.gz
* Decompress a.tar.bz2: Tar jxvf a.tar.bz2
* Compress the AAA bbbdirectory as xxx.tar.gz: Tar zcvf xxx.tar.gz aaa bbb
* Compress the AAA bbbdirectory as xxx.tar.bz2: Tar jcvf xxx.tar.bz2 aaa bbb
6. Nautilus:
Special URI address
* Computer: //-all mounted devices and networks
* Network: //-browse Available Networks
* Burn: // a data virtual directory for burning CdS/DVDs
* SMB: //-available Windows/samba Network Resources
* X-Nautilus-desktop: //-desktop project and icon
* File: //-local file
* Trash: //-local recycle bin directory
* Ftp: //-FTP folder
* SSH: //-ssh folder
* Fonts: //-font folder. You can drag the font file here to complete the installation.
* Themes: //-system topic folder
* Display hidden files: Ctrl + H
* Display address bar: Ctrl + L
* View installed fonts: Enter "fonts: //" in the address bar of Nautilus to view all fonts on the local machine.
7. Supplement:
* View all local TPCs and UDP listening ports: netstat-tupln (t = TCP, u = UDP, P = program, L = listen, n = numric)
* Run man-K keyword. eg: Man-K user.
* You can also use apropos
* Actual disk space occupied by the Statistical File: du (Du-estimate file space usage)
* Characters in the statistics file, in bytes: WC-C/-L/-W (WC-print the number of newlines, words, and bytes in files)
* View the file content: OD-x/-C/... (OD-dump files in octal and other formats)
I think the most useful OD is the byte stream of the file: OD-T X1 filename
View the file's ASCII code format: OD-T c filename (the leftmost part of the statistics is the number of bytes)
* Find the location of the command file: Which OD output:/usr/bin/OD
Check which package provides the file: dpkg-S/usr/bin/OD output: coreutils:/usr/bin/OD
Check all the content of the coreutils package and you will know the Linux core command: dpkg-l coreutils
Then info coreutils Haha, learn it carefully. The whole world is a command!
* You can use the man command to view the interpretation of all sections of a command: Man-A tty
Then use Q, and next to convert to the next section.
* Bash shortcut keys:
CTRL + A: move the cursor to the beginning of the line.
CTRL + B: move the cursor to the left
CTRL + C: Kill the current process.
CTRL + D: exit the current shell.
CTRL + E: move the cursor to the end of the row.
CTRL + H: Delete the character before the cursor, which is the same as the backspace key.
CTRL + K: Clear the content from the cursor to the end of the row.
CTRL + L: clear screen, equivalent to clear.
CTRL + R: Search for commands that have been used before. There will be a prompt to search for bash history based on the keyword you entered
CTRL + u: Clear all content from the front of the cursor to the beginning of the line.
CTRL + W: Remove a word before the cursor
CTRL + T: two characters before the cursor position
CTRL + Y: paste or restore the last Deletion
CTRL + D: Delete the letter where the cursor is located. Note the difference with backspace and CTRL + H. The two are the characters before the cursor is deleted.
CTRL + F: move the cursor right
CTRL + Z: run the current process in the background and run the 'fg' command to restore the process. For example, top-D1, CTRL + Z, go to the background, then FG, and restore
* Quick paste: first select the text in a place, and then press the mouse button in the place where you want to paste it.
* Equivalent middle key: A. Pressing the pulley is equivalent to the middle key. B. Simultaneously pressing the left and right keys is equivalent to the middle keys.
* Restart x service quickly: press Alt + Ctrl + backspace at the same time.
* Open the "run" window: press Alt + F2 at the same time.
* Screen wear: A. Full Screen: press the prtscr key directly.
B. Current window: press Alt + prtscr at the same time.
C. delayed screen wear: Enter the command: gnome-screenshot -- delay 3 in the terminal or "run" window, and wear the screen after a delay of 3 seconds.
* Drag the file in the file manager to the gnome terminal to obtain the complete path name.
8. ulimit
Ulimit: displays (or sets) limits on resources that a user can use. These limits are divided into soft limits (current limits) and Hard Limits (upper limits ), the hard limit is the upper limit of the soft limit. Program The system resources used during the running process cannot exceed the corresponding soft limit. Any exceeding of the limit will lead to the termination of the process.
Ulimited does not limit the resources that users can use, but this setting sets the maximum number of files that can be opened (max open files)
The maximum number of processes that can run simultaneously (max user processes) is invalid.
-A: List the limits of all current resources.
-C: sets the maximum value of the core file. Unit: Blocks
-D. Set the maximum value of a process's data segment. Unit: Kbytes
-F shell: maximum size of the file to be created. Unit: Blocks
-H specifies the hard limit of a given resource. If you have root user permissions, you can increase the hard limit. Any user can reduce the hard limit
-L maximum value of physical memory that can be locked
-M: maximum value of the resident memory that can be used. Unit: Kbytes
-N maximum number of files that each process can open simultaneously
-P: sets the maximum value of the MPs queue, in the unit of block, 1 block = 512 bytes
-S indicates the maximum value of the stack. Unit: Kbytes.
-S specifies the soft limit for the given resource. The soft limit can be increased to the hard limit value. If the-H and-s signs are not specified, the limit applies to the above two
-T indicates the number of seconds used by each process. Unit: seconds.
-U maximum number of concurrent processes that can be run
-V shell indicates the maximum virtual memory available. Unit: Kbytes.
Eg: ulimit-C 1000 (you can first view the original value through ulimit-C)

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.