Collect common Ubuntu commands [cainiao]

Source: Internet
Author: User

Software Package management of the Debian system Program (Its graphic front-end is a new place with great names), it will automatically help you deal with dependencies
Common parameters:
Update -- Update the package list with your software source (listed in/etc/APT/sources. List). Run
Upgrade-compare the source software library obtained by the update with the local one (if necessary ).
Install -- install the software package (you can use tab to complete the software package name, which is more convenient)
Remove -- uninstall the Software Package
Purge -- uninstall the software package and delete the configuration file of the software.
Source -- download the software package source code from the source to the current directory (the directory for executing this command) and decompress it (unless the-download-only parameter is specified)
This address is specified by the Deb-Src line in/etc/APT/sources. List.
Check -- used to (automatically) fix (installed) dependencies between software packages
Clean -- clear/var/Cache/APT/archives/cache of all software packages including its sub-directory partial/
Autoclean-is more common than clean. I understand that the cache of earlier versions is deleted and the later version is retained (or include software packages not in the current source ?)
This is added to PT. His suggestion is that aptitude has fewer crosslines than apt-get, and Tab completion is easier (=. = )~ Probably, shiniu is relatively lazy.
I have to mention the Ubuntu eggs that I have mentioned before: <only for Ubuntu 8.04>
Man apt -- at last we will see "this APT has super power" or "this APT has a super-cow power"
Man aptitude -- we can see that "this aptitude is not super powerful"
Looking at the aptitude parameters, you will understand why aptitude is named "advanced software package management program ".
Common parameters:
Search -- search for the software in the list of all software packages (your source). The search expression can be complex. For details, see man.
Other common parameters are the same as apt-Get.

Display (one or more) file content (connections) to standard output
When the text file is very small and you just want to see it and don't want to use a gedit or Vim editor to edit it, You Can cat It. I use it with grep.

Switch the current working directory
Unlike other commands, This is a shell built-in command, so there is no manual page to read... So it will appear in this articleArticleMedium (=. =) depressing
Common parameters:
. -- Switch to the current directory (it seems meaningless) (. This directory can be seen through LS-)
... -- Switch to the upper directory
~ -- Return to the home directory (/home/your login name /)

chmod :
change the File Permission bit
the permission bit of the Linux File System can be expressed in two ways, the mouse must be exhausted. =, so only the 8-in-number representation:
In brief, LS-l can display the file permissions, such as (-rwxr-XR -), represents the permissions of three users
the first rwx represents the permissions of the file owner (read, write, and execute), expressed in binary as 111, 4 + 2 + 1 = 7 in octal
the second R-X represents the permissions of other users in the same user group of the file owner, that is, (read, execute ), in binary format, the value is 101, which indicates 5 = 4 + 0 + 1 in octal.
the third R-represents the permissions of other users, that is, (read ,,), the binary value is 100, which indicates 4 = 4 + 0 + 0 in octal.
therefore, the permission bit of this file is 754.
This is the usage of CHMOD, for example, chmod 751 myfile # sets the File Permission to rwxr-X-x
the most common parameters:
-V -- list the currently executed steps
-r -- Recursive, that is, to change everything in a non-empty directory to the specified permission

Copy files and directories
Common parameters:
-B -- make a backup for each existing target file
-D -- if a soft link is encountered, the file to which the soft link is not copied; if the soft link is copied, The Links attribute (number of links) is retained)
-P -- retain the object access permission, owner, and timestamp
-R and-r -- Recursive copy (valid only when a non-empty directory is encountered in the CP process), that is, copy directories, subdirectories, sub-directories .....
-A -- same role as-DPR
-S -- it is not really a copy, but a soft link (symbolic link) for each file)
-U -- same as the-u parameter of the following mv

Head, tail
Like these two names, one is the header of the file, and the other is the tail of the file.
Common parameters:
-N -- specifies the number of output rows (header or tail). If this parameter is not set, 10 rows are displayed by default.

Configure the NIC
Common parameters:
No parameter -- list the status of the Active Network Card
-A: lists the statuses of all NICs.
Interface -- specify the NIC name, such as eth0
Up -- wake up the NIC
Down -- disable this Nic
Arp, MTU, netmask ADDR ,... And so on many parameters =. =

Create a link for a file
Linux links are divided into two types: hard links and soft links. ln creates hard links by default. You can search for the two types of links by yourself :)
Common parameters:
-S -- create a soft link (symbolic link, which can be understood as a shortcut in Win)
-F -- if the name of the link to be created already exists, delete it

Show directory content
Common parameters:
-A -- display all files in the specified directory, including files whose names start.
-L -- displays detailed information about a file, including the file type, permission, modification time, access time, size, and file name ...)
-H -- indicates the file size in the form of easy reading. It is often used with the-l parameter.

Read Reference Manual ~
ASIDE: HX says this is the most difficult command to learn in Linux. Because you have learned man well, there will be no command to beat you down, =. = invincible
Man can check more than just the command amount (of course, because man is invincible/CH)
Common parameters:
Man Arabic numerals
Arabic numerals 1: executable program (generally a user-installed program, if manpages is provided) and shell commands
Arabic numerals 2: system calls (such as open calls, socket calls, chmod calls, etc.), first install manpages-dev first
Arabic numerals 3: library function call (such as man 3 printf), first install manpages-dev first
When you execute man ls, the result is the same as that of MAN 1 ls, Because ls has only one entry in man manual.
When you want to see the CHMOD call manual page, you must specify MAN 2 CHMOD ~~ Because chmod has more than one entry
When a man is running, he can move up and down through J and K (similar to that in VI). He can search for the next one through/, and find the last match through N and N (similar to that in VI)
Q exit (similar to Vi ....)
Since man itself is a command, even man can be man =. =

Create a directory
Common parameters:
-P -- if the parent directory does not exist in the given path, the parent directory is created at the same time.

Mount :
mount a file system (which can be understood as mounting a partition)
common parameters:
-t -- specify the file system type, such as iso9660 (mounting an ISO image as a CD, equivalent to a virtual optical drive), NTFS, ext3, RFs and so on
-l -- list all mounted file systems, support volume labels
-A -- Mount all the partitions recorded in fstab
-n -- Do not write/etc/mtab during mounting
-o -- a commonly used parameter, specifies the "option" for mounting the file system, such as noatime, which is suitable for mounting a Bt dedicated partition
MV :
move or rename the file, depends on whether the target directory is the current directory
the most common parameters:
-B -- back up each existing target file (to prevent overwriting)
-f -- Do not prompt whether to overwrite the existing target file
-I -- opposite to the-F parameter
-u -- only when the source file is updated or move when the target file does not exist
-V -- displays the progress of the file to be moved (this parameter is always recommended for individuals, understand what you are doing)

PS, top:
Lists the execution status of the current command. The PS is static, and the top is dynamic ('q' exits when top is top)
PS: this command is more commonly used. I recommend it to you =. =
Most common parameters (PS multi-purpose parameter set, not a single parameter, and used with grep)
-Ef -- list all current process statuses using standard syntax, such as PS-Ef | grep Eva # list the process statuses of Eva.
Aux -- list in BSD syntax ......................................
-Ejh -- list process trees
-Elf -- list thread statuses at the same time

Rm, rmdir:
RM: delete a file or directory. rmdir: delete an empty directory. (This command is useless and can be replaced by RM-R)
Rm common parameters:
-F -- skip directly if the file does not exist.
-I -- a prompt is displayed for each Delete action (=. = if there are too many deletions, it will not be annoying)
-I -- if you delete multiple files (when there are more than 3 files) or recursively delete files (for non-empty directories), a prompt is displayed.
-R and-r -- recursively delete everything in this directory
-V -- display the delete action of each file (this parameter is always recommended for individuals to understand what you are doing)

Sudo, Su:
This is probably the first command to be used after the system is installed, right?
Sudo is mainly used for temporary elevation of permissions. It is mainly used for the Administrator (Super User) permission to run commands. When you need to modify the files/directories that cannot be reached by the current login user
Sudo or Su-C is required. Of course, sudo and Su are not effective in this way.
You can use mongodo to edit the/etc/sudoers file to modify more detailed actions of sudo (for example, remember the password timestamp length). Please be careful when modifying this!

Interpret and execute on the terminal
Similar to the './' format, but PT gives the difference: './' is only valid for programs with the execution permission under the current directory, 'sh' does not care about this set
Think too. './' is just a file path (in the current directory), but it is hard to say whether the file can be executed.
So SH is always correct.

Shut down the system. If you stay at tty, use commands such as halt and poweroff.
Common parameters:
+ M -- specify the minute of shutdown delay
-C -- cancel a request waiting for shutdown (you can also turn off the terminal that runs this command :))
Now -- immediate shutdown
Hh: Mm -- manually specify the time (in 24 hours)

This one is not too many's all taobao.gz,taobao.bz2.
Like the ps command, tar generally does not use a single parameter, but a combination of multiple parameters. Remember that parameter X is extracted (extract), and parameter C is the creation package (creat ).
Common parameters:
-Xvf-detailed steps to unpackage
-CVF-detailed steps for listing packages
-J --used to describe this is a tar.bz2 package, such as tar-xjvf myfile.tar.bz2
-T -- List objects in the package
-- Append parameters when packaging:
-R -- append to the compressed package
-U -- only append the files updated in the package
-H -- add the symbolic link to the file instead of adding it to the package.
Additional instructions: tar is a very powerful stuff. Common Operations are package and unpackage. For more information about advanced features, see man =. =.

Change the file timestamp. The default value includes the modification time and creation time. The default value is the current time. If the file does not exist, it will be created (=. = is it too cool)

Thanks to Ubuntu Linux Group (46603737) and group (514034120) for their help.

The purpose of this article is clear. It is only convenient for cainiao and does not include advanced commands.

If there are other similar commands not mentioned, add them in the comments :)

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: 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.