Common Linux command

common linux commands

Task Manager: top

Linux common system working commands

man command

View the specific available parameters and object format of the command

echo command

Display string or variable in terminal

date command

Display system time and date

< /table>

For example: Display the current time [[email Protected] ~]# date Sunday, July 22, 2018 09:36:39 CST formatted output time< span class="md-tab"> [[emailprotected] ~]# date “+%Y年%m月%d日, %H hour%M minute%S second” July 22, 2018, 09:40:52

reboot command

reboot the system (only root user Use)

Extension: su command

Used to change the identity of another user

For example: su czs switch to czs user

Logout user: logout or exit

Restart the computer: reboot or shutdown -r now

shutdown exit: halt or shutdown- h now

Task Manager: top

Linux system status detection command

ifconfig command

used to obtain network card Information such as configuration and network status

uname command

View system kernel version and other information< /span>

uptime command

Check the load of the system

free command

free command will display the memory usage, including Physical memory, virtual swap file memory, shared memory segments, and buffers used by the system core. Common parameters are:

-d, –date= STRING Display the time of the specified date
-I Display only dates
-r, –reference=document Display the last modification time of the specified file
-R, –rfc-2822 Output date and time in RFC 2822 format
-s, –set=STRING < span class="md-plain">Set the system time to the specified time STRING
-u, –utc, –universal< /span> Display UTC time (UTC) td>
–help span> display this help message and exit
–version Display version information and exit
-b Display memory usage in Bytes
-k < span class="td-span">Display memory usage in KB units
-m Display memory usage in MB units
-o Do not display the buffer adjustment bar
-s Continuously observe memory usage
-t Display the memory sum column
-v Display version information

who command

The who command displays information about all users currently on the local system. The following are displayed: login name, tty, login date and time. who command can also display the elapsed time since the line activity occurred, the process ID of the command interpreter (shell), login, logout, restart And system clock changes, and other processes generated by the initialization process can also be displayed.

last command
history command

Used to display historical records and executed commands. The history command reads the directory in the historical command file to the historical command buffer and writes the directory in the historical command buffer to the command file.

sosreport command

is used to collect system configuration and diagnose information and output the conclusion document

Linux text file editing commands

cat command

This command is used to view the content of a text file, followed by The name of the file to be viewed is usually piped together with more and less, so that the data can be viewed page by page.

-n display line number
-b display line number (not including blank lines)
-A shows “invisible” symbols, such as spaces, tab key etc.

format: cat [OPTION]… [FILE]…    -n : Number the displayed text line    -E: Display the end of line symbol $ Example: cat -n /etc/fstab –view /etc/fatab content and display the line number

< h6 class="md-end-block md-heading">more command

< span class="md-plain">For viewing longer plain text files (cat for shorter ones)

< span class="md-plain">head command

View the front of a plain text document N line ——head: display text content, the default display head 10 lines Format: head [OPTION]… [FILE]… -n #: Display text header# line content Example: head -5 /etc/passwd < span class="md-plain">–Display the first 5 lines of the /etc/passwd file< /span>

tail command

View the last N lines of a plain text document

wc command

Using the wc command, we can calculate the number of bytes, words, or columns of the file. If the file name is not specified, or the given file name is “- “, the wc instruction will read data from the standard input device.

-c or –bytes or –chars Only display the number of Bytes
-l or –lines Show only the number of lines
< span class="md-plain">-w or –words Show only word count
–help Help
–version Display version information

p>


Linux Working directory switching command share picture

share picturels command

ls command: View information in the directory Command format: ls [option] [directory name]

options Function description
-a List all files in the directory, including hidden files beginning with. (All)
-l List the detailed information of the file
-h Together with -l, output the file size in an easy-to-read format
–help display help information

share picture

 Share picturecd command

directory switching command cd switch directory

share picture < span class="td-span">Special directory symbols Meaning . Current working directory .. Parent Directory ~ User Home Directory< /span> previous working directory td>

< td>automatically complete< /span>

< tr class="md-end-block">

< td>Clear screen

Several auxiliary operations of command line compilation
Tab key
backslash\ Add \ after a line of command, which means start another line and continue typing< /span>
Up and down arrow keys find out historical commands that have been executed
Ctrl+U Key Empty to the beginning of the line
Ctrl+K span> Empty to the end of the line
Ctrl+L
Ctrl+C Terminate the execution of the command

< p>

share picture

pwd command

show the current Working directory

absolute path and relative path

< p class="md-end-block md-p">Absolute path: YesStart from the root directory (/), which completely represents the path to the target file or directory. Relative path: starting from the current directory, the complete path to the target file or directory.
Share pictures

p>

share pictureLinux file management commands

mkdir command

1. Use the mkdir command to create a directory.

options function description< /th>
-m Set the permission mode when creating a directory
-p Create each directory specified in the directory structure, if the directory does not exist, create the directory, if the directory already exists, it will not be overwritten e.g. mkdir -p ./xx/yy/uu
-v< /span> or –verboss: display information every time a new directory is created
–help Show help information

For example: mkdir+file name (in the current Create a file under the directory) mkdir /home/stduent/sl (create a folder in the specified directory) span>

Current directory: mkdir s1 s2 s3 Specify the directory: mkdir /home/czs/s2 /home/czs/s3

Preparation: File naming < span class="md-softbreak"> File names and commands in Linux systems need to be case sensitive. Linux supports long file names, up to 256 bytes (without spaces and special characters)< /span>

touch command

Used to create a new empty text file

Example: touch 1.txt

cp command

can be used for directories or files Command format: cp [options] source file target file

< table class="md-table">

options function description -a< /span> reserved chain Connection, file attributes, recursive copy directory when copying directory -i If the target file or directory already exists, the user will be prompted to confirm with the letter y -r Copy the directory to copy the files and subdirectories in the source directory to the target directory together

Example: Copy 1.txt to the uu directory cp 1.txt uu/ copy 1.txt to the current directory and name it 2.txt cp 1.txt 2.txt will uu directory (including sub File) copied to the sss directory cp -r uu sss/< /span>

mv command

Used to move or rename a directory or file (equivalent to a renaming cut command) command format: mv [option] source file Target file Example: Move 1.txt to the target file mv /mnt/xx/yy/uu/1.txt /mnt/files/ (if it is named 2.txt here, it will be 2.txt after the move is not named, then it will be the original name) change the file name in the current directory mv 2.txt 3.txt

rm command (delete files or directories)

is used to delete files, and can also delete multiple files or directories. Command format: rm [options] target file add On-f will not give a prompt to confirm deletion

< span class="md-plain">rm -f 1.txt rm -rf /mnt/files/ /mnt/s3/ (delete files and s3)

Delete directory Need to add -r Delete directory without prompt-rf

rmdir command (delete empty directories)

Delete an empty directory, and the delete operation must be performed in the parent directory. Command format: rmdir [option] directory name

options span> Function description
-p< /td>

Delete the specified directory tree
-v < span class="td-span">–verbose outputs diagnostic information during directory deletion
–help Display command help information

rmdir -p xx/yy/ (need to be empty)

find command (find)

is used to find files that meet the conditions in a relative path. Command format: find the path of the search directory, the search condition option sets the search condition

< td>Find files newer than the specified file

Options function description th>
-name Search by file name
-user Search by username
-type < span class="td-span">Search by file type
-size Find by file size
-atime Find by file’s last access date
-mtime Find by the last modification date of the file
-newer
-amin Find files that have been accessed within a specified time
-cmin Find files that have been changed within a specified time< /span>
-perm Find files that meet the specified permission value td>

Example: find / -name student

find / -user student

grep command

The grep command is used to search text, the format is: “grep [option] [file] “.

Parameter Function
-b treat executable files (binary) as text files ( text) to search
-c 仅显示找到的次数
-i 忽略大小写
-n< /td>

显示行号
-v 反向选择——仅列出没有“关键词”的行

 

获取帮助

man +指令名称 获取帮助页面 ESC+ :q退出

 

Linux压缩文件命令

tar命令

tar命令用于对文件打包压缩或解压,格式为:“tar [选项] [文件]”。

打包并压缩文件:“tar -czvf 压缩包名.tar.gz 文件名”

解压并展开压缩包:“tar -xzvf 压缩包名.tar.gz”

< td>-P
参数 作用
-c 创建压缩文件
-x 解开压缩文件
-t 查看压缩包的文件
-z 用Gzip压缩或解压
-j 用bzip2压缩或解压
-v 显示压缩或解压的过程
-f 目标文件名
-p 保留原始的权限与属性
使用绝对路径来压缩
-C 指定解压到的目录

###


Leave a Comment

Your email address will not be published.