Summary of linux shell commands

alloy@ubuntu:~$ 
alloy: account name
@: connector
ubuntu: Linux host name.
~: But the current directory
$:normal user
#: root user, use sudo.
View environment variables: echo $PATH

Directory creation command: mkdir
-p direct path creation.
-m Set directory permissions when creating a directory.
Example: mkdir -p -m 700 ppp
drwx------ 1 alloy alloy 512 Oct 27 21:19 ppp

Delete directory: rmdir
Example: rmdir ppp
but only empty directories can be deleted, use rm -rf to delete non-empty ones. Generally use rm directly

Display path: pwd
Example: liu@DESKTOP-MHNDSB8:~/mon$ pwd
/home/liu/mon

Change the current directory: cd
into the root directory: cd /
current directory: cd .Upper
directory: cd ..

File list: ls
lists all directories: ls -a
lists detailed file information: ls -l
looks at the root directory: ls /

-rw-r--r--
permissions have a total of ten digits, among them: the first one-represents the type, d represents the directory
, the three rw- represents the permissions owned by the owner (user)
and then the three r-- represents the permissions of the group (group). The
last three r-- represent the permissions of other people (other),
r read, w write, and x execute.

查 找 text: find
liu @ DESKTOP-MHNDSB8: ~ $ find / home / liu / mon
/ home / liu / mon
/ home / liu / mon / file
Unknown all-name 查 找:
liu @ DESKTOP-MHNDSB8: ~ $ find / home / liu / mo *
/ home / liu / mon
/ home / liu / mon / file
used-name Matching.
liu @ DESKTOP-MHNDSB8: ~ $ find / home -name fil *
/home/liu/min/arm-linux-gcc-3.4.5/arm-linux/include/linux/file.h
/home/liu/min/ arm-linux-gcc-3.4.5/arm-linux/include/linux/filter.h
/home/liu/min/arm-linux-gcc-3.4.5/arm-linux/include/sys/file.h
/ home / liu / min / arm-linux-gcc-3.4.5 / arm-linux / sys-include / linux / file.h
/home/liu/min/arm-linux-gcc-3.4.5/arm-linux/ sys-include / linux / filter.h
/home/liu/min/arm-linux-gcc-3.4.5/arm-linux/sys-include/sys/file.h
/home/liu/mon/file

Display the content of the file: cat
liu@DESKTOP-MHNDSB8:~/mon$ cat -n file
     1 kkkkkkkkk
     2 fsfgdhd
     3 fsfs
plus -n plus the serial number
cat connection function>
liu@DESKTOP-MHNDSB8:~/mon$ cat file test.c > cattest.txt
liu@DESKTOP-MHNDSB8:~/mon$ vi cattest.txt
kkkkkkkkk
fsfgdhd
fsfs
#include<stdio.h>
int main()
{         return 0; }

Copy command: cp
liu @ DESKTOP-MHNDSB8: ~ / LS Mike $
liu @ DESKTOP-MHNDSB8: ~ / Mike $ cp / Home / liu / Mon / File ./
liu @ DESKTOP-MHNDSB8: ~ / Mike $ LS
File
Plus - i When there are the same files, it will prompt whether to overwrite

Move and rename: mv
rename
liu@DESKTOP-MHNDSB8:~/mike$ mv file file1
liu@DESKTOP-MHNDSB8:~/mike$ ls
file1
move
liu@DESKTOP-MHNDSB8:~/mike$ mv file1 /home/liu /mon
liu@DESKTOP-MHNDSB8:~/mike$ ls
liu@DESKTOP-MHNDSB8:~/mike$

File content statistics: wc
bytes
liu@DESKTOP-MHNDSB8:~$ wc -c /home/liu/mon/test.c
44 /home/liu/mon/test.c
line number
liu@DESKTOP-MHNDSB8:~$ wc -l /home/liu/mon/test.c
5 /home/liu/mon/test.c
Number of words
liu@DESKTOP-MHNDSB8:~$ wc -w /home/liu/mon/test.c
7 /home/ liu/mon/test.c

Delete file command: rm
liu@DESKTOP-MHNDSB8:~$ rm -rf mike
liu@DESKTOP-MHNDSB8:~$ ls
min mon sources.list
plus -i with prompt

su switch user
sudo root user

Process management commands: ps and kill
liu@DESKTOP-MHNDSB8:~$ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 20:35? 00:00:00 /init
root 119 1 0 21:08 tty1 00 :00:00 /init
liu 120 119 0 21:08 tty1 00:00:00 -bash
liu 136 120 0 21:09 tty1 00:00:00 ps -ef
liu@DESKTOP-MHNDSB8:~$ sudo kill -9 1
-ef View the pid system time, directory,
process number of the executor kill, and sometimes sudo is needed.

ip管理命令:ifconfig
liu@DESKTOP-MHNDSB8:~$ ifconfig
eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.182.1  netmask 255.255.255.0  broadcast 192.168.182.255
        inet6 fe80::f855:f073:a57d:863f  prefixlen 64  scopeid 0xfd<compat,link,site,host>

Help commands: man,info,help

Shutdown and restart: shutdown, halt and reboot

查看内核和发行版版本号命令:uname 和 lsb_release
liu@DESKTOP-MHNDSB8:~$ sudo lsb_release -i
Distributor ID: Ubuntu
liu@DESKTOP-MHNDSB8:~$ sudo lsb_release
No LSB modules are available.
liu@DESKTOP-MHNDSB8:~$ sudo lsb_release -d
Description:    Ubuntu 18.04.2 LTS
liu@DESKTOP-MHNDSB8:~$ sudo lsb_release -r
Release:        18.04
liu@DESKTOP-MHNDSB8:~$ sudo lsb_release -v
No LSB modules are available.
liu@DESKTOP-MHNDSB8:~$ sudo lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic

Guess you like

Origin blog.csdn.net/qq_38531460/article/details/102809541