6. user and group related commands 1. groupadd command function: add groupaddtest1 & nbsp; add test1 group groupadd-g1111test2 & nbsp; add test2 group, group id 11112, useradd command function: add user useradduser1 & nbs 6. user and group commands
1. groupadd command
Function: Adds a group.
Groupadd test1 add test1 Group
Groupadd-g 1111 test2 add test2 group with id 1111
2. useradd command
Function: add a user
Useradd user1 add user user1, home is/home/user1, group is user1
Useradd-g test1-m-d/home/test1 test1 add user test1, home is/home/test1, group is test1
User list: displays the list of logged-in users
3. passwd command
Function: change the user password.
Passwd user1: change the password of user1.
Passwd-d root: delete the password of the root user
4. userdel command
Function: delete a user.
Userdel user1 delete user1 user
5. chown command
Function: change the owner of a file or directory.
Chown user1/dir: Set the/dir directory to all
Chown-R user1.user1/dir: set all the files and directories in the/dir directory to user1 and set the group to user1. -R recursion to each file and directory below
6. chgrp command
Function: changes all groups of files or directories.
Chgrp user1/dir set the/dir directory to all
7. chmod command
Function: change user permissions.
Chmod a + x file sets the file to executable, and the script file must be set in this way. Otherwise, it must be executed using bash file.
Chmod 666 file: Set the file to read/write.
Chmod 750 file: sets the file as the full permission of the owner. the file can be read and executed in the same group. other files have no permissions.
8. id command
Function: displays user information, including uid and gid.
# Id zhoulj
Uid = 500 (zhoulj) gid = 500 (zhoulj) groups = 500 (zhoulj)
9. finger command
Function: displays information for use.
Note: this command is not available in debian.
# Finger zhoulj
Login: zhoulj Name:
Directory:/home/zhoulj Shell:/bin/bash
On since Sun May 21 07:59 (CST) on pts/0 from 192.168.1.4
No mail.
No Plan.
VII. compression commands
1. gzip commands
Function: compress the file in gz format.
Note: the generated file overwrites the source file.
Gzip-v Compress the file and display the progress
-D Extract
Gnuzip-f Extract
For example:
# Gzip a. sh
# Ll
-Rwxr-xr-x 1 root 71 Aug 17 21:08 a.sh.gz
# Gzip-d a.sh.gz
# Ll
-Rwxr-xr-x 1 root 48 December 18 21:08 a. sh
2. zip commands
Function: zip commands for compression and decompression
Zip
Unzip
For example:
# Zip a.sh.zip a. sh
Adding: a. sh (stored 0%)
# Ll
-Rw-r? R? 1 root 188 May 21 10:37 a.sh.zip
# Unzip a.sh.zip
Archive: a.sh.zip
Replace a. sh? [Y] es, [n] o, [A] ll, [N] one, [r] ename: r
New name: a1.sh
Extracting: a1.sh
# Ll
-Rwxr-xr-x 1 root 48 December 18 21:08 a1.sh3 and bzip2 commands
Function: bzip2 compression command,
Note: the generated file overwrites the source file.
Bzip2
Bunzip2
For example:
# Bzip2 a. sh
# Ll
-Rwxr-xr-x 1 root 85 December 18 21:08 a.sh.bz2
# Bunzip2 a.sh.bz2
# Ll
-Rwxr-xr-x 1 root 48 December 18 21:08 a. sh
4. tar command
Function: archive, compress, etc. it is important and will be used frequently.
-Cvf Compressing files or directories
-Xvf Decompress a file or directory
-Zcvf Compressed file or, in the format of tar.gz
-Zxvf Uncompressed file or, in the format of tar.gz
-Zcvf Compressed file or, in the format of tgz
-Zxvf Decompress the file or, in the format of tgz
Example:
# Tar cvf abc.tar *. sh
# Tar xvf abc.tar
# Tar czvf abc.tar.gz *. sh
# Ll
-Rw-r? R? 1 root 20480 May 21 10:50 abc.tar
-Rw-r? R? 1 root 1223 May 21 10:53 abc.tar.gz
# Tar xzvf abc.tar.gz
8. network-related commands
1. ifconfig command
Function: displays the information for modifying the NIC.
Ifconfig displays network information
Ifconfig eth0 displays eth0 network information
Modify network information:
Ifconfig eth0 192.168.1.1 netmask 255.255.255.0 set the IP address 192.168.1.1 of Nic 1, mask 255.255.255.0
Ifconfig eth0: 1 192.168.1.2 bind the second address of network card 1 to 192.168.1.2
Ifconfig eth0: x 192.168.1.n the nth address of network card 1 bound to 192.168.1.n
For example:
# Ifconfig eth0: 1 192.168.1.11
# Ifconfig
Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: 06: 9C: 24
Inet addr: 192.168.1.5 Bcast: 192.168.1.255 Mask: 255.255.255.0
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 4220 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 3586 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 fig: 1000
RX bytes: 342493 (334.4 Kb) TX bytes: 469020 (458.0 Kb)
Interrupt: 9 Base address: 0 ×1400
Eth0: 1 Link encap: Ethernet HWaddr 00: 0C: 29: 06: 9C: 24
Inet addr: 192.168.1.11 Bcast: 192.168.1.255 Mask: 255.255.255.0
Up broadcast running multicast mtu: 1500 Metric: 1
Interrupt: 9 Base address: 0 ×1400
2. route command
Function: displays the current html "target = _ blank> route settings
The current route settings are displayed on the route page.
Route add-net 10.0.0.0 netmask route 255.0.0 gw 192.168.1.254 add static route
Route del-net 10.0.0.0 netmask route 255.0.0 gw 192.168.1.254 add a static route
Route add default gw 192.168.1.1 metric1 set 192.168.1.1 as the default route
Route del default deletes the default route
Example:
# Route add-net 10.0.0.0 netmask 255.255.0.0 gw 192.168.1.254
# Netstat-nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.0.0 192.168.1.254 & nb