A recent compilation of common Linux commands looks like this

Ls Lists folders and files

Options:

  • -a Lists all files in the current directory
  • -l Displays the list
  • -h Human-friendly interface display

Parameter: The directory to display

Example: Command input: ls -alh./

cd

cd .. Returns the upper directory

CD [path] Switches the ${path} position

PWD Displays the full path of the current directory

Mkdir Creates a directory

options

  • -p Creates directories recursively. The -p option is not added and directories can be created level by level

Rmdir Deletes an empty directory

Cp Copies files and directories

options

  • -r Indicates the replication directory
  • -p Reserved file attributes

Mv (move) Cuts a file or changes its name

Grammar:

Mv [source file or path] [destination directory]

Rm (remove) The operation was deleted

Grammar:

Rm -rf [file or directory]

  • -r Deletes a directory
  • -f Forcible deletion

Touch create file

Cat View file contents

options

  • -n Indicates the row number

More Displays file contents in pages

Grammar:

  • More [filename]
  • Space or f page feed
  • Enter a newline
  • Q or Q quits

Less Displays file contents in pages

Syntax: less [filename]

Description:

  • The usage of the less command is basically the same as that of the more command, except that the less command can be used to scroll up the page
  • Less can be searched by / + enter, and n(next) indicates the next

Head looks at the first few lines of the file

  • -n Displays how many lines to view (the first 10 lines of the file are viewed by default)

Tail Checks the last few lines of the file

options

  • -n Displays the number of trailing lines (default is 10)
  • -f Dynamic display (usually used to monitor log file information)

Ln (link) Generates link files (default: generates hard links)

Grammar:

  • Ln -s [source file] [target file]
  • -s Creates a soft link

Note:

Soft links can cross partitions, but hard links cannot

Chmod (change mode) Changes the permission of a file or directory

  • Chmod [{ugoa} {+-=} {RWX} [folder or directory]]
  • [mode=421] [file or directory]
  • -r recursion modification

Express permissions numerically:

  • R — 4 You can view files and list the contents of directories
  • W — 2 Can modify file contents and create and delete files in directories
  • X — 1 can execute files and access directories

Chmod -r u+w path Sets the write permission for files in path recursively

Chmod -r 755 path Indicates the permission of files in the path path to rwxr-xr-x

Chown (change owner) Changes the owner of a file or directory

Chowm [user] [file or directory]

CHGRP (change group) Changes the owning group of a file or directory

CHGRP [user group] [file or directory]

Umark-s Displays default permissions for new files

Find file search

Find [search scope]

Matching conditions:

  • -name Searches by name
  • -iname ignores case to search
  • -size Searches based on file size
  • -user Searches based on the specified user
  • -group Searches based on the specified group
  • -cmin Indicates the file whose attributes are changed
  • -mmin Indicates that the file content is modified
  • -a and
  • -o or
  • -type File type (f, D, or L)

find /etc -name init

find /etc -name *init*

Find /etc/iname init ignores file case

find /etc -name init -exec ls -l {} ;

Locate finds a file in the file repository

locate inittab

Updatedb updates the file database

Which is the directory where the search command resides

Whereis is the directory where the search command is located

Grep searches the file for lines that match the string and prints

options

  • -I is case insensitive
  • -v excludes specifying strings

Man (manual) Obtain the help information and configuration files

  • Enter Turns the page line by line
  • Blank page by page
  • /n Searches for the keyword

man 1 cmd

man 5 conf

Short message for the whatis command

Apropos conf Displays simple information about the configuration file

Useradd Adds a new user

Passwd Changes the user password

Passwd username

Who Login information used to view information

W You can view the login details

Write Sends a message to the specified user

CTRL + D ends the save

Wall sends a broadcast message

wall [message]

Ping Tests network connectivity

  • -c Specifies the number of requests

Ifconfig (interface configure) Displays and sets nic information

mail

Last and lastlog view current and past login information

Traceroute Displays the routing nodes that the network passes through

Netstat Displays network information

  • -t TCP protocol

  • -u UDP protocol

  • – l listening

  • The -r routing

  • -n Displays the IP address and port number

  • Netstat -tlun Displays the port monitored by the local host

  • Netstat -an Displays all network connections on the local computer

  • Netstat -rn Displays the local routing table

Setup Network

service network restart

Mount Device files to be mounted

mount /dev/sr0 /mnt/cdrom/

Gzip /gunzip compressed file

You can only compress files, not save source files

Tar package directory

Tar [option] [compressed file name] [directory]

  • – c packaging
  • -v Displays detailed information
  • -f Specifies the file name
  • -z packaging and compression

The tar decompressed

  • Unpack – x
  • Z decompression
  • -f Decompresses the file
  • -v Displays detailed information

zip

Zip option [compressed file name] [file or directory]

  • -r Indicates the compressed directory

shutdown

  • -c Cancels the previous shutdown command
  • -h shutdown
  • – r to restart

Process management

Main tasks of process management:

  • Health check
  • Check the process
  • Kill the process

Ps View all processes in the system

  • Ps aux view all processes, BSD standard
  • Ps-le Views all processes

Top Displays the system health status

Pstree Displays the process tree

Kill To end a process

  • Kill -1 pid Restarts the process
  • Kill -9 Forcibly terminates the PID

Viewing System Resources

Vmstat Monitors system resources

Vmstat [Refresh time] [Number of repeats]

Dmesg startup kernel check

Free Viewing memory information

Free-m The unit is M

Viewing CPU Information

cat /proc/cpuinfo

Uname Displays kernel information

  • -a Details information
  • -r Indicates a short message

File /bin/ls you can check whether the system is 32-bit or 64-bit

Lsb_release -a Views the release version

Lsof lists the files that the process calls

System Scheduled Task

  • service crond restart
  • checkconfig crond on

Crontab Settings of the user

  • -e Edits scheduled crontab tasks
  • -l Queries crontab tasks
  • -r Deletes all crontabs of the user

Standard format: ***** command

File System Management

The disk is divided into isolated areas according to certain rules

Primary partition: A maximum of four partitions

Extended partitions, one at most, and one of the primary partitions.

Logical partition, divided from extended partition.

Ext2, ext3, 16T maximum partition and 2T single file

Ext4 supports 1EB partitions, that is, 1024PB, and 16TB files for a single file

Df -h Command to view file system information

Du Statistics directory or file size

du -sh /home/root

FSCK file system repair command

dump2fs

Mount Mount files