Linux User File Disk Network Process Instructions

user related commands

useradd username Add user
useradd -g groupname username     Add user to group
passwd username  set password
id username  View the details of the username
cat  /etc/passwd    Check which users have been created
su username  Switch username (can't get environment variables)
su - username Obtain environment variables and execute permissions)
userdel username delete username   
 userdel -r username  The directory of the user name Yu user is also deleted
who am i  View login information
sudo username Set ordinary users to have root permissions [vim etc/sudoers modification]
usermod -g usergroup username  Modify a user's initial login group

Commands related to user groups   

groupadd group name Add new group
groupdel group name delete group
groupmod -n new group name old group name modify group name
cat /etc/group See what groups are created

file permission class

 

 

 chmod change permissions

          Method 1: chmod { {ugoa}+-={rwx}} file or directory

          Method 2: chmod number (777 binary: 111 111 111) file directory

 chown change owner

         chown -R end user user file or directory

 chgrp change group

          chgrp end user group file or directory

search for class

find 【Search range】【Options】{-name<query method> -user<username> -size<file size>}
Use updatedb as much as possible before locate search files
grep filter search and "|" pipe character
eg:ls | grep - n initial-setup-ks.cfg

compression and decompression 

gzip files (can only compress files)

gunzip filename.gz

zip [-r] compressed directory

unzip [-d] <directory> specifies the directory where the decompressed files are stored

tar package

             options

-c Generate a .tar package file
-v show details
-f Specify the file name after pressing the lock
-z Unzip while packing
-x Extract the .tar file
-C Unzip to the specified directory

       -zcvf file name [use together but f must be put at the end] package

       -zxvf filename unzip to current folder

  Disk View and Partition Class      

    du View the disk usage of files and directories

        du [option] file|directory

          options

-h show friendly information
-a View not only subdirectory size, but also files
-c After displaying all file and subdirectory sizes, also display the total
-s only show sum
-max-depth=n Specify the depth of the statistics subdirectory as the level

  df view disk usage

      df -h  lists the overall disk usage of the file system to view the file system occupancy

lsblk View the mounting status of the device

 lsblk -f View device mount status

 mount|umount mount|unmount

   mount 【-t vfstype】【-o option】 device dir 

  umount device file name or mount point

  Set up automount 

        vi   /etc/fatab

fdisk partition

    fdisk -l View disk partition details

 fdisk hard disk device name (partition operation)

  m display command list p display current disk partition n add new partition w write partition information and exit q exit without saving partition information

  Use mkfs -t xfs to specify the file system type for formatting

Process management class

    ps View the process status of the current system

        options

a Show all processes of all users with a terminal
x List all processes of the current user, including processes without a terminal
u friendly display
-e list all processes
-u List processes associated with a user
-f Show a list of all processes in full format

                ps aux cpu share

                ps -ef parent process ID of the process

kill terminates the process

pstree [-p display process ID||-u display process user]

top 实时监控系统进程状态

netstat 显示网络状态和端口占用信息 

     netstat -anp|grep 进程号 

     netstat   -nlp|grep 端口号

crontab 系统定时任务

     【1】启动服务     systemctl restart crond

     【2】基本语法  crontab 【选项】                

-e 编辑crontab的定时任务
-l 查询crontab任务
-r 删除当前用户的crontab的任务

举例每隔1分钟向hello 文件中写入一个a字符

                        *1 * * * * echo "a" >> /root/hello

Guess you like

Origin blog.csdn.net/qq_57533658/article/details/130026820