search
HomeOperation and MaintenanceLinux Operation and MaintenanceWhat is the command to check file permissions in Linux?

Linux command ls to view file permissions. ls is the abbreviation of list. Its main function is to display the contents of the current directory, including file permissions. The basic syntax is "ls [option] directory name"; the ls command needs to be used with the "-l" option parameter to view all the directories. For the permission information of the file or folder, check the syntax "ls -l [directory name]", which can be abbreviated as "ll [directory name]".

What is the command to check file permissions in Linux?

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

Linux command to view file permissionsls.

In the directory where the file is located, use the following command to view the permission information of all files or folders in the directory.

ls -l

or enter

ll

. The two commands have the same effect, but the latter is the abbreviation of the former.

What is the command to check file permissions in Linux?

We can see the permissions of the file, -rw-rw-r--, there are 10 digits in total.

Among them: The first one - represents the type (details are shown in the map below)

  • The middle three rw- represent It is the owner (user)

  • and the three rw- represent the group (group)

  • The last three r-- represent other people

Then let me explain the next 9 digits:

  • #r Indicates that the file can be read (read)

  • w Indicates that the file can be written (write)

  • x means the file can be executed (if it is a program)

  • - means the corresponding Permission has not been granted

File and folder operation permission:

Permission Abbreviation Effect on ordinary files Effect on folders
Read r View file content List the files in the folder (ls)
Write w Modify the file Content Delete, add or rename files (folders) in folders
Execution x Files can be used as programs Execute cd to the folder

图解:

What is the command to check file permissions in Linux?What is the command to check file permissions in Linux?

需要注意的一点是,一个目录同时具有读权限和执行权限才可以打开并查看内部文件,而一个目录要有写权限才允许在其中创建其它文件,这是因为目录文件实际保存着该目录里面的文件的列表等信息。

linux ls命令介绍

ls 命令,list 的缩写,是最常见的目录操作命令,其主要功能是显示当前目录下的内容。此命令的基本格式为:

# ls [选项] 目录名称

表 1 列出了 ls 命令常用的选项以及各自的功能。

表 1 ls 命令常用选项及功能
选项 功能
-a 显示全部的文件,包括隐藏文件(开头为 . 的文件)也一起罗列出来,这是最常用的选项之一。
-A 显示全部的文件,连同隐藏文件,但不包括 . 与 .. 这两个目录。
-d 仅列出目录本身,而不是列出目录内的文件数据。
-f ls 默认会以文件名排序,使用 -f 选项会直接列出结果,而不进行排序。
-F 在文件或目录名后加上文件类型的指示符号,例如,* 代表可运行文件,/ 代表目录,= 代表 socket 文件,| 代表 FIFO 文件。
-h 以人们易读的方式显示文件或目录大小,如 1KB、234MB、2GB 等。
-i 显示 inode 节点信息。
-l 使用长格式列出文件和目录信息。
-n 以 UID 和 GID 分别代替文件用户名和群组名显示出来。
-r 将排序结果反向输出,比如,若原本文件名由小到大,反向则为由大到小。
-R 连同子目录内容一起列出来,等於将该目录下的所有文件都显示出来。
-S 以文件容量大小排序,而不是以文件名排序。
-t 以时间排序,而不是以文件名排序。
--color=never
--color=always
--color=auto
never 表示不依据文件特性给予颜色显示。
always 表示显示颜色,ls 默认采用这种方式。
auto 表示让系统自行依据配置来判断是否给予颜色。
--full-time 以完整时间模式 (包含年、月、日、时、分)输出
--time={atime,ctime} 输出 access 时间或改变权限属性时间(ctime),而不是内容变更时间。

注意,当 ls 命令不使用任何选项时,默认只会显示非隐藏文件的名称,并以文件名进行排序,同时会根据文件的具体类型给文件名配色(蓝色显示目录,白色显示一般文件)。除此之外,如果想使用 ls 命令显示更多内容,就需要使用表 1 相应的选项。

相关推荐:《Linux视频教程

The above is the detailed content of What is the command to check file permissions in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
What is Maintenance Mode in Linux? ExplainedWhat is Maintenance Mode in Linux? ExplainedApr 22, 2025 am 12:06 AM

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

Linux: A Deep Dive into Its Fundamental PartsLinux: A Deep Dive into Its Fundamental PartsApr 21, 2025 am 12:03 AM

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

Linux Architecture: Unveiling the 5 Basic ComponentsLinux Architecture: Unveiling the 5 Basic ComponentsApr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux Operations: Utilizing the Maintenance ModeLinux Operations: Utilizing the Maintenance ModeApr 19, 2025 am 12:08 AM

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

Linux: How to Enter Recovery Mode (and Maintenance)Linux: How to Enter Recovery Mode (and Maintenance)Apr 18, 2025 am 12:05 AM

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

Linux's Essential Components: Explained for BeginnersLinux's Essential Components: Explained for BeginnersApr 17, 2025 am 12:08 AM

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

Linux: A Look at Its Fundamental StructureLinux: A Look at Its Fundamental StructureApr 16, 2025 am 12:01 AM

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

Linux Operations: System Administration and MaintenanceLinux Operations: System Administration and MaintenanceApr 15, 2025 am 12:10 AM

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

See all articles

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

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Atom editor mac version download

Atom editor mac version download

The most popular open source editor