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

Basic operating tutorial on Files and permissions in centos

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Preface

Before we begin, we should simply understand the properties of the file and how to change the file properties:

From the pictures above, we can see some basic attributes of the file, such as permissions, number of links, owner and group, file size, modification time, file name, etc.

Switch directories

Cd: switch directories.

When we need to go to another directory, we need to use the command cd. '

The command cd can be used in the following ways

Cd [~]: enter the current user's home directory. For example, if I log in as a fuwh user, go to the / home/fuwh directory.

Cd directory name: go to the specified directory

Cd.: represents the current directory

Cd.: means to enter the directory above. For example, when I am under / home/fuwh, using this command, I will go to the / home directory.

Cd -: represents the previous working directory, for example, we often need to switch between the two directories, we can use this shortcut.

View a list of files

Directory processing command: ls

Command name:

Ls

The original intention of the order is:

List

Path where the command is located:

/ bin/ls

Execute permission:

All users

Function description:

Show catalog files

Syntax:

Ls option [- ald] [file or directory]

-a show all files, including hidden files

-l details display

-d View directory properties

Ls-lh converts the byte display of file size into the familiar Windows.

Ls-lhd / etc is to look at the size of the etc directory rather than everything under the ect directory.

# ls-I check the id number of each file

Permission flag

R indicates that the file can be read (read)

W indicates that the file can be written (write)

X indicates that the file can be executed (if it is a program)

-indicates that the corresponding permission has not been granted

Permission grouping

Example-rw-r--r-- 1 root root 48 Jan 8 20:14 token.txt

The first 10 digits-rw-rw-r--

The one at the front-represents the type

The first rw- represents owner (user)

The second rw- represents the group.

The third rmuri-represents other people (other)

From the above explanation, we can see that the permissions of the token.txt file are:

Current user himself: readable and writable, no executable permission

Current user group: readable, not writable, no executable permission

Other users: readable, not writable, no executable permission

Rwx can also be replaced by numbers

R-4

W-2

X-1

-- 0

The corresponding number of permissions, octal

-rw- 0420000000 only the owner has read and write permission

-rw-r--r-- 0420400400 only the owner has read and write access, and groups and others only have read permission

-rwx- (700) 0421000000 only the owner has permission to read, write and execute

-rwxr-xr-x 0421401401 only owners have read, write, and execute permissions, groups and others only have read and execute permissions

-rwx--x--x 0421001001 only the owner has the permission to read, write, and execute, and groups and others only have the permission to execute

-rw-rw-rw- 0420420420 everyone has read and write access

-rwxrwxrwx 0421421421 everyone has access to read, write and execute

Modify file permissions

Chmod 777 file | dir (- R recursion to child files)

[root@iZwz9id7ajv83jhb9gicj0Z spiders] # chmod 777 test_data/-R [root@iZwz9id7ajv83jhb9gicj0Z spiders] # lsbatj_kb.py batj_yb.py _ _ init__.py items.py sztj_tjkb.py sztj_tjyb.py test_databatj_kb.pyc batj_yb.pyc _ _ init__.pyc items.pyc sztj_tjkb.pyc sztj_ tjyb.pyc [root @ iZwz9id7ajv83jhb9gicj0Z spiders] # ls-ltotal 60 RWMui RWMui-1 spiderftp ftp 2484 Sep 19 17:07 batj_kb.py- Rw-r--r-- 1 spiderftp ftp 2806 Sep 19 17:07 batj_kb.pyc-rw-r--r-- 1 spiderftp ftp 4751 Sep 19 17:07 batj_yb.py-rw-r--r-- 1 spiderftp ftp 4801 Sep 19 17:07 batj_yb.pyc-rw-r--r-- 1 spiderftp ftp 161 Sep 19 17:07 _ _ init__.py-rw-r--r-- 1 spiderftp ftp 132 Sep 19 17:07 _ _ init__.pyc-rw -items.py-rw-r--r-- 1 spiderftp ftp Sep 19 17:07 items.py-rw-r--r-- 1 spiderftp ftp 606 Sep 19 17:07 items.pyc-rw-r--r-- 1 spiderftp ftp 3900 Sep 19 17:07 sztj_tjkb.py-rw-r--r-- 1 spiderftp ftp 3542 Sep 19 17:07 sztj_tjkb.pyc-rw-r--r-- 1 spiderftp ftp 1522 Sep 19 17:07 sztj_tjyb.py-rw-r--r-- 1 spiderftp Ftp 2046 Sep 19 17:07 sztj_tjyb.pycdrwxrwxrwx 3 spiderftp ftp 4096 Sep 20 11:58 test_ data [root @ iZwz9id7ajv83jhb9gicj0Z spiders] # cd test_data/ [root@iZwz9id7ajv83jhb9gicj0Z test_data] # ls-ltotal 60-rwxrwxrwx 1 spiderftp ftp 2484 Sep 19 17:07 batj_kb.py-rwxrwxrwx 1 spiderftp ftp 2806 Sep 19 17:07 batj_kb.pyc-rwxrwxrwx 1 spiderftp ftp 4751 Sep 19 17:07 batj_yb.py-rwxrwxrwx 1 spiderftp ftp 4801 Sep 19 17:07 batj_yb.pyc-rwxrwxrwx 1 spiderftp ftp Sep 19 17:07 _ _ init__.py-rwxrwxrwx 1 spiderftp ftp 132 Sep 19 17:07 _ _ init__.pyc-rwxrwxrwx 1 spiderftp ftp 512 Sep 19 17:07 items.py-rwxrwxrwx 1 spiderftp ftp 606 Sep 19 17:07 items.pyc-rwxrwxrwx 1 spiderftp ftp 3900 Sep 19 17:07 sztj_tjkb.py-rwxrwxrwx 1 spiderftp ftp 3542 Sep 19 17:07 sztj_tjkb.pyc-rwxrwxrwx 1 spiderftp ftp 1522 Sep 19 17:07 sztj_tjyb.py-rwxrwxrwx 1 spiderftp ftp 2046 Sep 19 17:07 sztj_tjyb.pycdrwxrwxrwx 2 root root 4096 Sep 20 11:58 test

Modify the user to which the file belongs

Chown user file | dir (- R recursion to child files)

[root@iZwz9id7ajv83jhb9gicj0Z spiders] # ls-ltotal 60 RW Sep RW batj_yb.py-rw-r--r---1 spiderftp ftp 2484 Sep 19 17:07 batj_kb.py-rw-r--r-- 1 spiderftp ftp 2806 Sep 19 17:07 batj_kb.pyc-rw-r--r-- 1 spiderftp ftp 4751 Sep 19 17:07 batj_yb.py-rw-r--r-- 1 spiderftp ftp 4801 Sep 19 17:07 batj_yb.pyc-rw-r--r-- 1 spiderftp ftp 161 Sep 19 17: 07 _ _ init__.py-rw-r--r-- 1 spiderftp ftp 132 Sep 19 17:07 _ _ init__.pyc-rw-r--r-- 1 spiderftp ftp 512 Sep 19 17:07 items.py-rw-r--r-- 1 spiderftp ftp 606 Sep 19 17:07 items.pyc-rw-r--r-- 1 spiderftp ftp 3900 Sep 19 17:07 sztj_tjkb.py-rw-r--r-- 1 spiderftp ftp 3542 Sep 19 17:07 sztj_tjkb. Pyc-rw-r--r-- 1 spiderftp ftp 1522 Sep 19 17:07 sztj_tjyb.py-rw-r--r-- 1 spiderftp ftp 2046 Sep 19 17:07 sztj_tjyb.pycdrwxrwxrwx 3 spiderftp ftp 4096 Sep 20 11:58 test_ data [root @ iZwz9id7ajv83jhb9gicj0Z spiders] # chown root test_data/-R [root@iZwz9id7ajv83jhb9gicj0Z spiders] # ls-ltotal 60 Mustang RWKui Ruki-1 spiderftp ftp 2484 Sep 19 17:07 batj_kb.py-rw-r--r-- 1 spiderftp Ftp 2806 Sep 19 17:07 batj_kb.pyc-rw-r--r-- 1 spiderftp ftp 4751 Sep 19 17:07 batj_yb.py-rw-r--r-- 1 spiderftp ftp 4801 Sep 19 17:07 batj_yb.pyc-rw-r--r-- 1 spiderftp ftp 161 Sep 19 17:07 _ _ init__.py-rw-r--r-- 1 spiderftp ftp 132 Sep 19 17:07 _ _ init__.pyc-rw-r--r-- 1 spiderftp ftp 512 Sep 19 17:07 items.py-rw-r--r-- 1 spiderftp ftp 606 Sep 19 17:07 items.pyc-rw-r--r-- 1 spiderftp ftp 3900 Sep 19 17:07 sztj_tjkb.py-rw-r--r-- 1 spiderftp ftp 3542 Sep 19 17:07 sztj_tjkb.pyc-rw-r--r-- 1 spiderftp ftp 1522 Sep 19 17:07 sztj_tjyb.py-rw-r--r-- 1 spiderftp ftp 2046 Sep 19 17:07 sztj_tjyb .pycdrwxrwxrwx 3 root ftp 4096 Sep 20 11:58 test_data

Modify the group to which the file belongs

Chgrp group file | dir (- R recursion to child files)

[root@iZwz9id7ajv83jhb9gicj0Z spiders] # ls-ltotal 60 RW Sep RW batj_yb.py-rw-r--r---1 spiderftp ftp 2484 Sep 19 17:07 batj_kb.py-rw-r--r-- 1 spiderftp ftp 2806 Sep 19 17:07 batj_kb.pyc-rw-r--r-- 1 spiderftp ftp 4751 Sep 19 17:07 batj_yb.py-rw-r--r-- 1 spiderftp ftp 4801 Sep 19 17:07 batj_yb.pyc-rw-r--r-- 1 spiderftp ftp 161 Sep 19 17: 07 _ _ init__.py-rw-r--r-- 1 spiderftp ftp 132 Sep 19 17:07 _ _ init__.pyc-rw-r--r-- 1 spiderftp ftp 512 Sep 19 17:07 items.py-rw-r--r-- 1 spiderftp ftp 606 Sep 19 17:07 items.pyc-rw-r--r-- 1 spiderftp ftp 3900 Sep 19 17:07 sztj_tjkb.py-rw-r--r-- 1 spiderftp ftp 3542 Sep 19 17:07 sztj_tjkb. Pyc-rw-r--r-- 1 spiderftp ftp 1522 Sep 19 17:07 sztj_tjyb.py-rw-r--r-- 1 spiderftp ftp 2046 Sep 19 17:07 sztj_tjyb.pycdrwxrwxrwx 3 root ftp 4096 Sep 20 11:58 test_ data [root @ iZwz9id7ajv83jhb9gicj0Z spiders] # chgrp root test_data/ [root @ iZwz9id7ajv83jhb9gicj0Z spiders] # ls-ltotal 60 RWMUR Sep-1 spiderftp ftp 2484 Sep 19 17:07 batj_kb.py-rw-r--r-- 1 spiderftp ftp 2806 Sep 19 17:07 batj_kb.pyc-rw-r--r-- 1 spiderftp ftp 4751 Sep 19 17:07 batj_yb.py-rw-r--r-- 1 spiderftp ftp 4801 Sep 19 17:07 batj_yb.pyc-rw-r--r-- 1 spiderftp ftp 161 Sep 19 17:07 _ _ init__.py-rw-r--r-- 1 spiderftp ftp 132 Sep 19 17:07 _ _ init__.pyc-rw-r--r-- 1 spiderftp ftp 512 Sep 19 17:07 items.py-rw-r--r-- 1 spiderftp ftp 606 Sep 19 17:07 items.pyc-rw-r--r-- 1 spiderftp ftp 3900 Sep 19 17:07 sztj_tjkb.py-rw-r--r-- 1 spiderftp ftp 3542 Sep 19 17:07 sztj_tjkb.pyc-rw-r--r-- 1 spiderftp ftp 1522 Sep 19 17:07 sztj_tjyb.py-rw-r--r-- 1 spiderftp ftp 2046 Sep 19 17:07 sztj_tjyb.pycdrwxrwxrwx 3 root root 4096 Sep 20 11:58 test_data

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

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

Servers

Wechat

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

12
Report