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

What are the common commands in Ubuntu?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces what Ubuntu commands are commonly used, the content is very detailed, interested friends can refer to, hope to be helpful to you.

We use Ubuntu system, mainly using commands under Ubuntu system, so it is very important to master some common commands of Ubuntu.

Yes, then we will learn these commonly used commands to lay a good foundation for later study.

1 File Information View Command ls

File operation is the most basic operation. The command under ubuntu is "ls" in the following format:

Ls [options] [path]

Ls is the same as the dir command under dos, which is used to list the files in the directory. It is the abbreviation of list, when we learn something.

If you want to know why, when you know what this thing is, your mind will think of a lot of things to learn.

It will be soon. His main parameters are:

-a displays all files and subdirectories, including "." Hidden file at the beginning

-l displays the details of the file, such as the file's shape, permissions, owner, size, etc.

-t list the files in order of creation time

-s prints out the block size of the file at the end of each file

-A lists except "." And ".." Documents other than

-R lists the files of all the subdirectories under the directory, which is equivalent to the "recursive" implementation in our programming.

-L lists the link name of the file. Link (link)

-S sorts by file size

The above are some parameters of the ls command, of course, there are many not listed, as long as we master these are enough for our usual use

These parameters can also be combined, such as "- al" to display the details of all files, including "." Hidden file at the beginning

The command for ls uses the following figure:

2 directory switching command cd

The cd command format is as follows:

Cd [dirName]

The Linux cd command is used to switch the current working directory to dirName (directory parameter). Where dirName representation can be an absolute path or a relative path

Path. If the directory name is omitted, change to the user's home directory (that is, the directory where you were just login). The format of the command is as follows:

Cd / / go to the root directory "/", and the root directory of the Linux system is "/"

Cd / usr / / enter the directory "/ usr"

Cd.. / / go to the directory one level above

Cd ~ / / switch to the current user's home directory (the login user here is topeet, the main directory / home/topeet)

For example, we need to enter the directory "/ lib" and check what files are in the changed directory. The steps are shown in the following figure:

3 Show current path command pwd

The format of the pwd command is as follows:

Pwd [OPTION]...

Parameter description:

-L / / output the connection path when connecting to the link

-P / / output physical path

For example, if we look at the current directory, ten thousand square meters, we only need to enter the command "pwd", and the result is shown in the following figure:

4 system information view command uname

The format of the uname command is as follows:

Uname [- amnrsv] [--help] [--version]

The Linux uname command is used to display system information, such as information about the computer and the operating system.

Parameter description:

-a / / display all the information

-m / / display computer type

-n / / the host name displayed on the network

-r / / displays the release number of the operating system

-s / / displays the operating system name

-v / / displays the version of the operating system

-- help / / Show help

-- version / / displays version information

The result of using this command is shown in the following figure:

6. Switch users to execute identity command sudo

Ubuntu system is an operating system that allows multiple users to use at the same time. The most privileged user is the superuser "root", who has the most

Large permissions, sometimes we need to use root permissions to perform some operations, such as when installing software. Through sudo

Command We can switch the identity to the root user with the privileges of the root user. We are required to enter a password when using the sudo command

We need to note that the terminal does not have any prompt when entering the password! The format of the sudo command is as follows:

Sudo [options] [commands]

For example, we want to create a new user "test". The command to create a new user is "adduser". Only the root user has permission to create.

To build a new user, the "topeet" user we created when installing the Ubuntu system does not have root permission, so if we create a new user,

We need to use the "sudo" command as shown in the following figure:

7 add user command adduser

We have used the change command in Chapter 2.5.6. The format of the adduser command is as follows:

Adduser [parameter] [user name]

The common parameters are as follows:

-system / / add a system user

-home DIR / / DIR represents the user's home directory

-uid ID / / ID indicates the user's uid

-ingroup GRP / / indicates the group name to which the user belongs

The "adduser" command has already been used in Chapter 2.5.6, so you can try to add a new user.

8 delete the user command deluser

The command used to delete the user is "deluser". The command format is as follows:

Deluser [parameter] [user name]

The parameters are described as follows:

-system / / can be deleted only if the user is a system user

-remove-home / / Delete the user's home directory

-remove-all-files / / Delete all files related to the user

-backup / / back up user information

"deluser" will also be executed using "sudo". Take deleting the user "test" we created earlier as an example, we enter "sudo deluser".

-remove-all-files test ". The running result is shown as follows:

9 switch user command su

Earlier, when explaining the "sudo" command, he executed a command as the root user. The disease did not change the identity of the currently logged in user.

The "su" command can directly switch from the current user to the root user, and the switch to the root user will get the highest privileges of the system, all

Commands can be run directly without adding "sudo". The format of the command for "su" is as follows:

Su [option] [user name]

The option parameters are described as follows:

-c command executes the specified command and returns to the original user identity after execution

-l change the user identity, colleagues change the working directory and system environment variables

-m change the user identity without changing the system environment variables

-h displays help information

Let's take the user switching to "root" as an example. Let's look at the use of the "su" command. We type "sudo su" and follow the prompts.

Enter the password of the current user "topeet" (note that the password entered by the terminal will not be displayed), and you will switch to the "root" user, as shown in

As shown in the following figure

We see that in the figure above, the user in front of the command prompt @ becomes root, indicating that the currently logged-in user is "root", and the most

The next $becomes #.

To switch back to the "topeet" user, we can use the command "su topeet" and the result is shown in the following figure:

About what Ubuntu commands are commonly used to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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

Internet Technology

Wechat

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

12
Report