Linux Basic Command Ⅲ

Source: Internet
Author: User
Tags bz2 clear screen php language

1 Special Permissions Set_uid

[[email protected] ~]# ls-l/usr/bin/passwd when s appears on the file owner's X permission description is set_uid-rwsr-xr-x. 1 root root 27832 June 2014/usr/bin/passwdset_uid is an ordinary user who temporarily owns the identity of the owner (provided that this file is an executable binary) [[email protected] ~]# chmod u+s/u Sr/bin/ls (gives set_uid permission to LS) [[email protected] ~]# chmod u=rws/usr/bin/ls (second method of granting permissions) [[email protected] ~]# ls-l/usr/bin /ls-rwsr-xr-x. 1 root root 117656 November 6 2016/usr/bin/ls[[email protected] ~]# chmod u+x/usr/bin/ls[[email protected] ~]# ls-l/usr/bi N/ls-rwsr-xr-x. 1 root root 117656 November 6 2016/usr/bin/ls

2 Special Permissions Set_gid

This permission is valid only for the directory. After the directory is set, any user who creates the file in this directory has the same group as the group to which the directory belongs.

This is a good distinction when s is called set_gid[[email protected] ~]# chown :chy /lsm  in user group X to change the owning group under this LSM directory. [[email protected] ~]# ls -ld /lsm  View Permissions Drwxr-xr-x 2 root chy  4096 6 month    9 06:49 /lsm  no changes [[email protected] ~]#  mkdir /lsm/1   (Create a file first to facilitate later differentiation) [[email protected] ~]# ls -ld /lsm/ 1drwxr-xr-x 2  View permissions for this directory  root root 4096 6 month    9 06:50 / lsm/1[[email protected] ~]# chmod g+s /lsm/  to/lsm plus +s [[email protected]  ~]# ls -ld /lsm  found group changed drwxr-sr-x 3 root chy 4096 6 month     9 06:50 /lsm[[email protected] ~]# mkdir /lsm/234  re-create a post-discovery [[ email protected] ~]# ls -ld /lsm/234  found the difference  drwxr-sr-x 2 root  chy 4096 6 Month    9 06:51 /lsm/234 


3 Special Permissions Stick_bit

[[email protected] ~]# stick_bit = anti-delete bit [[email protected] ~]# LS-LD/TMP/DRWXRWXRWT. Root root 4096 June 9 06:33/tmp/stick_bit prevent other users from deleting files (except root)


4 Soft Connection files

> Another connection is called a symbolic connection (symbolic link), also known as a soft connection. A soft-link file has a shortcut similar to Windows. It's actually a special file. In a symbolic connection, a file is actually a text file that contains location information for another file.

[[email protected] ~]# ls-s source file Soft link file (target file) [[email protected] tmp]# ln-s/tmp/passwd Soft link Directory/root/111/passwd[[email prot Ected] ~]# ls-l/root/111 total dosage 0lrwxrwxrwx 1 root root 11 June 9 08:11 passwd,/tmp/passwd soft connection successful) relative path soft connection disadvantage: When the source file is moved to the location, the soft Connection will be invalidated

5 Hard Links

A hard connection is a connection that is made through an index node. In a Linux file system, a file saved in a disk partition, regardless of the type, assigns a number to it, called the index node number (Inode index). In Linux, multiple file names point to the same index node that exists. In general, this connection is a hard connection. The purpose of a hard connection is to allow a file to have multiple valid pathname, so that users can establish a hard connection to important files to prevent "accidental deletion" of the function. The reason for this is as above, because there is more than one connection to the index node that should be the directory. Deleting only one connection does not affect the index node itself and other connections, and the connection to the file's data block and directory will be released only if the last connection is deleted. That is, the condition that the file is actually deleted is that all the hard connection files associated with it are deleted.

[Email protected] ~]# LN 1.txt 1_head.txt

1. Only hard-linked files can not be hard-linked to the directory

2. Hard links are linked to each other for hard links, without linking the original link to the target. Hard links are the same inode

3. Hard links cannot span partitions

6 Find command synthesis

command to find a file: which

Whereis

Locate (This command is not the default)

[email protected] ~]# Yum install-y mlocate

Manually generated Commands UpdateDB

Introduction to shortcut keys

[[email protected] ~]# ctrl+l Clear Screen

[[email protected] ~]# Ctrl+d exit a terminal

[[Email protected] ~]# CTRL + C do not want to execute the command

[[email protected] ~]# ctrl+u all content before deleting the cursor

[[email protected] ~]# ctrl+e after moving the cursor to the last

[[Email protected] ~]# CTRL + A move the cursor to the beginning

Small case of Find

[[email protected] ~]# find/etc/-name "Sshd_config" find the path to a file

[[email protected] ~]# find/etc/-name "sshd*" wide-style search for a file

[[email protected] ~]# find/etc/-type d-name "sshd*" (-type D is search for a directory)

[[email protected] ~]# find/etc/-type f-name "sshd*" (-type F search for regular documents)

[[email protected] ~]# find/etc/-type L (-type l Search Connection file)

[[email protected] ~]# find/dev/-type B (-B and-C are search device files)

[[Email protected] ~]# stat 2.txt (stat view file for specific information)

File: "2.txt"

Size: 0 Block: 0 IO block: 4096 plain empty file

Device: fd00h/64768d inode:146705 hard Link: 1

Permissions: (0642/-rw-r---w) Uid: (0/root) Gid: (0/root)

Last visited: 2017-06-08 07:17:01.341855735 +0800

Last modified: 2017-06-08 07:00:10.258873841 +0800

Last modified: 2017-06-08 07:11:53.380861250 +0800

Creation Time:-

Mtime (recently changed)

Atime (recently visited)

CTime (Recent changes)

Access Time (-atime/days,-amin/minutes): The user's last access time.

Modification time (-mtime/days,-mmin/minutes): The last time the file was modified.

Change Time (-ctime/days,-cmin/minutes): File data elements (such as permissions, and so on) last modified time.

[[email protected] ~]# echo "1111" >>2.txt when a file is appended, CTime and mtime time will change)

[Email protected] ~]# stat 2.txt

File: "2.txt"

Size: 5 Block: 8 IO block: 4096 normal file

Device: fd00h/64768d inode:146705 hard Link: 1

Permissions: (0642/-rw-r---w) Uid: (0/root) Gid: (0/root)

Last visited: 2017-06-08 07:17:01.341855735 +0800

Last modified: 2017-06-10 16:31:02.055929915 +0800

Last modified: 2017-06-10 16:31:02.055929915 +0800

Creation Time:-

[[email protected] ~]# Find/-type f-mtime-1 change files within one day

[[email protected] ~]# find/etc/-type f-o-mtime-1-o-name "*.conf" (-O is or means, not added and meaning)

[[email protected] ~]# Find/-inum 146706 find hard link)

/root/3.txt

/tmp/1.txt.bak

[Email protected] ~]# find/root/-type f-mmin-60

/root/2.txt (find files changed within one hours)

[[email protected] ~]# find/root/-type f-mmin-60-exec ls-l {} \; Find files that have changed within one hours and list which files have been changed.

-rw-r---w-1 root root 5 June 16:31/root/2.txt

[Email protected] ~]# find/root/-type f-size-10k-exec ls-lh {} \;

Find files less than 10k under/root and list

[[email protected] ~]# find/root/-type f-size-10m-exec ls-lh {} \;(look for files above 10M, where-exec is the shell command that will execute this parameter on the matching file,-exec is equivalent to-ok, but there is a difference between the two is the exec directly processing, and OK is before processing prompt information, for the user to choose whether or not to do further work


7 filename suffix

    • Common file suffix names under Inux

1: System files *.conf configuration file

. RPM RPM Package

. A an archive file

. lock a trivial file

. ~ Backup File

. Hide File

2: Program or script. C C language source program Files

. cpp C + + language source program

. h C or C + + header files

. O Program Object files

. pl Perl Language source program

. PHP PHP Language source program

. tcl Tcl Script Program

. so/.lib Library File

. SQL SQL language files

3: Format File

. txt unformatted ASCII code file

. html/.htm Static Web page

. PS Postscipt File

. Au a sound file

. wav a sound file

. xpm an image file

. png a graphic, image file

4: Archive and Compress files

. Tar Tar archive file

. z/.gz/.bz2 Compressed Files

. TAR.GZ/.TGZ/.TAR.BZ2/.TBZ is a compressed tar package

8 Linux+windows Mutual Transfer files

Linux and Windows mutual files have a very useful tool is Rz/sz, as described below (indicating that this tool is suitable for Xshell)

[[email protected] ~]# Yum install-y lrzsz (this tool must use X-shell) [[email protected] ~]# sz 1.txt upload files from Linux to Windo [email prot Ected] ~]# rz (upload files from Windows to Linux)



Linux Basic Command Ⅲ

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.