In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Find a file
Find /-name filename.text / / follow the filename.txt file under / directory by name
Find.-name ".xml" / / Recursively find all .xml files
Find.-name ".xml" | xargs grep "Hello World" / / Recursively find all xml files containing hello World
Grep-H 'spring' * .xml / / find some xml files that contain spring
Find. /-size 0 | xargs rm-f & / / Delete a file with zero file size
Ls-l | grep 'jar' / / find all jar files in the current directory
Grep 'test' d* / / displays all lines that contain test in files that begin with d.
Grep 'test' aa bb cc / / displays the lines that match test in the aa,bb,cc file.
Grep'[a murz] / {5 /}'aa / / displays all lines that contain at least five consecutive lowercase characters for each string.
Check whether a program is running
Ps-ef | grep tomcat / / View all processes related to tomcat
View files, including hidden files
Ls-al
Current working directory
Pwd
Copy a file
Cp sourceFolder targetFolder
Scp sourecFile romoteUserName@remoteIp:remoteAddr / / remote copy
Create a directory
Mkdir newfolder
Delete directory
Rmdir deleteEmptyFolder / / Delete an empty directory rm-rf deleteFile recursively delete everything in the directory
Move Fil
Mv / temp/movefile / targetFolder
Rename
Mv oldNameFile newNameFile
Switch users
Su username
Modify file permissions
Permissions for chmod 777 file.java / / file.java-rwxrwxrwx,r for read, w for write, x for executable
Compressed file
Tar-czf test.tar.gz / test1 / test2 / / compress test1 test2
List the compressed files
Tar-tzf test.tar.gz
Extract the file
Tar-xvzf test.tar.gz
View the first 10 lines of the file
Head-n 10 example.txt
View the last 10 lines of the file
Tail-n 10 example.txt
View log type files
Tail-f exmaple.log / / this command automatically displays the new content, and the screen displays only 10 lines of content (configurable).
. / startup.sh & & tail-f.. / logs/catalina.out / / restart the tomcat output log
Execute commands using the Super Admin identity
Sudo rm a.txt / / use the administrator to delete the file
View port occupancy
Netstat-tln | grep 8080 / / View the usage of port 8080
Check which program the port belongs to
Lsof-I: 8080
View the process
Ps aux | grep java / / View java process
Ps aux / / View all processes
List the contents of the directory in a tree view
Tree a
File download
Wget http://file.tgz
/ / install the wget command under mac
Curl http://file.tgz
Network detection
Ping www.taobao.com
Remote login
Ssh userName@ip
Print information
Echo $JAVA_HOME / / print the value of the java home environment variable
Java common commands
Java javacjps, jstat, jmap, jstack
Other commands
Svn git maven
Grep command function
Grep command is a powerful text search tool in Linux system. It can use regular expressions to search text and print matching lines. The full name of grep is Global Regular Expression Print, which represents the global regular expression version, and its permission is for all users.
Ps Command reference Article
Ps is the abbreviation of Process Status. The ps command is used to list the processes currently running on the system. The ps command lists the current snapshots of those processes, that is, those at the time of the execution of the ps command. If you want to display process information dynamically, you can use the top command.
In order to monitor and control the process, we must first understand the current process, that is, we need to look at the current process, and the ps command is the most basic and powerful process view command. Use this command to determine which processes are running and running status, whether the process ends, whether the process is dead, which processes are taking up too much resources, and so on. In short, most of the information can be obtained by executing the command.
Ps provides us with an one-time view of the process, and the results it provides are not dynamic and continuous; if you want to monitor the time of the process, you should use the top tool.
The kill command is used to kill the process.
1. Command format:
Ps [parameters]
2. Command function:
Used to display the status of the current process
3. Command parameters:
A show all processes
-a displays all programs under the same terminal
-A shows all processes
C display the real name of the process
-N reverse selection
-e equals "- A"
E display environment variables
F shows the relationship between programs
-H shows the tree structure
R displays the progress of the current terminal
T displays all the programs of the current terminal
U specify all processes of the user
-au displays more detailed information
-aux displays all itineraries that include other users
-C lists the status of the specified command
-number of rows displayed per page of lines
-number of characters displayed per page of width
-help displays help information
-version display version display
Example
Ps-A / / displays all process information
Ps-u root / / displays the specified user information
Ps-ef / / displays all process information, along with the command line
Ps-ef | grep ssh / / ps and grep are commonly used in combination to find a specific process
Ps-l / / list the PID and related information that currently belong to you this time
Ps aux / / lists all the programs currently in memory
Ps-axjf / / lists the program display similar to the program tree
Ps aux | egrep'(cron | syslog)'/ / find out the PID number related to cron and syslog
Chmod
Linux chmod command is one of the most commonly used commands in daily operation and maintenance, and it is more important for file management, such as setting specific permissions when setting the web directory to ensure server security.
Tip: after writing a shell script, we generally need to set permissions to the script: chmod aquix shell.sh
Give chmod-R 777 file to programs and directories directly. This kind of highest permission will cause great security risks to server security. Generally, it is not recommended to set up web directory permissions on online servers. Chown can be configured to set the permissions of web directories. For example, the user permissions for uploading pictures are set to web, and the same settings are also set for directories in web that need to be operated by programs: chown-R apache:apache web. For other read-only files or directories, keep root permissions, which can increase server security.
Linux command: chmod
Permissions: all users
Usage: chmod [- cfvR] [- help] [- version] mode file. Note: the file call authority of Linux/Unix is divided into three levels: file owner [owner], group, and other users. Using chmod, you can control how files are called by others.
Chmod-related command: chown,umask, parameter: mode: permission setting string, format as follows:
[ugoa...] [[+-=] [rwxX]...] [,...] Where u represents the owner of the file [user], g
Indicates that the owner of the file belongs to the group (group), o indicates other users [other], and an indicates that all three are [all]. (commonly used)
Means to increase permissions, (commonly used)
Indicates the revocation of permissions, (commonly used)
= indicates the only set permission.
R indicates readable permission, w indicates writable permission, x indicates executable permission, and X indicates only if the file is a subdirectory or if the file has been set to executable.
-c: show the change action only if the file permission has indeed been changed.-f: do not display an error message if the file permission cannot be changed-v:
Display details of permission changes
-R: make the same permission changes for all files and subdirectories in the current directory (commonly used)
Example: modify all readable permissions for all to the file:
Chmod ugo+r linuxyw.com
Or
Chmod Aguilr linuxyw.com
Modify all executable permissions for all to the file:
Chmod axix linuxyw.com
Modify all executable permissions for the primary user to the file:
Chmod upright x linuxyw.com
Set the files in the linuxyw directory to everyone's executable permissions:
Chmod-R axix linuxyw/
Set all files in the linuxyw directory to 755 permissions:
Chmod-R 755 linuxyw/
Revoke writeable permissions for all files in the linux directory:
Chmod-R a Murw linuxyw/
Example
Execute ll
Return
Drwxr-xr-x 2 root root 4096 Apr 29 14:50 linuxyw
-rw-r-r- 1 root root 36 Apr 27 23:40 linuxyw.com
-rw-r-r- 1 root root 0 Apr 29 14:46 www.linuxyw.com
The result of ll returns seven columns, which indicate the following:
First column [file properties]
Column 2 [number of files]
Column 3 [owner]
Column 4 [owner Group]
The fifth column [size]
Column 6 [date of filing]
Column 7 [file name]
We set the permissions of the file is that this is the file properties in the first column.
There are ten fields in the file attributes section, such as drwxr-xr-x
Let's divide the 10 columns into four blocks: [d] [rwx] [rmurx] [rMuix]
The first block: the first column, which is used to indicate the type of the file, is like the following value:
(1) [d] is a directory, and what I have here is d, which means a directory.
(2) [-] is a document.
(3) [l] is expressed as a linked file (link file)
(4) [b] is represented as an interface device available for storage in the device file.
(5) [c] is expressed as a serial port device in the device file, such as keyboard and mouse.
The second block: columns 2 to 4, indicating the permissions of the file owner.
The third block: columns 5 to 7, indicating the permissions of the owner in the same group.
Block 4: columns 8 to 10, indicating the permissions of non-owner groups.
These permissions are indicated by three parameters [rwx] and correspond to different locations. Each block consists of three columns with a value for each column. [r] stands for readable, [w] for writable, and [x] for executable.
For example: if the owner only has read-only access, then columns 2 to 4 are [r -], the right to read and write is [rw-], and the right to read, write and execute is [rwx].
The command format for using numeric weighting is as follows:
Chmod abc filename
The abc represents three numbers and corresponds to a different subordinate group. That is:
The number a corresponds to bits 2 to 4, indicating the owner's permissions.
The number b corresponds to bits 5 to 7, indicating the permissions of users in the same group.
The number c corresponds to bits 8 to 10, indicating the permissions of other groups.
Rwx corresponds to 4, 2, 2, 1. Then read-only permissions are 4 for [rw- -], 6 for read and write for [rwx], and 7 for write plus execution for [rwx]. Read-only plus execution is denoted by 5 (4: 1) [rmurx].
Example:
Chmod 755 file1
Chmod 777 file1 chmod a=rwx file
Chmod 771 file chmod ug=rwx,o=x file
Chown
Chown changes the owner of the specified file to the specified user or group, the user can be the user name or the user ID; group can be the group name or the group ID; file is a list of files to change permissions separated by spaces, and wildcards are supported. System administrators often use the chown command to give users permission to use a file after copying it to another user's directory.
1. Command format:
Chown [options]... [owner] [: [group]] file...
2. Command function:
Change the owner and group of files through chown. You can use the user name and user identification number settings when changing the owner or group to which the file belongs. Ordinary users cannot change their files to other owners. Its operation authority is generally an administrator.
Examples
Example 1: change the owner and group
Command: chown mail:mail log2012.log
Example 2: change file owners and groups
Command: chown root: log2012.log
Example 4: change the owner and group of all files under the specified directory and its subdirectories
Command: chown-R-v root:mail test6
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.