Common linux commands and tips

Source: Internet
Author: User
Tags control characters
Common linux commands and tips: Summary of common linux commands: 1. Common commands: 1. date: printorsetthesystemdateandtime2.stty-a: You can view or print control characters (Ctrl-C, Ctrl-D, Ctrl-Z, etc.) 3. passwd: printorsetthesystemdateandtime (common commands and tips for passwd linux:
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: print or set the system date and time (view with passwd-h)
4. logout and login: shell logon and logout commands
5. pwd: print or set the system date and time
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 source code of the software: apt-get source packagename (note: deb-src source should be included 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. the system resources used by the application during running cannot exceed the corresponding soft limit. any exceeding causes the process to terminate.
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.