First, the user management (supplement)
Add a user: useradd [option] username
useradd -u 5000 -g demogroup -G root -d /home/demo -s /bin/bash demo
-u UID specify
-g specified group
-G specified user also belong to other groups
-d specifies the home directory (home directory, home directory, the default directory)
-s specifies the parser
-o -u and general use, create, and other users of the same user ID
Users are automatically added by default user name and join the same group
Modify a user:
usermod -l / -d / -g / -s username
-l modify the user name: usermod -l test number changed to number the user name test
-d modify the home directory: usermod -d / home / ko test will test the home directory to / home / ko
-g modify the owning group: usermod -g root test will test group belongs to root
-s modified parser: usermod -s / bin / zsh test The test parser (default bash) to replace zsh
Disable User: usermod -L username
Restore user: usermod -U username
Switch user: su
View the current user: whoami id (user names, group names can see)
View the current logged-on user belongs to which group: groups
What groups view the current Linux: / etc / group password: / etc / gshadow
geoclue:x:139:
kpadmins:x:140:
Debian-gdm:x:141:
dradis:x:142:
beef-xss:x:143:
systemd-coredump:x:999:
test (group name): x :( password) 1001 (GID) :( what the user's current group)
To add a group: groupadd Username
To delete a group: groupdel Username
The pentest user to the test group: gpasswd -a pentest test
The pentest user is removed from the test group: gpasswd -d pentest test
Two, Linux rights management
1, Linux file types
- binary file
d directory
l linked file
2, ls -l introduction
-rwxr-xr-x 1 root root 4405 6月 14 2013 nipper.conf
-rw-r--r-- 1 root root 553 8月 27 21:07 nsswitch.conf
drwxr-xr-x 2 root root 4096 9月 10 19:49 openal
drwxr-xr-x 4 root root 4096 9月 10 19:49 openvpn
drwxr-xr-x 3 root root 4096 9月 10 19:49 opt
lrwxrwxrwx 1 root root 21 9月 5 22:10 os-release -> ../usr/lib/os-release
The first column: the file type and permissions
A total of 10, the first is the file type, the second to the fourth place is the owner of the rights of the current file permissions fifth to seventh place indicates that the document belongs to the group, the eighth to tenth place indicates that the file others permission.
Example: -rw-r - r-- - (binary) rw- (rights holders) r - (owning group permissions) r - (Others Do)
r: read 4 w: write 2 x: executable 1
Example: 713 rwx - x-wx
Meaning permissions for files and folders
For the meaning of the document | For the meaning folder | |
r | You can view file contents | You can be listed directory |
w | You can modify the file | You can create or delete files in the folder |
x | You can perform file | You may enter the folder |
Change the permissions: chmod [who] [+ / - / =] filename
who: u ----> owner g ----> belongs to the group o ----> others a ----> Everyone
+: Add the permission: - Cancel permission =: assignment of certain rights
例:r--r--r-- test.php chmod +320 test.php ----> rwxrw-r--
rwxrwxrwx evil.php chmod -333 evil.php ----> r--r--r--
chmod 644 evil.php ----> rw-r--r--
Note: The recommended way to change the permissions of digital
The second column: the number of subdirectories or the number of links
The third column: the file owner
The fourth column: Owned by group
Change the owner or owning group
chown root / test root test will change the owner of the folder
chgrp admin / test will test your group change the admin folder
chown root: root / tmp tmp folder owner will be changed root, belongs to the group to root
chown -R root: root owner / tmp tmp folder to all files (including lower-level folder, the next level ...) to the root, the belonging group to root
Fifth column: File Size
The sixth column: Date
Seventh column: the file name
Third, the penetration commonly used commands
whoami view the current user
tar compress and decompress files
netstat view network state
nslookup + dns information see the website address
ps to see running programs
top real-time view of the operational program
service using a service control service starts to close
curl to get the page, you can redirect the output to download the file
wget to download files
Four, Linux memory management
1, ps View system processes
ps -u / -l to see the current user is part of the process of information
ps -aux to see all the user's process information system
ps -aux | grep apache apache check the specified process
ps -le | grep ssh process information
2, kill process / PID close a program
-9 forced to close
-l restart the process
killall shut down all processes
3, view ports information
netstat-ano (Windows)
netulp -ntulp (Linux)
That port services, port services and
4, top dynamic display of process information (PID, CPU-size, press q to quit)
-c Show full information
-d 5 update updated every 5 seconds
-p pid pid view a specific information
PID USER PR (process priority) NI (nice value) VIRT (virtual memory) RES (physical memory) SHR (shared memory) S (process status)% CPU (cpu percentage)% MEM
(The percentage of memory) TIME + (sum of cpu time using) the COMMAND
5, free Linux idle display, the use of physical memory, swap memory, buffer
total (total physical memory) used (used memory) free (free memory) shared (multiple processes to share the process) buff / cache (cache size) available
Five, Linux network management
ping/ifconfig/route/netstat/arp
See traceroute packet path in the network
ss socket display communication information
ss -t -a display tcp connection
ss -l all open network connecting port
ss -pl display socket used by the process