Take out those adjectives, and you're left with facts.

"To Kill a Mockingbird"

picture


Directory Basic Operations

  • cd change directory

  • cd <directory name> (absolute path/relative directory) .. one level up ~ current user directory

  • ls list directories

    • -a: all include hidden directories
    • -l: list all files
  • mkdir <directory name> create a directory

    • -p: recursively create directories
  • rmdir <directory name> can only delete empty files

    • -p delete recursively
  • pwd View the absolute path of the current directory

  • cp <original directory> <new directory> Copy file or directory

  • rm removes a directory or directory

      rm -rf / # 删机跑路
    • -f ignore non-existing files without warning, force deletion
    • -r delete directories recursively
    • -i interactive, delete asks whether to delete
  • mv move directory or file/rename

    # 重命名
      mv a.txt b.txt
    • -f force move
    • -u replace the updated file

File basic attributes ten letters

[root@hecs-409959 ~]# ls -al
总用量 104
dr-xr-x---.  9 root root  4096 8月   2 14:40 .
dr-xr-xr-x. 21 root root  4096 6月  12 00:40 ..
-rw-r--r--   1 root root 16426 8月   2 11:48 .bash_history
-rw-r--r--.  1 root root    18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root   176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root   176 12月 29 2013 .bashrc
drwxr-xr-x   3 root root  4096 6月  15 13:09 .cache
-rw-r--r--.  1 root root   100 12月 29 2013 .cshrc
-rw-r--r--   1 root root    76 7月  25 18:03 .gitconfig
-rw-------   1 root root     0 2月  10 14:31 .history
drwxr-xr-x   4 root root  4096 6月  15 13:09 .local
drwx------   3 root root  4096 8月   1 18:49 .mongodb
-rw-r--r--   1 root root  6140 11月 12 2015 mysql-community-release-el7-5.noarch.rpm
-rw-------   1 root root   200 8月   2 14:40 .mysql_history
-rw-------   1 root root     3 6月  15 13:11 .node_repl_history
drwxr-xr-x   4 root root  4096 6月  10 14:07 .npm
drwxr-----   3 root root  4096 2月  10 14:23 .pki
drwxr-xr-x   5 root root  4096 6月  15 13:14 .pm2
drwx------   2 root root  4096 6月  15 13:00 .ssh
-rw-r--r--.  1 root root   129 12月 29 2013 .tcshrc
-rw-------   1 root root  5060 8月   1 19:07 .viminfo
  • first character identifier

    • d:Table of contents
    • -:document
    • l: link file
    • b: Device interface available for storage in the device file
    • c: Serial port devices in the device file, such as keyboard and mouse, etc.
  • Authority ID

    File attributes from left to right

    file type
    0
    owner owner permission
    1 2 3
    group belongs to group permissions
    4 5 6
    otherOther users7
    8 9
    d
    file directory
    rwx
    read and write execution
    rwx
    read and write execution
    rwx
    read and write execution
    • -not writable
    • r read
    • w writable write
    • x executable execute
  • 1 4 7 bits for read

  • 2 5 8 bits for write

Modify file properties

1. chgrp changes the group of files

chgrp [-R] owner name file name

-R recursively change file ownership group,

2, chown to change the file owner can also change the file group at the same time

chown [-R] owner name file name
chown [-R] owner name: group name file name

3. chmod changes 9 attributes of the file

chmod [-R] xyz folder or directory

Two ways to set linux file attributes

  • Numbers are commonly used
  • symbol

owner group others
r:4 w:2 x:1

readable and writable non-executable rw-6
readable and writable executable rwx 7

For example: give each identity (owner/group/others) three permissions (r/w/x) points to accumulate
if the permissions are [-rwxrwx---]

  • owner = rwx = 4+2+1 = 7
  • group = rwx = 4+2+1 = 7
  • others = --- = 0+0+0 = 0

chmod 770 filename

file content view

  • cat displays the file contents starting from the first line

  • tac displays the file contents starting from the last line

  • nl output line number view

  • more page view:f line number

  • less is similar to more, it can page forward and push q

  • head only looks at the first few lines

  • tail only looks at the tail line

  • help command main [command]

  • CentOS7 network configuration directory cd /etc/syscojnfig/network-scripts

    • ifconfig command to view network configuration

soft link hard link

  • Hard links
    allow a file to have multiple paths

  • Soft Links /Symbolic Links

    Similar to the shortcut under Windows, delete the source file, the shortcut cannot be accessed

  • ln create link

    ln f f2 # create a hard link
    ln -sf f3 # create a soft link

  • touch create file command

  • echo input and output strings

    echo "admin test" > f

Vim editor

three modes

  • Command mode
  • Insert mode
  • Last line mode

command mode

  • i switch to input mode to enter characters
  • x delete the character under the cursor
  • : Switch to bottom line command mode after exiting edit mode
operate hot key
delete digital dd
copy entire line number yy
paste p
cut dd
delete the cursor position x
Remove line endings from cursor D
revoke u
Undo ctrl+r
replace r
Quickly navigate to the beginning of a line [number]gg
next page ctrl+f
previous page ctrl+b
next page ctrl+d
first half page ctrl+u
line start 0/home
Toggles the number of characters of the cursor backward digital space
Cut to the first line of the screen H
Cut to screen center header M
Cut to the bottom line of the screen L
Cut to the beginning of the line at the end of the file G
cursor down n n enter
similar to gg nG
Find the string behind the cursor /string
Find the face of the string in front of the cursor ? string

Open multiple files
vim -o /O ./a.txt ./b.txt
switch focus ctrl + ww

input mode

  • Arrow key
  • home/end
  • page up/page down
  • insert
  • esc switch to command mode

Bottom Line Command Mode

  • : Enter the bottom line command mode
  • q quit
  • w save
  • a close all
  • ! mandatory
  • set nu display line number
  • set nonu does not display line numbers

Account management

  • useradd -option username

    • -d specifies the user home directory
    • -m Automatically create user directory
    • -c specifies a comment
    • -g specifies the user group
    • -G specifies additional groups to which the user belongs
    • -s specifies the user's login shell
    • -u User ID, and -o User ID can be repeated at the same time
  • userdel -r username

    • -r delete user home directory
  • usermod -option username

    • -c
    • -d
    • -m
    • -g
    • -G
    • -s
    • -u
  • switch user

    • su username
    • sudo su: switch normal user to root
    • exit logout ctrl+d return to the original user
    • When switching users, if you want to use the new working environment after switching users, you can add - between su and username: su -root
    • ¥for ordinary users
    • #means root user
  • View host name

    hostname
  • Modify/set user password

      passwd <username> # 没有用户名就是修改自己的秘密 带用户名就是修改指定用户密码
  • View users

      cat /etc/passwd

    username:password:userid:groupid:commental description:home directory:login shell

  • View encrypted passwords

      cat /etc/shadow

    Login Name: Encrypted Password: Last Modified Time: Minimum Interval: Warning Time: Inactivity Time (days): Expiration Time (days): Flags

  • View group

   cat /etc/group
  • Locked account, can't log in after locked

      passwd -l guest # 锁定
      passwd -d guest # 清空密码也不能登录

user group

  • Create user group
  groupadd <newgroupname> -option
 - `-g` 指定id
  • delete user group groupdel

  • Modify user group permission information

  • groupmod -g [id] -n newname oldname

  • switch user group

    • newgroup groupname

Disk management

  • df lists the overall disk usage of the file system

    • -h G/M units
  • du checks disk usage and generally enters the specified directory to view

      du -sm /*
  • mount mount

     mount /dev/someupan /mnt/kuangshen
  • unmount unmount

      unmount -f [挂载位置]
    • -f force uninstall

Process management

  • Each program in Linux has its own process, and each process has an id number
  • Every process will have a parent process
  • There are two ways for a process to run in the foreground and background
  • General services are running in the background, basic programs are running in the foreground

ps View information about various processes being executed in the current system

  • ps

     # 查看所有进程
     ps -aux |grep mysql
    • | Pipeline command
    • grep finds strings in files that match tuning
    • -a Displays information about all processes running on the current terminal
    • -u Display processes with user information
    • -x Display the parameters of the background running process
  • ps -ef|grep mysql View parent process information

  • pstree -pu process tree display

    • p shows the parent id
    • u show user group
  • Kill the process kill -9 [process id]

install software

rpm install

  • rpm -ivh [package name]

Configure environment variables

 vim /etc/profile
  export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_192
  export MONGODB_HOME=/home/soft/mongodb-linux-x86_64-rhel70-5.0.2
  export NODE_HOME=/home/soft/node-v12.18.1-linux-x64
  export M2_HOME=/home/soft/apache-maven-3.5.4
  export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar
  export PATH=$PATH:$JAVA_HOME/bin:$MONGODB_HOME/bin:$NODE_HOME/bin:$M2_HOME/bin
  export RUN_AS_USER=root

Make the configuration take effect

source /etc/profile

Unzip the installation

tar -zxf ***.tar.gz

yum online installation

yum update
yum install mysql-server

View system version

cat /etc/redhat-release

other

  • history View commands used in history
  • reset initializes the terminal
  • clear terminal clear screen
Thank you for reading, welcome to follow, like, favorite, share