Continually updated....
Recently, I was watching SLAM Lecture 14 related content. By the way, I ran a virtual machine that I haven’t opened for half a year. In
this issue, I will write about how to get started with an old and unused virtual machine...
By the way, I will add some helpful bits and pieces of knowledge when using virtual machines personally. But not necessarily standardized.
just add attention limit to count the real reading data, if it is not suitable, just cancel it
Color code
blue
red
green
chatGPT helped me a lot, maybe I could have used this blog ;(
Local VSCode remote connection virtual machine
It should be noted that to open the ssh service on the Ubuntu side , the code used is
sudo service ssh start
Determine if ssh is connected by looking at the process
You can see this blogger's blog
vscode connect virtual machine (Ubuntu)
Process class✨
View process by keyword
ps -ef | grep 【关键字】 # 可以查看包含该关键字的进程
Some explanations :
ps -ef
Used to list all process information on the current system.|
is the pipeline operator that uses the outputps -ef
of as input togrep 【关键字】
.grep 【关键字】
It is used to filterps -ef
the output of and only keep the lines containing 【keyword】.- It can be added
|grep -v grep
togrep -v
indicate reverse matching, that is, to filter out the results that do not contain "grep" on the output results
Distinguish between process ID and parent process ID
The one on the left is the process ID , and the one on the right is the parent process ID
View processes by process ID
ps -p 【进程号】
kill process
Kill the process according to the process name: killall
killall 【进程名】
Note that using killall
the command kills all matching processes , including those that may belong to other users.
Kill the process according to the process number: kill
kill 【进程名】
Effect of the short option "-9"
When no -9
option is added, the process can choose to ignore it or perform some cleanup operations before exiting. In most cases, this approach is recommended, as the process has a chance to do some cleanup, release resources, etc.
When using -9
the option, the process will be terminated immediately .
ROS
Add the py file as executable
chmod +x filename # 将文件(如.py)设置成可执行文件
Create workspaces and feature packages
Create the specified folder and src subfolder
mkdir -p ~/my_workspace/src
[Under the workspace directory] Create a new workspace
cd ~/my_workspace # 进入工作空间目录
catkin_init_workspace
[In the src directory] Create a function package
cd src # 进入工作空间中的src子目录
catkin_create_pkg 【功能包名字】
Return to workspace forcatkin_make
Automatically start source
Put it in ~/.bashrc, and start automatic configuration
Conda
View environment list✨
conda env list
Create a new environment, activate and exit
conda create --name myenv python=3.8
# 创建一个名为"myenv"的环境,并使用Python3.8
activation
conda activate 【环境名称】 # 激活环境
# source activate 【环境名称】 # 在Linux中使用source激活
Keyword Search✨
According to [part] keywords in the document
grep -r 【关键字】 /path
or
grep -r 【关键字】 *.txt *.bak /path
Search by [file name]
find /path -name 【关键字】 -type d,f #type可去除
The type option selects the type of filename
d
: Folder
f
: File
Can be separated by commas
Search only in the current path
To search only in the current directory and not into subfolders, use -maxdepth
options to limit the depth of the search . Setting -maxdepth
it to 1 enables this functionality.
fuzzy search
Use wildcards to match part of a filename.
In Ubuntu, wildcards *
can match any character, and ?
can match a single character.
Keyword search in vim ✨
:
+ /
+ 【关键字】
pip-related
pip download [free source version]✨
pip --default-timeout=1000 install 库名称 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip download specified version
pip install 库名称==版本名称
If you don't know the version, don't type the version name first , pip will display the optional version
pip fuzzy search [deprecated]
pip search 【关键字】
It is no longer available
Please check it out at https://pypi.org/ .
Create a virtual environment ✨✨
Step 1: Download virtualenv
pip --default-timeout=1000 install virtualenv -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
Step 2: Create and enter the virtual environment
virtualenv -p python3.8 NAME # 创建虚拟环境
source NAME/bin/activate # 进入该虚拟环境
Others: Generate environment configuration files and download according to configuration files
Remember to use in virtual environment
generate file
pip freeze > requirements.txt # 列出环境中的所有包及其对应的版本。
import configuration
pip install -r requirements.txt # 读取.txt文件并安装
miscellaneous
View disk capacity
df -hl
-h
: Displays disk space usage in a human readable format. After using this option, the size of the disk space will be displayed in a more readable way, such as expressed in KB, MB, GB and other units.-l
: Displays only the disk space usage of the local file system. After using this option,df
the command will only display the disk space information of the local file system (that is, not including the network file system).
View remaining memory
free -m
When you enter free -m
the command, it lists the memory statistics in the system, including total memory, used memory, free memory and cache/buffer memory, etc.
The following are free -m
common options and usage of the command:
free -m
: Displays memory usage in MB.free -g
: Displays memory usage in GB.free -h
: Displays memory usage in a human-readable format, automatically selecting the appropriate unit (e.g. KB, MB, GB).free -s <秒数>
: Displays memory usage continuously and updates every specified number of seconds.
Display real-time updated files [such as tracking logs] ✨✨
output to file
To update the output content of a file in real time, you can use tail -f
the command combined with the redirection symbol >
to write the output content to another file. In this way, when the original file changes, the output file will also be updated in real time.
tail -f 【要监视的文件】 > 【输出文件】
Note that tail -f
the command will continue to run until you manually interrupt it (e.g. press Ctrl+C).
output on the command line ✨✨
If you want tail -f
the command to display the file's content updates directly on the screen in real time, rather than outputting it to a file, you can use the following command:
tail -f 【要监视的文件】
Replace 【要监视的文件】
with the path and name of the file you want to monitor in real time. After executing this command, the terminal will display the latest content of the file in real time and update it as the file is updated.
Note that tail -f
the command will continue to run until you manually interrupt it (eg press Ctrl + C
).