LINUX instantly uses basic commands --chmod and chown album

zhaozj2021-02-16  78

Linux

Next to use basic commands

Command name

basic skills

Use examples and description

CD

Change the work path

CD - (Return to the last time you stay)

AddUser

Used by root or other administrators to create new users

AddUser Student (Add User Student)

Passwd

Set user password

Passwd student (setting password for Student users)

&

Use behind other commands, it is used to notify the computer to run a certain order in the background

Netscape & (Background Launch Browser Netscape)

PS

Display the number of processes and processes running in the current system (PID)

PS AX (Display all processes of the current system and their PID)

Mount

Used to connect file systems (such as connecting optical drives, FAT partitions, etc.)

Mount / DEV / CDROM / MNT / CDROM (connecting the disc content to / cdrom)

Umount

Remove file system

Unmount / MNT / CDROM

More and Less

Browse the contents of the file, press the Q key to end

Less TXT1 (display TXT1 content)

Chown and Chgrp

Set file or directory owner

Chown User1 File (assign file to user1)

CHGRP GRP1 File (assigning the file to the GRP1 user group)

Chmod

Change file properties, attribute rules are owners identical group other users

CHMOD U X G W O R File (to the owner can be executed, the same group can be written, others can read)

GREP

Find strings in byte stream

PS AX | GREP Sendmail (Query the PID of the Sendmail program in PS AX)

Find

Used to find a file

Find / Home -Name * .cgi (Find a file with .cgi for .cgi under / home)

Kill

Used to kill a process

Usage: Kill 361 (killing process number 361)

Rpm

Manage RPM Packages

rpm -i

(Install RPM package)

Locate

Find files

Locate AddUser (listing paths with AddUser)

WHEREIS

See which directory exactly in the file

Whereis startX (getting a path to the startX command))

CHMOD and Chown album

Directive Name: Chmod

Use permission: All users

How to use: chmod [-cfvr] [--help] [--version] mode file ...

Description: Linux / UNIX file access rights are divided into three levels: file owners, groups, others. Using CHMOD how to control the file is accessed by others.

Mode: Permissions Set strings, formats are as follows: [ugoa ...] [ =] [rwxx] ...] [, ...], where

u Indicates the owner of the file.

g indicates that the owner of the file belongs to the same group (Group).

o indicates someone else.

a means that these are all.

Represents increased permissions, indicates cancellation, = indicates unique setting permissions.

R indicates that readable, W represents written, x represents executable, X represents only when the file is a subdirectory or the file has been set to be executed.

-c: If this file authority does have changed, it will display its change action.

-f: If this file is not changed, do not display an error message.

-v: Details show permission change - R: All files in the current directory are changed with the subdirectory (ie, changed one by one by hand)

--help: Display auxiliary instructions

--Version: Display version

Example:

1. Set the file file1.txt to everyone can read:

CHMOD UGO R File1.txt

2. Set the file file1.txt to everyone can read:

CHMOD A R File1.txt

3. Set the file file1.txt and file2.txt to this file owner, and it can be written with its own same group, but others cannot be written:

CHMOD UG W, O-W File1.txt File2.txt

4, set the ex1.py to only the file owner can perform:

CHMOD u x ex1.py

5. Set all the files and subdirectories in the current directory to anyone can read:

CHMOD -R A R *

6. In addition, CHMOD can also use numbers to indicate rights such as Chmod 777 file.

Grammatical: chmod abc file

Where A, B, C are each number, which represents USER, Group, and Other permissions.

R = 4, w = 2, x = 1

To RWX attribute 4 2 1 = 7;

To RW-attribute 4 2 = 6;

To R-X attribute 4 1 = 5.

Chmod a = rwx file is the same as the Chmod 777 File effect.

Chmod ug = rwx, o = x file and chmod 771 FILE effects are the same.

If you use CHMOD 4755 FileName, this program has root permissions

Directive Name: Chown

Use permission: root

How to use: chown [-cfhvr] [--help] [--version] user [: group] file ...

Description: Linux / UNIX is multi-person multi-work industry, all of which have owners. Use Chown to change the owners of the file. In general, this instruction only is used by the system administrator (root), and the general user has no permissions to change someone else's file owner, and there is no permission to change the owner of its own files to others. Only the system administrator (root) has such permissions. User: New Archive owner's user IDGroup: New Archive owner's User Group (Group) -c: If the file owner does have changed, the change action is displayed - F: If the owner cannot Do not display the error message - H: only for links (LINK), not the LINK, true pointing file -V: Display owner change - R: All files and subdirectories in current directory Perform the same owner change (ie, changed one by one by way) - Help: Display Auxiliary Description --Version: Display version

Example:

1. Set the owner of the file file1.txt to the User Group User Jessie:

Chown Jessie: Users file1.txt

2. Use the owners of all files in the current directory with the owner of the subdirectory to the user list: Lamport:

CHMOD -R LAMPORT: USERS *

转载请注明原文地址:https://www.9cbs.com/read-13909.html

New Post(0)