ubuntu使用命令

2.7k words
  • 重启
1
sudo reboot
  • 关机
1
sudo poweroff
  • 返回
1
2
3
4
5
6
1.返回根目录
cd
2.返回上一级
cd ..
3.回到上一次的位置
cd -
  • 列出当前目录文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1.显示当前文件目录
ls

2.显示指定文件目录
ls path

3.显示所有文件
ls -a

4.显示文件属性
ls -l

5.显示所有文件属性
ls -al或者ls -la
  • 清楚终端
1
clear
  • 显示当前路径
1
pwd
  • 文件操作
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1.创建文件夹
mkdir document
2.创建多级文件夹
mkdir -p user/document
3.删除文件夹
rm -rf document
4.复制文件夹
cp document new_name

5.创建文件
touch 1.txt
6.删除文件
rm 1.txt

7.重命名或者移动
mv aim new
  • 环境变量
1
2
3
4
5
6
7
8
9
10
一,用户环境变量
/user/ubuntu/.profile中添加shell脚本

二,系统脚本
在/etc/profile.d/目录下创建一个自定义脚本

三,PATH环境变量
echo $PATH 查看PATH环境变量
在系统脚本下添加以下命令
export PATH=$PATH:脚本路径
  • 自动补全
1
2
tab
tab tab
  • vim
1
2
清空文件内容
:%d
  • 查看ip
1
hostname -I
  • 模式切换
1
2
3
4
5
1.开机默认进入命令行
sudo systemctl set-default multi-user.target
2.开机默认进入桌面
sudo systemctl set-default graphical.target

  • 解压缩
1
2
3
4
5
6
7
8
9
10
11
12
13
归档文件
tar -cvf name.tar file1 file2

还原文件
tar -xvf name.tar
tar -xvf name.tar -C path

压缩文件
tar -zcvf name.tar.gz file1 file2

解压文件
tar -zxvf name.tar
tar -zxvf name.tar -C path
  • 创建软链接
1
2
创建软链接
ln -s 操作对象 链接名字
  • 用户操作
1
2
3
4
5
6
7
8
创建用户
sudo useradd -m 用户名

删除用户
sudo userdel 用户名

修改用户密码
sudo password 用户
  • 修改文件权限
1
2
3
4
5
6
7
8
增加可执行权限
chmod +x file

增加可读权限
chmod +r file

增加可写权限
chmod +w file
  • 可执行脚本
1
2
3
4
5
6
7
8
9
shell脚本
.sh文件,第一行声明shell解释器 #!/bin/sh
添加可执行权限
输入文件路径执行

python脚本
.python文件,第一行声明python解释器 #!/bin/python3
添加可执行权限
输入文件路径执行
  • ROS程序编译基础
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
自定义空间名space
mkdir -p ws/src

进入space执行编译
catkin_make

在src目录下创建包,添加依赖
catkin_create_pkg car_project roscpp rospy std_msgs

1,C++部分:
在包的src目录下创建编写C++文件

修改CMakeLists.txt文件
修改行136、149
add_executable(name
src/name.cpp
)

target_link_libraries(name
${catkin_LIBRARIES}
)

编译
启动核心:roscore
修改环境变量:source ./devel/setup.bash
rosrun 包名 name

2.python部分:

在包下建立scripts文件存放python

为python添加可执行条件:chmod +x name.py
查看可执行权限:ll

修改CMakeLists.txt文件
修改行162:
catkin_install_python(PROGRAMS
scripts/自定义文件名.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

编译
启动核心:roscore
修改环境变量:source ./devel/setup.bash
rosrun 包名 name.py

  • wifi配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#network-config文件
version: 2
wifis:
renderer: networkd
wlan0:
dhcp4: true
optional: true
access-points:
"lsksp":
password: "12345678"
"lsk":
password: "12345678"


#sudo nano /etc/netplan/50-cloud-init.yaml
network:
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
optional: true
access-points:
"WiFi名":
password: "你wifi的密码"
dhcp4: true
version: 2


#自定义
network:
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
optional: true
access-points:
lsk:
password: "12345678"

lsksp:
password: "12345678"
addresses: [192.168.167.8/24]
gateway4: 192.168.167.1
nameservers:
addresses: [8.8.8.8, 144.144.144.144]
dhcp4: true
version: 2

  • 查看进程并结束
1
2
3
4
5
#查看
ps aux | grep -i apt

#杀掉进程
sudo kill <process_id>
  • apt软件管理工具
1
2
3
4
5
6
7
8
安装软件
apt install 软件名
卸载软件
apt remove 软件名
搜索
apt search xxx
列表
apt list | grep xxx