In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "what are the common file management commands on the Linux system?" in the operation of actual cases, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
File View Class Command
1.cat
Cat can view the contents of a text file
Cat a.sh
-A View Line Terminator
Merge file contents cat / etc/fstab / etc/init.d/network > > / tmep/test.file
2.less/more
Files can be viewed page by page.
Less / etc/init.d/network
Pgup/pudn bhand f flips up / down
/ STRINT lookup string STRINT
N find next
3.head
The first n lines of viewing the file, the default is 10 lines
-n specify the first n lines head-11 / etc/init.d/network
4.tail
View the last n lines of the file. The default is 10 lines.
N lines after-n assignment, tail-11 / etc/init.d/network
Special usage
Tail-f / var/log/httpd/access_log continuously tracks the appended contents of files and is mainly used to view log files
Create files such as touch,vi,nano,nano, etc.
Delete the file rm-rf
Copy a file
1.cp
Cp source file target file
Only files can be copied, and one or more can be copied.
Cp / etc/init.d/network / etc/init.d/functions / tmp/
But if you copy multiple files, it can only be followed by a directory. If you copy a file, it can be followed by a file.
-f overwrite replication
-r copy the directory and all the files below
-a retain the original attributes when copying, such as ownership, 3D timestamp, mainly used for archiving documents
2.install
Install source target such as install / etc/grub2.cfg / tmp/
The default permission is 755 after copying. If the chmod command is lost, you can use scp to copy it from other hosts and then copy it with install, so you have the right to execute.
-m specify permissions install-m 000 / etc/grub2.cfg / tmp/
3. File lookup
Locate matches according to the database, fast, easy to use, non-internship
Find is copied by find command, so it is told in a separate article.
4. Move / rename full name file
Mv file to file2
Mv / etc/init.d/network / etc/init.d/network.bak
Mv / etc/init.d/network / tmp
5. Create a new directory
Mkdir-p cascading to establish a directory, skip if the directory already exists, and establish if it does not exist
Mkdir-pv / usr/local/tmp/src/httpd
6. Move / rename / delete just like a file
Second, use the command line expansion function to create / tmp/a1, / tmp/a2, / tmp/a1/a, / tmp/a1/b, and create a directory under the / tmp directory: xSecrety, xroomz, qroomy, qroomz
Mkdir-pv / tmp/a1 & & touch / tmp/a {1 / {arecine b}, 2}
Touch / tmp/ {x,q} _ {y,z}
How to modify the timestamp information of a file.
The data flow of a file is divided into two types, one is the file content, the other is the file metadata
There are thirteen metadata, 13 yuan for short, which is also the name of the rhyme of A Dream of Red Mansions.
1. File name
two。 File size
3. Data block where it is located
4.
5. File type
6. Inode where the file is located
7. Number of hard connections
8. Authority
9.UID
10.GID
11. Last visit timestamp
twelve。 The last time the contents of the file were changed
13. When the metadata was last changed
View file metadata stat file
Stat / dev/sr0
What if you change the file metadata?
Touch file changes the file with three timestamps
-an access, changing the access time, but also changing the time when the metadata was last changed
-m modify, change the time when the contents of the file were modified, but also change the time when the metadata was last changed
Create a file under the / tmp directory that starts with tfile, followed by the current date and time, with a file name such as: tfile-2016-05-27-09-32-22.
Copy all files or directories under the / etc directory that begin with p and end with non-numbers to the / tmp/mytest1 directory.
Mkdir-p / tmp/mytest1
Cp-r / etc/p* [^ [: digit:]] / tmp/mytest1
Create user tom, specify UID as 5001, home directory as / tmp/tom, shell as / bin/zsh, basic group as tom, and additional group as jack
Setenforce 0
Groupadd jack
What are the commonly used user and file management commands, and demonstrate the commands and usage.
What is a user? The user is the unique identification of the computer to the user.
Why should there be users? Because all processes can only be run by the user, the process that is not running is just a static file. No matter when and where only users can log on to the system and use computer resources.
The user format is as follows: separated by: no blank.
User name: X:UID:GID: comment: home directory: shell
Ajxzl:x:1000:1000:ajxzl:/home/ajxzl:/bin/bash
Slackware:x:1001:1001::/home/slackware:/bin/tcsh
User name: login name visible to the user
X: password. Placed in the / etc/shadow file. X is used to occupy seats.
UID: the unique identification that the computer can recognize. Same as GID: 0 is root.1-999 for system user. 1000-60000 ordinary users. 60000 reserved.
What is the system user? Because all processes must have an owner, that is, they must belong to a certain user. In order to enable some processes to boot or background processes, the assigned user is called the system user. These users can never log in to the system. Purely to run a process.
GID: user basic group.
Home directory: default directory when logging in
Shell: log in to shell by default
Useradd adds users.
Useradd [option] user name
Useradd ajxzl
-u UID useradd-u 3001 ajxzl2
-r system user useradd-r ajxzl3
-g GID basic group GID. But this group must have useradd-g 1000 ajxzl4 beforehand.
-G GID additional group GID, this group must have useradd-G 1001 ajxzl5 beforehand
-c comment useradd-c "This is a testusre" ajxzl6
-d directory user home directory. Useradd-d / tmp/ajxzl7 ajxzl7 default / home/USER_NAME
Home directory template file / etc/skel/
Modifying the contents of this directory will affect all new user home directory contents.
-s shell_name sets user shell. The default is / bin/bash. View all shell:cat / etc/shells
Where is the default shell set? / etc/default/useradd default options for new users
Useradd-s / bin/cash ajxzl8
-M does not create a home directory useradd-M ajxzl10
Note that-r will not create a home directory either.
User password management
Password management file: / etc/shadow in the following format: .man 5 shadow
Ajxzl9:$6 $/ DjwtprZ$sZ/Vw4d9.8hBGLkYCl7yaqMhKqXeIVAisTGVZ53o4v5AsY4HCSE0HqP5y7d2.K/FaaHzbuKTklXVrCMgbB3Bf.:17823:0:99999:7:::
User name: password after encryption: date of the last password change: minimum life of password: maximum password life: password warning period: password expiration time: account expiration time: reserved field
There are 9 fields in total.
User name: user login name
Password: password. Can be empty, which means no password. If it is * or! Indicates that login through password is prohibited.
Date of last password change:
Minimum password life: 0 means it is not set
Maximum useful life: 99999
Password disabled date: indicates the number of days after the warning period that the password has not been changed. At this point, login with a password will be prohibited, but it may be done in other ways.
Account ban period: login is prohibited.
Reserved field
Modify user: usermod [Action] username
-ag adds additional groups
-d home directory
-m modify the home directory and move the data to the new home directory
-L locks the user so that he cannot log in
-U unlock the user
Delete user userdel-r username
Passwd: command. Change user password
-d clear user password
Id command: viewing user information
-u only watch uid
-g only watch gid
-n results are displayed by name
Newgrp group_name switch user basic group
Finger displays user login information
Pwck: user items are checked according to / etc/passwd by default.
Correct number of fields
A unique and valid user name
A valid user and group identifier
Valid primary group
Valid home directory
A valid login shell pwck shadow checks whether the user's password is valid, expired, etc.
This is the end of the content of "what are the common file management commands on the Linux system?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.