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 is the basic operation of files and permissions in centos

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the centos files and permissions of the basic operation of what is the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe that you will have a harvest after reading this centos file and permissions of the basic operation of the article, let's take a look at it.

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 RW Muhami 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 's article on "what is the basic operation of files and permissions in centos" ends here Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "what is the basic operation of files and permissions in centos". If you want to learn more knowledge, you are welcome to follow the industry information channel.

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

Development

Wechat

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

12
Report