目录
12.Ubuntu18.04 开机自动开启小键盘(数字键盘)
1.解除安装占用
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
2.树形图查看目录结构
sudo apt-get install tree
tree / -L 1
3.区域截图
Shift+PrtSc
4.ubuntu 系统设置应用到桌面快捷方式的使用方法
sudo apt install gnome-panel
gnome-desktop-item-edit ~/Desktop/ --create-new
然后设置命令和图标
5.设置快捷命令
Ubuntu Linux系统包含两类环境变量:
系统环境变量和用户环境变量。系统环境变量对所有系统用户都有效
系统环境变量相关文件:
/etc/environment
/etc/profile
/etc/bash.bashrc
用户环境变量仅仅对当前的用户有效
用户环境变量相关文件:
~/.profile
~/.bash_profile 或者 ~./bash_login
~/.bashrc
对环境变量的介绍就到这里。
————————————————
# 编辑环境变量文件
vi ~/.bashrc
# 为需要打开的路径设置一个别名(快捷命令)
alias cd_d='cd /home/username/a/b/c/d'
alias clc='clear'
这样就为打开d所在目录建立了一个快捷命令,但是只会在下次启动生效。如果想要立即生效,需要source ~/.bashrc
alias css='nautilus /mnt/hgfs/Share/'
example for .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# add /opt/ros setup.bash by yww at 20190718
source /opt/ros/kinetic/setup.bash
source ~/catkin_ws/devel/setup.bash
# add ros command definitions
alias eb='nano ~/.bashrc'
alias sb='source ~/.bashrc'
alias gs='git status'
alias gp='git pull'
alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
alias cm='cd ~/catkin_ws && catkin_make'
# add user commad
alias cds='cd /mnt/hgfs/Share'
alias clc='clear'
alias css='nautilus /mnt/hgfs/Share/'
# set ros network
export ROS_HOSTNAME=localhost
export ROS_MASTER_URI=http://${ROS_HOSTNAME}:11311
# set ros edit tool
export EDITOR='gedit'
#export ROS_HOSTNAME=ubuntu
#export ROS_MASTER_HOSTNAME="192.168.8.1"
#export ROS_MASTER_URI=http://${ROS_MASTER_HOSTNAME}:11311
6.设置Ubuntu18.04 4K缩放比例
查看当前显示缩放比例,0或1表示一倍縮放比
vic@ubuntu:~$ gsettings get org.gnome.desktop.interface scaling-factor
uint32 0
設置縮放比例
vic@ubuntu:~$ gsettings set org.gnome.desktop.interface scaling-factor 2
一般設置爲2倍縮放比就比較合適
7.matlabR2019b安装
挂载/启动安装
sudo mount -o loop R2019b_Linux.iso /mnt/matlab
cd /mnt/matlab/
sudo ./install
安装过程跟windows上一样
运行激活,激活选择跟windows上安装一样
cd /usr/local/Polyspace/R2019b/bin/
sudo ./matlab
创建图标
sudo gedit /usr/share/applications/MatlabR2019b.desktop
编辑图标文件
[Desktop Entry]
Categories=Application;Development;
Comment=Matlab:科学计算的语言
Encoding=UTF-8
Exec=/usr/local/Polyspace/R2019b/bin/matlab -desktop -prefersoftwareopengl
Icon=/usr/local/Polyspace/R2019b/toolbox/shared/dastudio/resources/MatlabIcon.png
Name=MATLAB
StartupNotify=true
Terminal=false #在启动matlab时不启动终端
Type=Application
给缓存目录相关权限
sudo chmod a+w -R ~/.matlab
或者
sudo chmod 777 /home/vic/.matlab
参考:Ubuntu 18.04安装Matlab 2016b教程(附创建图标快捷方式)_step step的博客-优快云博客
8.Ubuntu18.04 解压文件乱码的解决方法
sudo apt install unar
格式
unar xxx.zip #不需要加参数,自动识别编码
常见使用方法
参数[-o]
解释:指定解压结果保存的位置
~$ unar test.zip -o /home/dir/
参数[-e]
解释:指定编码
~$ unar -e GBK test.zip
参数[-p]
解释:指定解压密码
~$ unar -p 123456 test.zip
列出压缩包内容
~$ lsar xxx.zip
参考:Ubuntu18.04 解压zip文件乱码的解决方法_Pipcie的博客-优快云博客
9.Ubuntu 18.04 swap分区扩展
查看当前内存和交换分区大小
free -h
或者查看交换分区大小
sudo swapon --show
重新分配交换分区大小
sudo fallocate -l 16G /swapfile
可能报错如下
fallocate: fallocate failed: Text file busy
解决方法,执行以下命令,再分配大小
sudo swapoff -a
执行以下命令为 swapfile 文件设置正确的权限
sudo chmod 600 /swapfile
使用 mkswap 实用程序在文件上设置 Linux SWAP 区域
sudo mkswap /swapfile
使用以下命令激活 swap 文件
sudo swapon /swapfile
要让创建好的 swap 分区永久生效,可以将 swapfile 路径内容写入到 /etc/fstab 文件当中
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
查看实际分配结果
free -h
参考:Ubuntu 18.04 swap分区扩展_AlexWang30的博客-优快云博客
10.Ubuntu网速调整与测试
sudo lshw -numeric -class network
sudo ip addr show
sudo ip route show
sudo tracepath forum.ubuntu.org.cn
sudo apt-get install traceroute
sudo traceroute forum.ubuntu.org.cn
sudo apt install speedtest-cli
speedtest-cli
11.当前目录搜索文件夹并删除
find . -name ".git" |xargs rm -rfv
12.Ubuntu18.04 开机自动开启小键盘(数字键盘)
sudo apt-get install numlockx -y
sudo gedit /usr/share/lightdm/lightdm.conf.d/50-greeter-wrapper.conf
在50-greeter-wrapper.conf末尾添加
greeter-setup-script=/usr/bin/numlockx on
13.保存终端信息到文件
开始
script log.txt
退出
exit
14.eigen库头文件找不到问题
sudo apt-get install libeigen3-dev
安装后执行以下命令
运行命令:
sudo cp -r /usr/include/eigen3/Eigen /usr/include
15.Linux maple2019激活
sudo apt install lsb-core
sudo ./crack.pl /home/vic/maple2019
16.Ubuntu 安装不同版本壁纸
例如:
sudo apt-get install ubuntu-wallpapers-xenial
17.解决安装oh-my-zsh后,cd到特定文件夹变卡顿的问题
#cd 到相应目录
git config --add oh-my-zsh.hide-dirty 1
#恢复
git config --add oh-my-zsh.hide-dirty 0