


The principle and usage of ll command to view directory information list in Linux
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:
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:
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
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
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
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,
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.
-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:
Earlier we used numbers to change permissions. Let’s use letters to change permissions.
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.
-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
4. linuxc disk management
The file /etc/fstab records the hard disk partition situation in Ubuntu in detail,
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 inrepresents 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.
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
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











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.

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.

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.

The main differences between Linux and Windows in virtualization support are: 1) Linux provides KVM and Xen, with outstanding performance and flexibility, suitable for high customization environments; 2) Windows supports virtualization through Hyper-V, with a friendly interface, and is closely integrated with the Microsoft ecosystem, suitable for enterprises that rely on Microsoft software.

Learning Linux is not difficult. 1.Linux is an open source operating system based on Unix and is widely used in servers, embedded systems and personal computers. 2. Understanding file system and permission management is the key. The file system is hierarchical, and permissions include reading, writing and execution. 3. Package management systems such as apt and dnf make software management convenient. 4. Process management is implemented through ps and top commands. 5. Start learning from basic commands such as mkdir, cd, touch and nano, and then try advanced usage such as shell scripts and text processing. 6. Common errors such as permission problems can be solved through sudo and chmod. 7. Performance optimization suggestions include using htop to monitor resources, cleaning unnecessary files, and using sy

For years, Linux software distribution relied on native formats like DEB and RPM, deeply ingrained in each distribution's ecosystem. However, Flatpak and Snap have emerged, promising a universal approach to application packaging. This article exami

This guide explores various methods for comparing text files in Linux, a crucial task for system administrators and developers. We'll cover command-line tools and visual diff tools, highlighting their strengths and appropriate use cases. Let's assum

The main difference between Linux and Windows in user account management is the permission model and management tools. Linux uses Unix-based permissions models and command-line tools (such as useradd, usermod, userdel), while Windows uses its own security model and graphical user interface (GUI) management tools.
