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 operating bases of Linux's CLI command line interface system?

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "what are the operating bases of Linux's CLI command line interface system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the operating bases of Linux's CLI command line interface system?"

Common shortcut keys:

Ctrl+d keyboard input ends or exits the terminal

Ctrl+s tentatively determines the current program. Press any key to resume operation after pausing.

Ctrl+z will run the current program in the background and restore it to the foreground as the command fg

Ctrl+a moves the cursor to the input header, which is equivalent to the Home key

Ctrl+e moves the cursor to the end of the input line, equivalent to the end key

Ctrl+k delete from cursor position to the end of the line

Alt+Backspace deletes a word forward

Shift+PgUp scrolls up the terminal display

Shift+PgDn scrolls down the terminal display

Wildcard character

The wildcard entered in the terminal is handled by shell, not by the command statement involved, it only appears in the "parameter value" of the command. When shell encounters a wildcard in the "parameter value", shell will use it as a path or file name to search the disk for a possible match: if a match exists, it will be replaced (path extension); otherwise, the wildcard will be passed to the command as a normal character, and then processed by the command. In short, wildcards are actually a kind of path extension implemented by shell. After the wildcard is processed, shell first completes the reorganization of the command, and then continues to process the reorganized command until the command is executed.

For example:

The code is as follows:

Touch love_ {1..10} _ linux.txt

You can create 10 files from love_1_linux.txt to love_10_linux.txt.

* match 0 or more characters

? Match any character

[list] matches any single character in list

[! list] matches characters other than any single character in list

[c1-c2] matches any single character in c1-c2, such as: [0-9] [amurz]

{string1,string2,... } match one string of sring1 or string2 (or more)

{c2..c2} matches all characters in c1-c2, such as {1... 10}.

Get help on the command line

The code is as follows:

$man

You can get a description and a detailed description of how to use a command. The man command is an abbreviation for Manual page. Use this command to display the manual will enter a VIM-like editing interface, you can use VIM shortcuts to navigate, such as /, after you can use the n key to switch to the next keyword, shift+n is the previous keyword. Use Space to turn the page, Enter to scroll down one line, or j or k (the move key of the vim editor) to scroll forward and backward one line. Press the h key to display the usage help (because man uses less as a reader, which is actually the help of the less tool), press Q to exit.

The man manual contains a lot of content, and it is dealt with by volume (section) in order to make it easy to find. In Research Unix, BSD, OS X and Linux, the manual is usually divided into eight sections, arranged as follows:

General command

1. System call

two。 Library functions, covering the C standard function library

3. Special files (usually devices in / dev) and drivers

4. File formats and conventions

5. Games and screensavers

6. Miscellaneous

7. System management commands and daemons

To view the contents of the corresponding section, add the number of the corresponding section after the man, such as:

The code is as follows:

$man 3 printf

All man pages follow a common layout that is optimized for simple ASCII text presentation, in which case there may be no highlighting or font control of any kind. It generally includes the following parts:

NAME (name): the name of the command or function, followed by a brief introduction on one line.

SYNOPSIS (summary): for a command, formally describe how it works and what command-line arguments are required. For a function, describe the parameters required for the function and which header file contains the definition of the function.

DESCRIPTION: a textual description of the function of a command or function.

EXAMPLES (example): some commonly used examples.

SEE ALSO (see): a list of related commands or functions.

For more detailed help, you can also use the info command, but man is usually sufficient. If you know what a command does and just want to quickly see what some of its specific parameters do, you can use the-help parameter, which most commands have.

Linux user Management

Linux is an operating system that can realize multi-user login. This paper records the user management of Linux, including viewing and creating users and user groups, as well as the permission mechanism of files.

Linux is an operating system that enables multi-user login. For example, both Li Lei and Han Meimei can log on to the same host at the same time. They share some host resources, but they also have their own user space to store their own files. In fact, their files are all on the same physical disk or even in the same logical partition or directory, but they cannot see or manipulate each other's files, which is the mechanism of Linux user management and permissions.

View users

Use the whoami command directly to view the user name of the currently logged-in user, and there is also a who command to view more detailed information.

Create a user

Root permission is a kind of system permission. Root is a super administrator user account in Linux and unix systems, which has the supreme power of the whole system, and he can operate all objects, so many hackers have to upgrade their privileges to root privileges when they invade the system. The root account is the equivalent of Linux's "God".

Generally, when logging in to the system, you log in as an ordinary account (that is, "mortal"). If you want to add a user (God created man), you need to "borrow" the power of God, even with the sudo command. There are two major prerequisites for using this command, one is that you need to know the password of the currently logged in user, and the other is that the current user must be in the sudo user group.

Sudo adduser: create a new user (a user group with the same name will be automatically created by default), and a corresponding folder will be created under the / home directory

Su-l: switch login users

Exit (or CTRL+D): logs out of the currently logged in user

User group

In linux, each user has an attribution (user group). A user group is simply a collection of users who share some resources and permissions while owning private resources. A user can belong to multiple user groups.

Groups: see which user group user belongs to. The output colon indicates the user before and then the user group to which the user belongs.

Cat / etc/group | sort: the output is as follows. The content of the / etc/group file includes the user group (Group), the user group password, the GID and the users (User) contained in the user group, with one record for each user group. The format is group_name:password:GID:user_list, where the password field indicates that the password is invisible.

Daemon::1:root

Kmem::2:root

Sys::3:root...

Usermod-G: add a user group for the user (root permission is required). You can use this command to add a user to the sudo group so that the user can borrow root permissions.

Deluser-- remove-home: delete the user (root permission is required). -- the remove-home parameter indicates that the folder under the home directory is deleted.

Linux file permissions

The ls command lists the files in the current folder with the following parameters:

-l: list the files in a more detailed format (as shown below)

-A: show except. (current directory), All files that contain hidden files outside the previous directory (under Linux. The beginning file is a hidden file)

-dl: view the complete properties of a directory instead of displaying the file properties in the directory

-sSh: small s to show file size, big S to sort by file size, h to show all file sizes, and to present them in a way that ordinary human beings can understand

The code is as follows:

Drwxr-xr-x@ 11 root wheel 374 1 25 22:23 usr

From left to right are: file type and permissions, number of links, owner, user group, file size, last modification time, file name.

1. File type and permissions (drwxr-xr-x@)

The first bit d indicates the file type. The other file types are:

D: directory

L: soft link

B: block equipment

C: character device

S:Socket

P: pipe

-: ordinary files

The last 9 bits are divided into 3 groups, namely, owner permissions, user group permissions, and other user rights. The meaning of the characters is:

R: allow read permissions, for example, you can use commands such as cat to read the contents of a file

W: write permission is allowed, indicating that you can edit and modify a file

X: permission to execute, usually a binary or script file that can be run. File types are not distinguished by file suffixes on Linux. Note: a directory can only be opened with both read and execute permissions, and a directory must have write permission to create other files in it. This is because the directory file actually holds information such as a list of files in the directory.

2. Number of links

The number of file names linked to the inode node where the file is located (for knowledge of the concepts related to the linux file system, refer to yourself)

3. File size

If the file size is expressed in terms of inode node size, you can add the-h parameter to ls to view the file size more intuitively.

Use the chown command to modify file file permissions (root permissions are required). The parameter param can be in binary form or in the form of addition and subtraction assignment.

In the binary form, such as chown 755 some_file, the three numbers in the parameters represent the rights of the owner, the user group, and other users. The calculation of permission values is determined by r, w, x, with permissions of 1 and no permissions of 0, which are weighted by binary. For example, 7 represents rwx,5 and represents RMX.

The operation forms of addition and subtraction assignment, such as chmod go-rw some_file,'g''o' and 'group,others,user,'+','-', respectively, means to increase and remove the corresponding permissions, respectively.

At this point, I believe you have a deeper understanding of "what is the operating basis of Linux's CLI command line interface system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

*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