Linux File Management
Create a touch vim / vi echo redirection
touch 管理:atime mtime ctime
touch the file name // If the file does not exist create a file
touch -a -t [CC]YY]MMDDhhmm[.ss]
20190827100322
-C
Delete 1, mv / tmp
2、find| xargs rm
3、rm
rm delete files
alias rm -i
-i Tips
-f
-r
By default rm-f / are deleted to prevent (and in the following versions centos 5)
6 is to be deleted and centos7 need to add a parameter; --preserve-root root can be deleted
rmdir remove directory
mobile
File transfer has two actions : one is the " push " is the " pull " approach;,
mv move files, rename
-t
mv abcd / e // a plurality of files to a directory simultaneously
mv ab // change the name of a file name to b
Covering issues -i
cp
cp ab
-t
-a can copy the properties directory and directory files!!
install delete and copy files
-d delete files
-t
-g Specifies the group belongs
-o specify your main
-m assign permissions to copy files
Command file transfer between Linux machines - scp;
linux1--linux2
linux1: scp file root @ ip (linux2): / directory
linux2: scp root @ ip (linux1: / file in the local directory that
4. Find
locate
Find a need to generate a library - not commonly used
updatedb I look to find the corresponding file in the library
find
According to any one of the attributes of the file to find the file
1, inode2, 3 file type, file permissions 4, hardwired having 5, 6 belongs to the main group 7 belongs, file size 8, 9. The modified file name (globbing) -regex
-type f d s p c b l
-perm 007
Find a few levels up to -maxdepth directory
-mindepth directory to find at least a few levels
find ./ -maxdepth 1 -perm + 1
find ./ -maxdepth 2 -perm 755
-links
find ./ -maxdepth 1 -links 2
-user -nouser
-group -nogroup
-size [default unit is how much?]
-mtime -ctime -atime + - Digital
-name wildcard
-regex specified using regular expressions
------------
-ok
-exec
|xargs
5, compression and recursion
Compression - 1. Only the file compression; 2, let the source file smaller
-z gzip ---------
bzip2 ----------- -j
xz ------------- J
Archive - 1 Archive 2 can operate on the directory, the directory will not allow smaller
takes
-c -x
-v
-f filename Specifies the file name to create a compressed
[Decompression, it is best not to compress the file specified]
6, edit
Full-screen editor:
nano
you vim
[Distinguish sed stream editor line editor]
vim
1, the default command mode -------- | il a A o O enter the edit mode
| ESC to enter the last line mode
2, commonly used technique in command mode
2.1. Up and down hjkI
2.2 dd ndd delete
p np Copy
u (operations on a) the U-(return to the initial state into the file)
yy nyy
gg cursor jumps to the first line of the file contents
G cursor jumps to the file end of the line
c=dd+i
r replacement character cursor to the specified character
v access optional mode, to select the specific content, then a corresponding operation
3, line mode
[Line mode operation and a lot of the same] sed
,$S/^#/ /g
: $ Move the cursor to the end of the file: 1.
:W
: W filename Save the current file to a new file to
:q
: Wq // representatives mandatory!!
[In command mode ZZ can also save and exit the file]
Seek
/ Down operation of a next one of N n
? Look up above a n a N below
Edit multiple files simultaneously case
:next
vim a b
5DD
:next!
p
:perv
:first
:last
: Q // exit the current file
: Q:! Qa // Quit all files
Compare View Files
1, the vertical split screen
-The came ab
Move the cursor ctrl + w w release
Then cut screen ctrl + w releasably V
2, a horizontal split screen
I came -oab. .
Move the cursor : ctrl + w release w.
Then cut screen : ctrl + w releasably S
: Qa all out!
:! Wq to save and exit all
linux user and user rights management
User Management :
1, useradd to create the user
-c Specifies the user description
-d specifies the home directory of the default directory of the same name under the home directory / home
-g Specifies the primary group
-G specify additional group
[A user can have only one primary group, and there may be two additional groups}
-s specifies the shell program
Special: / sbin / nologin -> user is not allowed to log system
-u UID specify
-M do not create home directories
2、userdel
-r home directory block with deleted
3, usermod - Modify
-cd -mgGsu -o (UID allow same, and since the use -u-)
4、passwd
-1 lock
-u unlock
-d remove the password
echo "password" | passwd --stdin "username"
Group Management
1、groupadd
-g Add Group
-o delete a group
2, groupdel delete group
3、groupmod
-g
-O
-n modify the group name
[-p password specified group if a file input this additional group of users, and you want to access the file, others thought that the group can set a password]
Common file
/etc/passwd
uname: x: uid: gid: Description home directory: shell program
Superuser - root
User 1-4991-999 ordinary users 500-65535 1000-65535
/etc/shadow
uname: uid: Password: various time ..
/etc/group
Group: Group Password: Group ID: Additional group
/etc/gshadow
/etc/skel
Files in this directory will be copied to each ordinary user's home directory, generally used for warning ;
User rights
r w x
Read write execution
4 2 1
r 100
w 010
x 001
chmod [a | o | g | u] [+ | -] Files
chown: user10 file
chown user10: file
chown user10: user10 file
acl license management:
By rights management, assign permissions to the specified user ;
setfacl - add permissions
setfacl -mu: Username: added file // file permissions - If given the user's files
setfacl-x u: Username file // file permissions canceled
getfac
View acd add permissions
Special permission bits
Temporary permission to borrow: temporary authority to borrow ; for example: There are two user inputs AB and BB AA group group; A user creates a a.txt, B default access a.txt continue using other; however, if I want to override , a's permission to borrow to visit a.txt, would need to
To SUID bit is set to 1; also can borrow SGID permissions to access the file;
Sticky bit role: licensed to a directory, all users can delete their own files in the directory, others can not delete your files ; - granted to the file directory;
SOUTH
chmod u + s filename // granted special privileges of SUID
If the owner has rights x s appear as
If no owner permissions x shown as S
SGID
chmod u + s filename // granted special privileges SGID's
If the owner has rights x s appear as
If no owner permissions x shown as S
Sticky
chmod o + t // file granted special privileges sticky bits
If the owner has rights t s shown as
If no owner permissions T shown as S
sudu 授权
/ Etc / sudoers // In this file add the permission to go inside;
ITS-
its
sudo
Linux disk management
File system
LVM Logical Volume Manager
RAID Disk Management