Linux Common commands and tips
Linux common commands and tips:
Linux Common Commands Summary:
One. General Command:
1. Date:print or set the system date and time
2. Stty-a: can view or print control characters (ctrl-c, ctrl-d, ctrl-z, etc.)
3. Passwd:print or set the system date and time (viewed with passwd-h)
4. Logout, Login: Login and logoff command for logon shell
5. Pwd:print or set the system date and time
6. More, less, head tail: Displays or partially displays the contents of the file.
7. Lp/lpstat/cancel, LPR/LPQ/LPRM: Print the file.
8. Change file permissions: chmod u+x ...
9. Delete a non-empty directory: Rm-fr dir
10. Copy directory: Cp-r dir
FG Jobid: A background process can be placed in 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 directly in the background.
The role of Kill: Send a signal to a process. Eg:kill-9 is sending the Sig_kill signal ... What signal is sent can be viewed through man kill.
Usage of PS, ps-e or Ps-o pid,ppid,session,tpgid, Comm (where session shows the SessionID, Tpgid shows the foreground process group ID, Comm displays the command name. )
Two. Ubuntu Common commands:
1. Dpkg:package Manager for Debian
* Installation: Dpkg-i Package
* Uninstall: Dpkg-r Package
* Uninstall and delete profile: Dpkg-p |--purge Package
* If a package is installed. Said to rely on some libraries. You can first Apt-get install somelib ...
* View Package installation content:d Pkg-l packages
* See which package is available for the file: dpkg-s filename
* There are also dselect and aptitude two frontend in addition to the dpkg.
2. Apt
* Installation: Apt-get Install packs
* Apt-get Update: Updating source
* Apt-get Upgrade: Upgrade the system.
* Apt-get dist-upgrade: Smart upgrade. Install new packages, remove obsolete packages
* Apt-get-f Install:-F = =--fix Broken Repair Dependency
* Apt-get autoremove: Automatic removal of useless software
* Apt-get Remove Packages: Remove software
* Apt-get Remove Package--purge Remove packages and clear configuration files
* Remove the residual profile for the package: dpkg-l |grep ^rc|awk ' {print $} ' |tr ["/n"] [""]|sudo Xargs dpkg-p
* Temporary storage directory for packages when installing software:/var/cache/apt/archives
* Clear this directory: Apt-get clean
* Clear the old version of the software cache for this directory: Apt-get AutoClean
* Query software some dependency package: Apt-cache depends some
* Query software some by which package depends on: Apt-get rdepends some
* Search Software: Apt-cache search Name|regexp
* Check the role of the package: Apt-cache Show Packages
* View a compilation dependency library for a software: Apt-cache showsrc packagename|grep build-depends
* Source code of the downloaded software: apt-get source PackageName (Note: There should be deb-src source in sources.list)
* Install the package source code at the same time, install its compilation 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 Kernel version: Uname-a
* View Ubuntu version: Cat/etc/issue
* Check NIC status: Ethtool eth0
* View memory, CPU information: cat/proc/meminfo; Cat/proc/cpuinfo
(There are a lot of system information/proc below)
* Print File system space usage: df-h
* View hard disk partition: Fdisk-l
* Production look file size: du-h filename;
* View Directory Size: Du-hs dirname; Du-h DirName is to view the size of all files in the directory
* View Memory Usage: free-m|-g|-k
* View process: PS-E or Ps-aux--show Users
* Kill the process: Kill PID
* Forced Kill: killall-9 ProcessName
4. Network-Related:
* Configuration Adsl:sudo pppoeconf
* ADSL manual dialing: sudo pon dsl-provider
* Activate Adsl:sudo/etc/ppp/pppoe_on_boot
* Disconnect Adsl:sudo Poff
* According to IP check NIC address: arping IP Address
* Production to see local network information (including IP, etc.): ifconfig | Ifconfig eth0
* View routing information: Netstat-r
* Switch off the NIC: sudo ifconfig eth0 down
* Enable NIC: sudo ifconfig eth0 up
* Add a service: sudo update-rc.d service name defaults 99
* Delete a service: sudo update-rc.d service name remove
* Temporarily restart a service:/etc/init.d/Service Name restart
* Temporarily shut down a service:/etc/init.d/service name stop
* Temporarily start a service:/etc/init.d/service name start
* Under Console display Chinese: sudo apt-get install Zhcon
* Find a file: Whereis filename or find directory-name file name
* Transfer files via SSH
scp-rp/path/filename [Email Protected]:/path #将本地文件拷贝到服务器上
SCP-RP [Email Protected]:/path/filename/path #将远程文件从服务器下载到本地
5. Compression:
* Unzip A.tar.gz:tar ZXVF a.tar.gz
* Unzip A.tar.bz2:tar JXVF a.tar.bz2
* Compression AAA BBB Catalog for Xxx.tar.gz:tar ZCVF xxx.tar.gz AAA BBB
* Compression AAA BBB Catalog for 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 items and icons
* 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 Theme Folder
* Show hidden files: ctrl+h
* Show Address bar: Ctrl+l
* View installed Fonts: Enter "fonts:///" in the Nautilus's address bar to view all fonts on this machine
7. Supplementary sections:
* View all local TPC,UDP listening ports: NETSTAT-TUPLN (T=tcp, U=UDP, P=program, L=listen, N=numric)
* Through man search said the relevant command: MAN-K keyword. Eg:man-k User
* or with Apropos
* Actual disk space occupied by the statistics file: Du (du-estimate file space usage)
* Statistics file characters, Bytes: wc-c/-l/-w (wc-print the number of newlines, words, and bytes in files)
* View the contents of the file: od-x/-c/.... (od-dump files in octal and other formats)
I think the most useful od is the file byte stream: od-t x1 filename
View the Ascii form of the file: od-t C filename (where the leftmost statistic is: bytes)
* Locate the file where the command is located: which OD output:/usr/bin/od
See which package the file is provided with: dpkg-s/usr/bin/od output: coreutils:/usr/bin/od
Check out the full contents of the Coreutils package and know the Core Linux command: Dpkg-l coreutils
Then info coreutils haha, seriously learn it, the all over the command!
* The explanation of all sections of a command can be produced with the man command: Man-a TTY
Then use Q, and next to translate the explanation to the next section
* Bash's handy shortcuts:
CTRL + A: The cursor moves to the beginning of the line.
CTRL+B: The cursor moves left one letter
CTRL + C: kills the current process.
Ctrl+d: Exits the current Shell.
Ctrl+e: The cursor moves to the end of the line.
Ctrl+h: Deletes the previous character of the cursor, same as the BACKSPACE key.
Ctrl+k: Clears the contents of the cursor to the end of the line.
Ctrl+l: Clear screen, equivalent to clear.
Ctrl+r: Search for previously played commands. There will be a hint to search for the history of bash based on the keywords you entered
Ctrl+u: Clears all content before the cursor to the beginning of the line.
Ctrl+w: Remove a word before the cursor
Ctrl+t: Swap two characters before the cursor position
Ctrl+y: Paste or restore the last delete
Ctrl+d: Delete the letter of the cursor, note the difference between backspace and ctrl+h, and these 2 are the characters before the cursor is deleted.
CTRL+F: Cursor Right Shift
CTRL + Z: Move the current process to the background and use the ' FG ' command to recover. Like top-d1 then CTRL + Z, into the background, then FG, re-restore
* Quick paste: First select the text in one place, click the middle mouse button in the place where you want to paste.
* Equivalent Middle key: A, press the pulley equivalent to the middle button. b, at the same time press the mouse key, equivalent to the middle button.
* Fast Restart X service: Press: Alt + Ctrl + Backspace three keys.
* Open the Run window: Press the ALT + F2 key at the same time.
* Dai: A, Full screen: Press the PRTSCR key directly.
B, Current window: Press ALT + PRTSCR key at the same time.
C, Delay Dai: Enter the command in terminal or "Run" window: Gnome-screenshot--delay 3, will delay 3 seconds after Dai.
* Simply drag files from the File Manager to the GNOME terminal to get the full pathname in the terminal.
8. Ulimit
Ulimit: Displays (or sets) the limits of the resources that the user can use, which are limited to soft limits (current limit) and hard limits (caps), where the hard limit is the upper limit of the soft limit, and the system resources used by the application do not exceed the corresponding soft limit in the run process. Any transcendence leads to the termination of the process.
Ulimited does not restrict the resources that users can use, but this setting sets the maximum number of files that can be opened (max Open file)
And the maximum number of processes that can run concurrently (max user processes) is invalid
-A lists all current resource limits
-C Sets the maximum value of the core file. Unit: Blocks
-D sets the maximum value of the data segment for a process. Unit: Kbytes
-F Shell The maximum file size of the created file, in: Blocks
-h Specifies to set the hard limit for a given resource. If the user has root user rights, the hard limit can be increased. Any user can reduce the hard limit
Maximum number of physical memory that can be locked by-l
The maximum number of resident memory that can be used by-M, in: Kbytes
-N Maximum number of files per process that can be opened at the same time
-P Sets the maximum value of the pipe in block,1block=512bytes
-s Specifies the maximum value of the stack: unit: Kbytes
-s specifies to set the soft limit for a given resource. The soft limit can be increased to the value of the hard limit. If the-H and-s flag are not specified, the limit applies to both
-t specifies the number of seconds to use per process, in units: seconds
The maximum number of concurrent processes that can be run by-u
The maximum amount of virtual memory that the-V shell can use, in units: Kbytes
EG:ULIMIT-C 1000 (You can see the original value by Ulimit-c first)
This article comes from Chinaunix blog, if you look at the original point: http://blog.chinaunix.net/u1/34627/showart_466111.html
Common commands and tricks for Linux