日常随笔小记

更改Linux终端中用户名颜色

用户名的设置在~下.bashrc文件中,更改PS1变量的值,如果没有就自己加一行

PS1='\[\e[32m\][\u@\h \W]#\[\e[m\] '
PS1="\[\e[1;32m\][\t \[\e[1;33m\]\u\[\e[35m\]@\h\[\e[1;31m\] \W\[\e[1;32m\]]\[\e[0m\]\\$ "

32代表的是绿色前景色,\[\e[m\]是关闭颜色设置,如果没有这一句,后面所有的字符都会是前面设置的颜色。

颜色设置在bash脚本中是通用的,也就是说你可以在终端里直接输入

前景代码背景代码颜色
3040黑色
3141红色
3242绿色
3343黄色
3444蓝色
3545紫红
3646青蓝
3747白色
11透明

Linux比较数字大小

你可以使用比较运算符来比较数字。以下是一些常见的比较运算符:

字符含义
-eq等于
-ne不等于
-lt小于
-le小于等于
-gt大于
-ge大于等于

输出时间只包括年月日时分秒

date +%Y-%m-%d\ %H:%M:%S

Linux中求百分率

numerator=75
denominator=100

# 使用 bc 进行除法计算和百分率转换
percentage=$(echo "scale=2; $numerator / $denominator * 100" | bc)

# 使用 printf 格式化输出百分率
printf "Percentage: %.2f%%\n" $percentage

命令详解:
在这里插入图片描述

神奇的光盘挂载目录

rpm -q autofs || yum -y install autofs
systemctl enable --now autofs

查看生成文件

ls /misc/cd

centos8停止维护修改 yum 源

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

mysql操作

修改用户密码

alter user root@'localhost' identified by 'password';

持久修改mysql提示符

[root@sre-5 ~]# cat /etc/my.cnf.d/mysql-clients.cnf 
[mysql]
prompt="\\r:\\m:\\s(\\u@\\h) [\\d]>\\_"

效果如下图所示
在这里插入图片描述

update语句修改数据
注意:一定要有显示条件,否则将修改所有行为指定字段
可利用mysql选项避免这个错误:

mysql -U | --safe-updates| --i-am-a-dummy

[root@sre-5 ~]# vim /etc/my.cnf
[mysql]
safe-updates

源码安装jdk1.8 配置相关文件

首先下载有关的安装包:jdk-8-oracle

解压安装包至usr/local/jdk

tar -xvf jdk-8u381-linux-x64.tar.gz -C /usr/local/jdk

编辑 /etc/profile 文件

export JAVA_HOME=/usr/local/jdk/jdk1.8.0_381
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

使用 source 命令让配置生效

source /etc/profile

验证:

root@ubuntu:~# java -version
java version "1.8.0_381"
Java(TM) SE Runtime Environment (build 1.8.0_381-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode)
root@ubuntu:~# javac 
Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -parameters                Generate metadata for reflection on method parameters
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -h <directory>             Specify where to place generated native header files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -profile <profile>         Check that API used is available in the specified profile
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
  -Werror                    Terminate compilation if warnings occur
  @<filename>                Read options and filenames from file

Linux命令随机生成16位数字字母大小写组合

cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1

Ubuntu在更新软件源包报错未签名

The repository ‘http://pkg.jenkins.io/debian-stable binary/ Release’ is not signed.

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5BA31D57EF5975CA
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Mathcad 是一种功能强大的数学软件,它可以让我们非常方便地进行数学计算和分析。学习使用Mathcad 对我来说是一种挑战,但同时也是一次非常有意义的经历。 首先,通过学习Mathcad,我深刻认识到数学公式和计算的重要性。在过去,我常常依赖计算器和纸笔进行数学计算,但这种方式往往效率不高,并且难以避免出错。而Mathcad 提供了一个直观且可视化的界面,让我们可以更加直观地理解和应用数学原理。 其次,学习Mathcad 也提高了我的数学建模和问题解决能力。在学习过程中,我发现Mathcad 的强大之处在于它能够将数学公式和实际问题相结合。通过输入不同的数学公式和数据,我可以揭示和解决一些实际世界中的问题,例如电路分析、力学运动、概率统计等,这为我提供了宝贵的数学建模实践经验。 此外,通过学习Mathcad,我也掌握了一种全新的数学表达方式。通过使用Mathcad的函数和符号库,我可以更加准确地表达数学概念和计算过程。这种表达方式简洁明了,易于理解和阅读,有助于提高我的数学思维能力和表达能力。 尽管学习Mathcad可能会遇到一些挑战,例如复杂的函数和符号操作,对于初学者来说不太友好,但通过不断实践和学习,我相信我可以克服这些问题,并不断进步。 总的来说,学习Mathcad 是一次充满挑战和收获的过程。它帮助我提高了数学知识和技能,提升了我的数学建模和问题解决能力。我相信在未来的学习和工作中,Mathcad 将成为我强大的数学工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值