Home System Tutorial LINUX The principle and usage of ll command to view directory information list in Linux

The principle and usage of ll command to view directory information list in Linux

Jun 12, 2024 am 10:27 AM

Linux 中 ll 命令查看目录信息列表的原理与使用方法

Study and summarize the document yourself. It’s a bit messy, don’t blame me

1. What does the total dose in Linux mean?

In Linux, we often use the ll command (ls-l) to view the directory information list, see the picture on the right:

查看用户的命令Linux_linux的chmod命令_打开终端的命令Linux

In the picture above, what does "Total 92" refer to? The "total" here, which can also be called "total dosage" or "total", refers to the number of blocks used in the directory. How is this number of blocks estimated? See picture on the right:

打开终端的命令Linux_查看用户的命令Linux_linux的chmod命令

The value on the right side of the above figure is the sum of the number of blocks (number of blocks) occupied by directories and files, 4x8+40+12+8=92, which is equal to "total 92", among which, the "ll-s" command also It can be written as "ls-ls" or "ls-l--size", and use "ls--help" to view the ls command parameter information, see the picture on the right (partial screenshot):

Note that "-s" here is capitalized, and the size of each file is listed in blocks.

To sum up, the "total" value in the ll or ls-l query results refers to the total number of blocks occupied by all files and subdirectories in the directory.

2. Linux return to root directory command

1. cd.. means to go to the upper directory;

2. cd-, means to return to the previous directory, similar to windows return;

3. cd/ means returning to the root directory.

4. cdlinux chmod command, return to normal user

查看用户的命令Linux_打开终端的命令Linux_linux的chmod命令

1. The command to switch users is: su+username

2. Switch from ordinary user to root user: sudosu

3. Return to the original user: exit command or logout, or ctrl+d

4. If you want to switch to the working environment of a new user: su-username such as su-root

5.# represents ordinary users, $ represents super users. That is root user

3. Linux file permissions

There are three types of file permissions: read (r), write (w) and execute (x). In addition to being represented by r, w and x, we can also use two's complement numbers to represent the three permissions. It is represented by a 3-digit two's complement number. A permission corresponds to a two's complement bit. If the bit is 1, it means that you have this permission. If the bit is 0, it means you do not have this permission, as shown in Table

打开终端的命令Linux_linux的chmod命令_查看用户的命令Linux

If you have done microcontroller development, you will also find that the three permissions r, w and x are the same as the register bits on the microcontroller

By different combinations, you can get different two's complement numbers and eight's complement numbers. 3-digit permissions can create 8 different permission combinations, as shown in the table

linux的chmod命令_打开终端的命令Linux_查看用户的命令Linux

The eight's complement number corresponding to the permission is the multiplication of the bits corresponding to each permission. For example, the permission rwx is 4+2+1=7. The permissions of the following file test.c are "rw-rw-r--", so its ten's complement representation is: 664.

In addition, we also started to use a, u, g and o to indicate the ownership of files, and =, + and - to indicate changes in file permissions,

查看用户的命令Linux_打开终端的命令Linux_linux的chmod命令

linux的chmod命令_查看用户的命令Linux_打开终端的命令Linux

For the file test.c, we want to change its ownership user (zuozhongkai) to have executable permissions on it, so we can

Use: u+x. If you want to set the owned user and its user group to have executable permissions on it, you can use: gu+x.

1. Permission management commands

Use Shell to operate file permission management, mainly using the two commands "chmod" and "chown",

Permission change command chmod

The command "chmod" is used to change the permissions of files or folders. The permissions can be represented by the numbers mentioned above or they can be

is represented by letters, and the command format is as follows:

chmod[parameter][file name/directory name]

The main parameters are as follows:

-c is similar to the "-v" parameter, but only the modified part is echoed.

-f does not display error messages.

-R recursively processes all files in the specified directory and their sub-file directories together.

查看用户的命令Linux_打开终端的命令Linux_linux的chmod命令

-v displays the execution process of the instruction.

Let's first learn how to use the command "chmod" to modify the permissions of a file in commonly used Linux systems and create a

in the user root directory.

File mytest, then check its default permissions,

We created a file: mytest. The default permissions of this file are "rw-rw-r--". We changed its permissions to "rwxrw-rw". The corresponding number is 766. The operation is as follows:

查看用户的命令Linux_linux的chmod命令_打开终端的命令Linux

Earlier we used numbers to change permissions. Let’s use letters to change permissions.

打开终端的命令Linux_查看用户的命令Linux_linux的chmod命令

File owner change command chown

The chown command is used to change the owner user or user group of a file or directory. The command format is as follows:

chown[parameter][username.][filename/directory]

where [username.] indicates the user or user group to which the file or directory is to be changed. The user name and group name are

Separated by ".", either the user name or group name can be omitted. The main parameters of the command are as follows:

-c has a similar effect to -v, but only the modified part is displayed.

打开终端的命令Linux_查看用户的命令Linux_linux的chmod命令

-f does not display error messages.

-h only processes all files and subdirectories in the specified directory.

-v displays the processing process. Create a test file in the user root directory and check the user and user group to which the folder belongs

linux的chmod命令_打开终端的命令Linux_查看用户的命令Linux

4. linuxc disk management

The file /etc/fstab records the hard disk partition situation in Ubuntu in detail,

查看用户的命令Linux_linux的chmod命令_打开终端的命令Linux

There is a line "/wason/dev/sda1duringinstallation", which means that the root directory "/" is on /dev/sda1 Linux chmod command , where "/" is the mount point, " /dev/sda1" is the hard drive where we install the Ubuntu system. Because our system is installed in a virtual machine. You can view the c drive in the current system through the following command:

ls/dev/sd*The above command is to copy all the device files starting with /dev/sd,

There are four c drive device files in

, where sd indicates a SATA hard drive or other external device, and the last

The number in

represents the nth partition on the hard disk. For example, /dev/sda1 represents the first partition on drive c. sda. picture

all start with /dev/sda, indicating that there is currently only one hard drive. If you plug in a U disk, SD card, etc., /dev/sdb, /dev/sdc, etc. may appear. If your USB flash drive has two partitions, device files such as /dev/sdb1 and dev/sdb2 may also appear.

打开终端的命令Linux_查看用户的命令Linux_linux的chmod命令

c drive management command

1. Disk partition command fdisk

If you want to partition a certain c drive, you can use the command fdisk. The command format is as follows:

fdisk

[parameter]

The main parameters are as follows:

-b

Specify the size of each partition.

-l

List the partition table of the specified device.

-s

Output the specified partition size to standard output, in blocks.

-u combined with the "-l" parameter will use the number of partitions instead of the number of cylinders to represent the starting address of each partition.

For example, if I want to partition the U disk, I must not partition the Ubuntu system I installed! ! ! You can use the following command

Command: sudofdisk/dev/sdb

linux的chmod命令_打开终端的命令Linux_查看用户的命令Linux

The above is the detailed content of The principle and usage of ll command to view directory information list in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1267
29
C# Tutorial
1239
24
What is the most use of Linux? What is the most use of Linux? Apr 09, 2025 am 12:02 AM

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

How to learn Linux basics? How to learn Linux basics? Apr 10, 2025 am 09:32 AM

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

Does the internet run on Linux? Does the internet run on Linux? Apr 14, 2025 am 12:03 AM

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

What are Linux operations? What are Linux operations? Apr 13, 2025 am 12:20 AM

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

What is the salary of Linux administrator? What is the salary of Linux administrator? Apr 17, 2025 am 12:24 AM

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

What are the main tasks of a Linux system administrator? What are the main tasks of a Linux system administrator? Apr 19, 2025 am 12:23 AM

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

Boost Productivity with Custom Command Shortcuts Using Linux Aliases Boost Productivity with Custom Command Shortcuts Using Linux Aliases Apr 12, 2025 am 11:43 AM

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

See all articles