Basic operation tutorial of files and permissions in centos

Basic operation tutorial of files and permissions in centos

Preface

Before we begin, we should briefly understand the file attributes and how to change file attributes:

From the above picture we can see some basic properties of the file, including permissions, number of links, owner and group, file size, modification time, file name, etc.

Change directory

cd: Change directory.

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

The cd command has the following main usage modes:

cd [~]: Enter the home directory of the current user. For example, if I log in as user fuwh, I will enter the /home/fuwh directory.

cd directory name: enter the specified directory

cd .: represents the current directory

cd ..: represents entering the upper directory. For example, if I am in /home/fuwh now, using this command will enter the /home directory.

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

View the file list

Directory processing command: ls

Command name:

ls

Command English original meaning:

list

Command path:

/bin/ls

Execute permissions:

All users

Functional description:

Display directory files

grammar:

ls option [-ald] [file or directory]

-a Display all files, including hidden files

-l detailed information display

-d View directory properties


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

ls -lhd /etc is to view the size of the etc directory instead of viewing all the contents under the ect directory.

#ls -i View the id number of each file

Permission Flags

r means the file can be read
w means the file can be written (write)
x means 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 first one - represents the type. The first one rw - represents the owner (user).
The second rw- stands for group
The third r stands for other people.

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

The current user itself: readable and writable, no executable permission

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

Other users: Readable but not writable, no executable permission

rwx can also be replaced by numbers

r------------4
w ------------2
x ------------1
-------------0

Permissions correspond to numbers, octal

-rw------- (600) 0420000000 Only the owner has read and write permissions
-rw-r--r-- (644) 0420400400 Only the owner has read and write permissions, the group and others only have read permissions
-rwx------ (700) 0421000000 Only the owner has read, write, and execute permissions
-rwxr-xr-x (755) 0421401401 Only the owner has read, write, and execute permissions, while the group and others have only read and execute permissions
-rwx--x--x (711) 0421001001 Only the owner has read, write, and execute permissions, while the group and others have only execute permissions
-rw-rw-rw- (666) 0420420420 Everyone has read and write permissions
-rwxrwxrwx (777) 0421421421 Everyone has read, write, and execute permissions

Modify file permissions

chmod 777 file|dir (-R recurse into subfolders)

[root@iZwz9id7ajv83jhb9gicj0Z spiders]# chmod 777 test_data/ -R
[root@iZwz9id7ajv83jhb9gicj0Z spiders]# ls
batj_kb.py batj_yb.py __init__.py items.py sztj_tjkb.py sztj_tjyb.py test_data
batj_kb.pyc batj_yb.pyc __init__.pyc items.pyc sztj_tjkb.pyc sztj_tjyb.pyc
[root@iZwz9id7ajv83jhb9gicj0Z spiders]# ls -l
total 60
-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.pyc
drwxrwxrwx 3 spiderftp ftp 4096 Sep 20 11:58 test_data
[root@iZwz9id7ajv83jhb9gicj0Z spiders]# cd test_data/ 
[root@iZwz9id7ajv83jhb9gicj0Z test_data]# ls -l
total 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 161 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.pyc
drwxrwxrwx 2 root root 4096 Sep 20 11:58 test

Modify the user to whom the file belongs

chown user file|dir (-R recurse into subfolders)

[root@iZwz9id7ajv83jhb9gicj0Z spiders]# ls -l
total 60
-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.pyc
drwxrwxrwx 3 spiderftp ftp 4096 Sep 20 11:58 test_data
[root@iZwz9id7ajv83jhb9gicj0Z spiders]# chown root test_data/ -R
[root@iZwz9id7ajv83jhb9gicj0Z spiders]# ls -l
total 60
-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.pyc
drwxrwxrwx 3 root ftp 4096 Sep 20 11:58 test_data

Modify the group to which a file belongs

chgrp group file|dir (-R recurse into subfiles)

[root@iZwz9id7ajv83jhb9gicj0Z spiders]# ls -l
total 60
-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.pyc
drwxrwxrwx 3 root ftp 4096 Sep 20 11:58 test_data
[root@iZwz9id7ajv83jhb9gicj0Z spiders]# chgrp root test_data/
[root@iZwz9id7ajv83jhb9gicj0Z spiders]# ls -l
total 60
-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.pyc
drwxrwxrwx 3 root root 4096 Sep 20 11:58 test_data

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • How to recover MariaDB database root user permissions in centos
  • Centos rsync file synchronization configuration steps sharing
  • How to set up folder sharing in CentOS 7 in VMware
  • VMware12 and CentOS7 shared folder problem analysis
  • Chinese file names display garbled characters in CentOS
  • CentOS system modifies the display color of the created folder directory
  • Steps to build FTP file service in CentOS
  • How to set up NFS file sharing in CentOS 6.8

<<:  MySQL replication table details and example code

>>:  How to add interface listening mask in Vue project

Recommend

DockerToolBox file mounting implementation code

When using docker, you may find that the file can...

Solution to nginx hiding version number and WEB server information

Nginx can not only hide version information, but ...

Summary of the benefits of deploying MySQL delayed slaves

Preface The master-slave replication relationship...

Implementation code of front-end HTML skin changing function

50 lines of code to change 5 skin colors, includi...

Three Ways to Find the Longest Word in a String in JavaScript (Recommended)

This article is based on the Free Code Camp Basic...

CSS example code to hide the scroll bar and scroll the content

Preface When the HTML structure of a page contain...

WeChat applet learning notes: page configuration and routing

I have been studying and reviewing the developmen...

WeChat applet date and time component (year, month, day, hour, and minute)

This article example shares the specific code of ...

Echarts implements switching different X-axes in one graph (example code)

Rendering If you want to achieve the effect shown...

How to install pyenv under Linux

Prerequisites Need to install git Installation St...

JavaScript to achieve a simple page countdown

This article example shares the specific code of ...

How to configure mysql on ubuntu server and implement remote connection

Server: Ubuntu Server 16.04 LSS Client: Ubuntu 16...

How to use vue-bootstrap-datetimepicker date plugin in vue-cli 3

Demand Background Recently, I plan to use Vue and...

Detailed tutorial on deploying Apollo custom environment with docker-compose

Table of contents What is the Apollo Configuratio...

How to use CURRENT_TIMESTAMP in MySQL

Table of contents Use of CURRENT_TIMESTAMP timest...