常见操作

软连接

https://www.cnblogs.com/sueyyyy/p/10985443.html#

当我们需要在不同的目录,用到相同的文件时,我们不需要在每一个需要的目录下都放一个必须相同的文件,我们只要在其它的 目录下用ln命令链接(link)就可以,不必重复的占用磁盘空间。

ln -s source_path target_path

例子:ln -s /home/atguigu/bin/ ~/bin

互信

https://blog.csdn.net/chenghuikai/article/details/52807074

(1)hadoop102上生成公钥和私钥:

[atguigu@hadoop102 .ssh]$ ssh-keygen -t rsa

然后敲(三个回车),就会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)

(2)将hadoop102公钥拷贝到要免密登录的目标机器上

[atguigu@hadoop102 .ssh]$ ssh-copy-id hadoop102

[atguigu@hadoop102 .ssh]$ ssh-copy-id hadoop103

[atguigu@hadoop102 .ssh]$ ssh-copy-id hadoop104

chmod

修改权限

chmod u+x lg.sh

https://blog.csdn.net/u013197629/article/details/73608613

rsync

集群分发文件

1.编写脚本

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
#!/bin/bash
#1. 判断参数个数
if [ $# -lt 1 ]
then
echo Not Enough Arguement!
exit;
fi
#2. 遍历集群所有机器
for host in hadoop102 hadoop103 hadoop104
do
echo ==================== $host ====================
#3. 遍历所有目录,挨个发送
for file in $@
do
#4 判断文件是否存在
if [ -e $file ]
then
#5. 获取父目录
pdir=$(cd -P $(dirname $file); pwd)
#6. 获取当前文件的名称
fname=$(basename $file)
ssh $host "mkdir -p $pdir"
rsync -av $pdir/$fname $host:$pdir
else
echo $file does not exists!
fi
done
done

2.修改脚本xsync具有执行权限

1
chmod +x xsync

环境变量

https://blog.csdn.net/white_idiot/article/details/78253004

根目录下各个文件夹的作用

https://blog.51cto.com/u_14233078/2443062

如何让你的脚本可以在任意地方都可执行?

https://www.cnblogs.com/yychuyu/p/12918957.html

jps

https://blog.csdn.net/wangzhongshun/article/details/112546027

不过jps有个缺点是只能显示当前用户的进程id,要显示其他用户的还只能用linux的ps命令

scp

scp -r root@hosts : addr ./

tar

https://www.cnblogs.com/w54255787/p/10175202.html

压缩

tar -czvf XXX.tar.gz XXX

解压

tar -xzvf XXX.tar.gz

zip

压缩

zip -r -q XXX.zip XX XX

解压

unzip XXX.zip

用户和用户组

https://www.jianshu.com/p/1e3fcfc8e3ef

sudo chown XX:XX dir or file

cd

root用户也是用户,就是权限高于普通用户

cd -: 上一次的目录

cd ~ :回到当前用户目录

cd /:回到根目录

软件安装

1.离线安装

2.在线安装

1.yum

yum源配置

1.查看系统版本

cat /proc/version

2.找到对应配置

3.修改配置

vim /etc/yum.repos.d/XXX.repo

4.

yum clean

yum makecache

yum update

安装

yum install XX

2.apt-get

hexedit

16进制编辑

taskset

绑核

stat

查看修改文件状态

wget

wget http:XXX

grep

过滤文件内容

本机免密

vim /etc/sudoers

添加 用户名 ALL=(ALL) NOPASSWD:ALL

history

查看历史

find

查找文件

find path -name filename

sed

输出文件某行

sed -n “1,1p” filename

切换用户

普通用户切换root sudo -i

root切换某个用户 su username

清理内存缓存

root用户

echo 3 > /proc/sys/vm/drop_caches

diff

diff file1 file2

http代理

unset http_proxy

unset https_proxy

搜索输入过的命令

ctrl+r

查看进程

ps -ef | grep processname

查看磁盘

df -h

df -h dir

关闭终端继续执行命令

nohup cmd > XX.log &

md5

md5sum file

echo -n “string” | md5sum

sha256

sha256sum file

统计数量

cmd | wc -l

联想敲过的命令

PU键

批量杀死进程

ps -ef | grep “process name” |grep -v grep | cut -c 9-16 | xargs (sudo) kill -9

cat

cat file.txt

head tail

head/tail -f filename

head/tail -100 filename

> , >>

重定向到一个文件

> 覆盖

>> 追加

查看内存,cpu 占用前几的进程

ps aux | sort -nrk 3,3 | head -n 5

ps aux | sort -k4nr | head -n 5

查看文件大小

ls -al

du -sh file

curl

请求服务器

设置简写命令

比如 cd /XXX/XXX/XXX 用一个 hlw 代替

awk

查看进程的工作目录

pwdx pid

查看端口使用情况

netstat -nlp | grep port

bashrc

用户登录时自动执行的shell脚本

source

使刚修改的脚本立即生效,不用重新打开终端

export

设置环境变量

磁盘挂载,卸载

df -h 会显示 文件系统 挂载点

1 卸载

umount 挂载点

2 挂载

mount 文件系统 挂载点

设置开机自动挂载

Author

Lavine Hu

Posted on

2022-02-07

Updated on

2024-05-03

Licensed under

# Related Post
  1.vim
Comments

:D 一言句子获取中...