Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the common commands of Ubuntu

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the use of Ubuntu common commands". In daily operation, I believe many people have doubts about the use of Ubuntu common commands. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about the use of Ubuntu commands. Next, please follow the editor to study!

After working hard to learn Ubuntu common commands, I would like to discuss with you that you may encounter the problem of using Ubuntu common commands. After reading this article, you must have a lot of gains. Here will introduce the solutions to the problems in the use of Ubuntu common commands. Here we will talk about how to automatically upgrade XX after installation. This process is relatively slow and is still under implementation.

I just collected some common Ubuntu commands on the Internet and sorted them out for future use.

Ubuntu common commands apt-get:

The software package manager of the debian system (whose graphical front end is the famous Xinlide) will automatically help you deal with your dependencies.

Most commonly used parameters:

Update-- updates the package list with your software source (listed in / etc/apt/sources.list), which needs to be executed after changing the source.

Upgrade--, based on the comparison of the source software libraries obtained by update with those already installed locally, upgrade all (if needed).

Install-- installation package (you can use tab to complete the name of the package, which is convenient)

Remove-- uninstall package

Purge-- uninstalls the package while deleting the configuration file for the software

Source-- downloads the source code of the package from the source to the current directory (the directory where this command is executed) and decompresses it (unless you specify the-download-only parameter)

The address is specified by the deb-src line in / etc/apt/sources.list

Check-- is used to (automatically) repair (installed) dependencies between software packages

Clean-- clears / var/cache/apt/archives/ includes all package caches under its subdirectory partial/

Autoclean-more common than clean, my understanding is to delete the lower version of the cache and keep the higher version (or include packages from non-current sources?)

Aptitude:

This is added by PT. What he said is that aptitude has fewer horizontal lines than apt-get, and tab completion is easier (=. =) ~ maybe Shenniu is lazy.

I have to mention the ubuntu eggs mentioned before by the Egg Children's shoes:)

Man apt--*** will see that "Ben apt is super powerful" or "this APT has a super-cow power"

Man aptitude-- you will see that "this aptitude is not super awesome."

Look at the parameters of aptitude and you will see why aptitude is labeled "advanced package manager"

Most commonly used parameters:

Search-- searches for the software in the list of all packages (of your source). The expression of search can be very complex, as shown in man.

Other commonly used parameters are the same as apt-get

Ubuntu common commands cat:

Display the contents of (one or more) files (links) to standard output

When the text file is small and you just want to take a look at it and are not going to edit it with an editor like gedit or vim, you can cat it. I use it with grep.

Ubuntu common commands cd:

Switch the current working directory

Unlike other commands, this is a shell built-in command, so there is no manual page to read. Basic enough, that's why it appears in this article (=. =) depressed

Most commonly used parameters:

.-- switch to the current directory (it doesn't seem to make any sense). This directory can be seen through ls-a)

..-- switch to the upper directory

~-- return to the home directory (/ home/ your login /)

Ubuntu common commands chmod:

Change the permission bits of a file

There are two ways to express the permission bits of a linux file system. If you talk about it in detail, you have to be tired to death. =, so only say octal numbers:)

A brief introduction: ls-l can show the permissions of the file, such as (- rwxr-xr-), which represents the permissions of three types of users

* rwx, representing the permissions of the file owner, that is, (read, write, execute), expressed as 111in binary, representing 4'2'1'7 in octal

The second rmurx, representing the permissions of other users in the same user group of the file owner, namely (read, execute), is expressed as 101 in binary and represents 5 percent 4 percent 0 percent 1 in octal.

The third rmurf, which represents the permissions of other users, that is, (read,), is expressed as 100 in binary, which represents the octal 4 "4" 0.

So the permission bit of this file is 754

This is the use of chmod, for example, chmod 751myfile # sets the file permissions to rwxr-x-x

Most commonly used parameters:

-vMurt-list the steps that are currently being performed

-Rmure-Recursive, that is, to change everything under a non-empty directory to a specified permission

Cp:

Copy files and directories

Most commonly used parameters:

-bMurt-make a backup of every existing destination file

-dmurf-do not copy the file pointed to by the soft link when you encounter a soft link; keep the links attribute (number of links) when copying

-pmurf-retains the access, owner, and timestamp of the file

-R and-r-- Recursive copy (the cp process is valid only if there is a non-empty directory), that is, copy directories, subdirectories, subdirectories of subdirectories. ..

-a muri-action is the same as-dpR

-smurf-doesn't actually make a copy, but just makes a soft link for each file (symbolic link)

-Umuri-same as the-u parameter of mv below

Ubuntu common commands head, tail

Like these two names, one shows the head of the file and the other shows the tail.

Most commonly used parameters:

-nMurt-specifies the number of lines (header or trailer) output. When this parameter is not available, 10 lines are displayed by default.

Ifconfig:

Configure the network card

Most commonly used parameters:

No parameters-list the status of the currently active Nic

-a-- list the status of all network cards

Interface-- specify the name of the network card, such as eth0

Up-- Wake up the network card

Down-- closes the network card

Arp,mtu,netmask addr,... Wait, many parameters =. =

Ln:

Establish a link for the file

There are two kinds of links in linux: hard links and soft links. Ln establishes hard links by default (hard link). Search for the difference between the two.)

Most commonly used parameters:

-Smuri-establish soft links (symbolic links, which can be understood as shortcuts under win)

-fmurf-if the link name you want to establish already exists, delete it

Ls:

Show catalog contents

Most commonly used parameters:

-a color-displays all files in the specified directory, including the file name. Beginning of the file

-lmurf-displays file details (including file type, permissions, modification time, access time, size, file name …)

-hmurf-indicates the file size in an easy-to-read form, which is often used in conjunction with the-l parameter.

Man:

Read the reference manual of~

Digression: HX said that this is the most difficult command for linux to learn, because if you learn man well, no command can defeat you. =. = invincible

Man can check more than just the command amount (of course, because man is invincible / ch)

Most commonly used parameters:

Man Arabic numerals

Arabic numeral 1: executable programs (programs typically installed by the user, if manpages is provided) and shell commands

Arabic numeral 2: system calls (such as open calls, socket calls, chmod calls, etc.), install manpages-dev first

Arabic numeral 3: library function calls (for example, man 3 printf), install manpages-dev first

…… .

When you execute man ls, the result is the same as man 1 ls, because ls has only one entry in the man manual

When you want to see the man page of chmod calls, you should specify man 2 chmod ~ ~ because chmod has more than one entry

In man, you can move up and down through jjournal k (similar to vi), you can use / query to find the next match and the last match (similar to vi).

Q exit (also similar to vi … (.)

The more interesting thing is:

Because man itself is a command, even man can be man. =

Mkdir:

Create a directory

Most commonly used parameters:

-pmurf-if the parent directory does not exist in the given path, create the parent directory at the same time

Mount:

Mount the file system (which can be understood as mounting a partition)

Most commonly used parameters:

-tmure-specify the file system type, such as iso9660 (mount iso image as CD, equivalent to virtual optical drive), ntfs,ext3,rfs, etc.

-lmurf-lists all mounted file systems and supports volume labels

-a Mel-Mount all partitions recorded in the fstab

-nMurt-do not write / etc/mtab when mounting

-Omuri-A parameter that is quite commonly used to specify the "option" for mounting the file system, such as noatime, which is suitable for mounting BT dedicated partitions.

Mv:

Move or rename a file, depending on whether the destination directory is the current directory

Most commonly used parameters:

-bMurt-make a backup of every destination file that already exists (prevent overwriting)

-fmurf-does not prompt whether to overwrite the existing destination file

-iMurt-contrary to the-f parameter

-Umure-move only when the source file is newer than the destination file or when the destination file does not exist

-vMurt-shows the progress of moving files (individuals always recommend this parameter to understand what you are doing)

Ps,top:

Lists the execution status of the current command. Ps is static, top is dynamic ('q' exits when top)

Ps: this command is more commonly used by myself. I recommend it to you.

Most commonly used parameters (ps multipurpose parameter collection rather than a single parameter, and used with grep)

-ef-- lists all current process states in standard syntax, such as ps-ef | grep eva # lists the process status of eva

Aux-- is listed in BSD syntax. ..

-ejH-- list the process tree

-eLf-- list thread status 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)

The most commonly used parameters of rm:

-fmurf-do not prompt for files that do not exist, just skip them

-iMurt-every delete action is prompted (=. = wouldn't it be annoying if there are too many deletions)

-Imura-Delete multiple files (when more than 3) or recursively delete (for non-empty directories) prompt once

-r and-R-- Recursively delete everything in this directory

-vMurt-displays the delete action for each file (this parameter is always recommended to know what you are doing)

Sudo,su:

This is probably a command to be used after installing the system.

Sudo is mainly used to temporarily enhance permissions, mainly for administrators (superusers) to run commands when you need to modify files / directories that are beyond the reach of the currently logged in user.

You need to use sudo, or su-c, but of course sudo and su are more than that.

You can use visudo to edit the / etc/sudoers file to modify more detailed actions of sudo (such as the timestamp length of remembering passwords), please modify it carefully!

Sh:

Interpretation and execution at the terminal

Similar to the form of'. /', but PT gives a difference:'. /'is only valid for programs that have execution permissions in the current directory, while sh' doesn't care about it.

If you think about it,'. / 'just gives the path of a file (in the current directory), but it's hard to say whether the file can be executed or not.

So it's always right to use sh.

Shutdown:

Shut down the system. If you stay in TTY, please use halt, poweroff and other commands instead.

Common parameters:

+ mmurf-specify the minutes of shutdown delay

-Cmure-cancel a request waiting for shutdown (you can also turn off the terminal running this command:)

Now-- shuts down immediately

Hh:mm-specify the time manually (in 24 hours)

Tar:

Pack / unpack

Say no more about this tar.. There's tar.gz,tar.bz2 stuff everywhere.

Like the ps command, tar generally does not use a single parameter, but a combination of multiple parameters. Remember that parameter x is extract and c is creat.

Most commonly used parameters:

-xvf-- lists the steps for unpacking in detail

-cvf-- lists the steps of packaging in detail

-Jmure-used to indicate that this is a tar.bz2 package, such as tar-xjvf myfile.tar.bz2

-tmure-list the files in the package

-- parameters that are often appended in packaging:

-rmure-append to the compressed package

-uMQ-only append files that are newer than those in the package

-hmurf-do not add a symbolic link to the package, but add the file that this symbolic link points to

Additional note: tar is a too powerful thing, the common operation is packaging and unpacking, the advanced function is still refer to man

At this point, the study on "the use of common Ubuntu commands" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report