This record is from Tencent Cloud Experiment https://cloud.tencent.com/developer/labs/lab/10000
Connected to the experimental cloud host
Login: ssh [email protected] -p 22
Password: ncuswbwiXA0@
System: CentOS 7.2 64 bit
Connected to the experimental cloud host
Login: ssh [email protected] -p 22
Password: drjzyW0#^^#%
System: CentOS 7.2 64 bit
Connected to the experimental cloud host
Login: ssh [email protected] -p 22
Password: uwNTOGZHXX5#
System: CentOS 7.2 64 bit
Connected to the experimental cloud host
Login: ssh [email protected] -p 22
Password: rbszRPL58&^~
System: Ubuntu 16.04.1 LTS 64 bit
This record is from Tencent Cloud Experiment https://cloud.tencent.com/developer/labs/lab/10000
Directory operations
Task time: 5min ~ 10min
Create a directory
Use the mkdir command to create a directory
mkdir $HOME/testFolder
Switch directory
Use the cd command to switch directories
cd $HOME/testFolder
Use the cd ../ command to switch to the upper directory
cd ../
Move directory
Use the mv command to move directories
mv $HOME/testFolder /var/tmp
Delete directory
Use the rm -rf command to delete the directory
rm -rf /var/tmp/testFolder
View the files in the directory
Use the ls command to view all files and folders in the [ /etc ] directory
ls /etc
The /etc directory defaults to the storage location of the software configuration file of the *nix system
File operations
Task time: 5min ~ 10min
Create a file
Use the touch command to create a file
touch ~/testFile
Execute the ls
command, you can see the newly created testFile file
ls ~
Copy files
Use the cp command to copy files
cp ~/testFile ~/testNewFile
Delete Files
Use the rm command to delete the file, enter y
and press Enter to confirm the deletion
rm ~/testFile
View file content
Use the cat command to view the contents of the .bash_history file
cat ~/.bash_history
Filter, pipe and redirect
Task time: 5min ~ 10min
filter
Filter out root
the records contained in the /etc/passwd file
grep 'root' /etc/passwd
Recursively filter out linux
the records contained in the /var/log/ directory
grep -r 'linux' /var/log/
pipeline
To put it simply, the function of the pipeline in Linux is to use the output of the previous command as the input of the next command, and to execute each command in series like a pipe. The operator of the pipeline is |
For example, we can combine the two commands cat and grep with pipes
cat /etc/passwd | grep 'root'
Filter out the directories contained in the name in the /etc directory ssh
(excluding subdirectories)
ls /etc | grep 'ssh'
Redirect
You can use> or <to redirect the output of the command to a file
echo 'Hello World' > ~/test.txt
Common commands for operation and maintenance
Task time: 5min ~ 10min
ping command
Send 4 ping packets to cloud.tencent.com to check if it is connected
ping -c 4 cloud.tencent.com
netstat command
The netstat command is used to display various network-related information, such as network connections, routing tables, interface status, etc.
List all tcp ports in listening state
netstat -lt
View all port information, including PID and process name
netstat -tulpn
ps command
Filter to get the ssh process information in the current system
ps -aux | grep 'ssh'
completed experiment
Directory operations
-
Create a directory
Use the mkdir command to create a directory
mkdir $HOME/testFolder
- Switch directory
Use the cd command to switch directories
cd $HOME/testFolder
Use the cd ../ command to switch to the upper directory
cd ../
[root@VM-24-20-centos ~]# cat /etc/passwd | grep 'root'
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
[root@VM-24-20-centos ~]# ls /etc|grep 'ssh'
ssh
[root@VM-24-20-centos ~]# echo 'Hello World'> test.txt
[root@VM-24-20-centos ~]# ls
miniconda3 testNewFile
Miniconda3-py38_4.8.2-Linux-x86_64.sh test.txt
[root@VM-24-20-centos ~]# cat test.txt
Hello World
[root@VM-24-20-centos ~]# ping -c 4 cloud.tencent.com
PING cloud-gz.tencent-cloud.com (193.112.234.28) 56(84) bytes of data.
64 bytes from 193.112.234.28 (193.112.234.28): icmp_seq=1 ttl=57 time=0.957 ms
64 bytes from 193.112.234.28 (193.112.234.28): icmp_seq=2 ttl=57 time=0.969 ms
64 bytes from 193.112.234.28 (193.112.234.28): icmp_seq=3 ttl=57 time=0.978 ms
64 bytes from 193.112.234.28 (193.112.234.28): icmp_seq=4 ttl=57 time=0.927 ms
--- cloud-gz.tencent-cloud.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.927/0.957/0.978/0.042 ms
[root@VM-24-20-centos ~]# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
[root@VM-24-20-centos ~]# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 924/sshd
udp 0 0 10.104.24.20:123 0.0.0.0:* 1317/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 1317/ntpd
udp6 0 0 ::1:123 :::* 1317/ntpd
udp6 0 0 fe80::5054:ff:fe7b::123 :::* 1317/ntpd
[root@VM-24-20-centos ~]# ps aux | grep 'ssh'
root 924 0.0 0.4 112924 4324 ? Ss 14:12 0:00 /usr/sbin/sshd -D
root 2721 0.0 0.5 155112 5844 ? Ss 14:17 0:00 sshd: root@pts/0
root 3749 0.0 0.5 154736 5584 ? Ss 14:19 0:00 sshd: root@pts/1
root 3838 0.0 0.5 154740 5360 ? Ss 14:20 0:00 sshd: root@notty
root 3841 0.0 0.2 72252 2856 ? Ss 14:20 0:00 /usr/libexec/openssh/sftp-server
root 14004 0.0 0.5 154736 5580 ? Ss 14:38 0:00 sshd: root@pts/2
root 14020 0.0 0.5 154740 5360 ? Ss 14:38 0:00 sshd: root@notty
root 14055 0.0 0.2 72252 2868 ? Ss 14:38 0:00 /usr/libexec/openssh/sftp-server
root 20576 0.0 0.0 112812 972 pts/0 R+ 14:53 0:00 grep --color=auto ssh