-
Linux操作记录
2013-11-24 14:36:26Linux操作记录 -
linux操作记录
2017-02-13 14:48:39linux操作记录用户操作
-
增加用户
root 下useradd mw
root 下 passwd mw -->> 加上密码
然后在home中加个和用户名一样的文件夹 -
sudo
增加sudo权限 sudo visudo /etc/sudoers
编辑/etc/sudoers文件。即输入命令"vim /etc/sudoers",找到这一行:“root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL”(这里的xxx是要改的用户名)
gk ALL=(ALL) ALL
使用mw 登陆后, sudo 可用 -
用户登陆
用户登陆时init(如alias,echo提示等):
vi ~/.bashrc
网络相关
网络相关命令,查端口,查进程
netstat -anp|grep mysqld
netstat -anp|grep 8080 查看端口netstat -anp|grep java
查看带有uip_的进程
ps -ef | grep uip_看网络连接
要出现性能问题的时候,可以看看!
netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’
TIME_WAIT状态 过多的时候,要考虑下对上述结果的解释:1
CLOSED:无连接是活动的或正在进行
LISTEN:服务器在等待进入呼叫
SYN_RECV:一个连接请求已经到达,等待确认
SYN_SENT:应用已经开始,打开一个连接
ESTABLISHED:正常数据传输状态
FIN_WAIT1:应用说它已经完成
FIN_WAIT2:另一边已同意释放
ITMED_WAIT:等待所有分组死掉
CLOSING:两边同时尝试关闭
TIME_WAIT:另一边已初始化一个释放
LAST_ACK:等待所有分组死掉网络总体情况*
iftop -i eth1系统操作
-
查看文件夹容量
du --max-depth=1 -h -
linux 查看发行版本
方法一: cat /etc/issue
方法二: lsb_release -a
方法三: cat /etc/redhat-release(针对redhat,Fedora) -
top查看 cpu,内存
P – 以 CPU 占用率大小的顺序排列进程列表
M – 以内存占用率大小的顺序排列进程列表
各进程(任务)的状态监控,项目列信息说明如下 2
PID — 进程id
USER — 进程所有者
PR — 进程优先级
NI — nice值。负值表示高优先级,正值表示低优先级
VIRT — 进程使用的虚拟内存总量,单位kb。VIRT=SWAP+RES
RES — 进程使用的、未被换出的物理内存大小,单位kb。RES=CODE+DATA
SHR — 共享内存大小,单位kb
S — 进程状态。D=不可中断的睡眠状态 R=运行 S=睡眠 T=跟踪/停止 Z=僵尸进程
%CPU — 上次更新到现在的CPU时间占用百分比
%MEM — 进程使用的物理内存百分比
TIME+ — 进程使用的CPU时间总计,单位1/100秒
COMMAND — 进程名称(命令名/命令行)-
pwdx 进程号
查看进程的工作路径 -
知道端口查进程号
netstat -tunlp |grep 32000
lsof -i:8081 -
知道进程查端口
netstat -tunlp |grep 4650
lsof -p 4650 | grep TCP -
copy文件到远程
scp: copy文件到远程 用法: copy本地/root/index.html到xxx.xxx.xxx.xxx 的/root目录下 scp /root/index.html root@xxx.xxx.xxx.xxx:/root
其它
alias gcm='git commit -m ’
alias gs=‘git status’
alias gpo='git pull origin ’
alias c=‘clear’python的安装
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
tar Jxvf Python-3.6.5.tar.xz
cd Python-3.6.5
./configure --prefix=/usr/local/python3.6
make && make install
ln -s /usr/local/python3.6/bin/python3.6 /usr/bin/python3一些shell脚本:
adobe=('20180101' '20180102' '20180103' '20180104' '20180105' '20180106' '20180107' '20180108' '20180109' '20180110' '20180111') for cdate in ${adobe[@]};do echo ${cdate} declare -A map=(["10.2.9.15"]="/opt" ["10.2.9.16"]="/opt" ["10.2.9.17"]="/opt" ["10.2.9.18"]="/opt" ["10.2.9.6"]="/disk" ["10.2.9.7"]="/disk" ) for ip in ${!map[@]} do echo --------------$ip-------------- ssh $ip cd ${map[$ip]}'/myproject/bak/testauth20171226 && tar -czvf c'${cdate}'.tar.gz result_testauth.log.*'${cdate}'* && rm result_testauth.log.*'${cdate}'* -f' done done cdate="20180105" declare -A map=(["10.2.9.15"]="/opt" ["10.2.9.16"]="/opt" ["10.2.9.17"]="/opt" ["10.2.9.18"]="/opt" ["10.2.9.6"]="/disk" ["10.2.9.7"]="/disk" ) for ip in ${!map[@]} do echo --------------$ip-------------- ssh $ip cd ${map[$ip]}'/myproject/bak/testauth20171226 && tar -czvf c'${cdate}'.tar.gz result_testauth.log.*'${cdate}'* && rm result_testauth.log.*'${cdate}'* -f' done
-
-
Linux 操作记录
2018-06-13 17:52:47创建文件夹 mkdir test删除文件夹 rmdir test打开文件夹 cd ./test新建文件 touch 文件名删除文件 rm 文件名删除不为空的文件名 rm - rf 文件名查看文件 cat wenjianming复制文件 : cp 源文件 目标文件夹/目标文件...创建文件夹 mkdir test
删除文件夹 rmdir test
打开文件夹 cd ./test
新建文件 touch 文件名
删除文件 rm 文件名
删除不为空的文件名 rm - rf 文件名
查看文件 cat wenjianming
复制文件 : cp 源文件 目标文件夹/目标文件
移动文件: mv 源文件夹/源文件 目标文件夹
返回上一层目录 : cd..
pwd
ls
ll
ls -a
帮助 men cat 帮助命令
men cp
-
elasticdump对windows与linux操作记录
2018-08-31 10:55:311 增加操作 在liunx或windows中增加索引页面操作: http://127.0.0.1:9200/_plugin/head/ 在liunx或windows中增加索引命令操作: 2 删除操作 删除索引test curl -XDELETE http://localhost:9201/test ...1 增加操作
在liunx或windows中增加索引页面操作:
http://127.0.0.1:9200/_plugin/head/
在liunx或windows中增加索引命令操作:2 删除操作
删除索引test
curl -XDELETE http://localhost:9201/test
删除所有的索引、
curl -XDELETE http://localhost:9200/_all
或 curl -XDELETE http://localhost:9200/*
进入复合查询选项:
删除索引下的所有数据操作(这个在linux或者windows中都可以,页面操作):
{“query”:{“match_all”:{}}}
一定要记得加_all和选择delete,然后提交请求就ok了。
3 数据导入导出操作
数据导入操作
如果是linux中,首先需要将json数据文件上传到指定目录:
首先进入解压后的elasticdump目录:
cd /app/elasticdump
然后执行导入mapping命令:
bin/elasticdump –input=/app/test/test_mapping.json –output=http://localhost:9200/test –type=mapping
注:http://localhost:9200/test 其中test是索引名,test后面还可以加type名称如下
http://localhost:9200/test/type/导入的数据默认就会以这个test为索引,type为类型进行建mapping
当然也可以直接导入数据,自动建立了mapping如下:
bin/elasticdump –input=/app/test/test_data.json –output=http://localhost:9200/test
如果不需要建立索引,那么把test去掉,会默认根据数据中索引生成,在linux中需要执行以下命令:
bin/elasticdump –input=/app/test/test_data.json –output=http://localhost:9200 –all=true
在windows中执行如下命令即可:
elasticdump –input=D:\test\test_data.json –output=http://localhost:9200
就可将数据格式全部导入es中数据导出操作:
导出跟导入把input和output调换一下即可:
elasticdump –input=http://localhost:9200 –output=D:\test\test_data.json总结:
elasticdump 这个工具吧无论在windows环境中,还是linux环境中使用,简单粗暴,缺点使用的功能性再多一些功能就更好了。
-
VM虚拟机20G磁盘扩展到40G的Linux操作记录
2019-12-12 09:46:08先到VM客户端界面中扩展到40G,然后启动系统,进入系统后操作,操作记录如下: Last login: Wed Dec 11 23:10:40 2019 from 192.168.1.47 [root@cib-server1 ~]# df -h Filesystem Size Used Avail Use% Mounted on ...系统CentOS7
原有磁盘20G
先到VM客户端界面中扩展到40G,然后启动系统,进入系统后操作,操作记录如下:Last login: Wed Dec 11 23:10:40 2019 from 192.168.1.47 [root@cib-server1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 17G 17G 282M 99% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 9.0M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 1014M 179M 836M 18% /boot tmpfs 379M 0 379M 0% /run/user/0 [root@cib-server1 ~]# fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000ef4fd Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM Disk /dev/mapper/rhel-root: 18.2 GB, 18249416704 bytes, 35643392 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/rhel-swap: 2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes [root@cib-server1 ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000ef4fd Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): Using default response p Partition number (3,4, default 3): First sector (41943040-83886079, default 41943040): Using default value 41943040 Last sector, +sectors or +size{K,M,G} (41943040-83886079, default 83886079): Using default value 83886079 Partition 3 of type Linux and of size 20 GiB is set Command (m for help): t Partition number (1-3, default 3): 3 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000ef4fd Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM /dev/sda3 41943040 83886079 20971520 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. [root@cib-server1 ~]# ll /dev/sda* brw-rw---- 1 root disk 8, 0 Dec 12 01:45 /dev/sda brw-rw---- 1 root disk 8, 1 Dec 12 01:45 /dev/sda1 brw-rw---- 1 root disk 8, 2 Dec 12 01:45 /dev/sda2 [root@cib-server1 ~]# partx -a /dev/sda partx: /dev/sda: error adding partitions 1-2 [root@cib-server1 ~]# ll /dev/sda* brw-rw---- 1 root disk 8, 0 Dec 12 01:45 /dev/sda brw-rw---- 1 root disk 8, 1 Dec 12 01:45 /dev/sda1 brw-rw---- 1 root disk 8, 2 Dec 12 01:45 /dev/sda2 brw-rw---- 1 root disk 8, 3 Dec 12 01:45 /dev/sda3 [root@cib-server1 ~]# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created. [root@cib-server1 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- <19.00g 0 /dev/sda3 lvm2 --- 20.00g 20.00g [root@cib-server1 ~]# vgs VG #PV #LV #SN Attr VSize VFree rhel 1 2 0 wz--n- <19.00g 0 [root@cib-server1 ~]# vgextend rhel /dev/sda3 Volume group "rhel" successfully extended [root@cib-server1 ~]# vgs VG #PV #LV #SN Attr VSize VFree rhel 2 2 0 wz--n- 38.99g <20.00g [root@cib-server1 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- <17.00g swap rhel -wi-ao---- 2.00g [root@cib-server1 ~]# lvextend -l +100%FREE /dev/sda /dev/sda2 /dev/sda3 [root@cib-server1 ~]# ll /dev/mapper/ total 0 crw------- 1 root root 10, 236 Dec 12 01:44 control lrwxrwxrwx 1 root root 7 Dec 12 01:44 rhel-root -> ../dm-0 lrwxrwxrwx 1 root root 7 Dec 12 01:44 rhel-swap -> ../dm-1 [root@cib-server1 ~]# lvextend -l +100%FREE /dev/mapper/rhel-root Size of logical volume rhel/root changed from <17.00 GiB (4351 extents) to 36.99 GiB (9470 extents). Logical volume rhel/root successfully resized. [root@cib-server1 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- 36.99g swap rhel -wi-ao---- 2.00g [root@cib-server1 ~]# xfs_growfs / meta-data=/dev/mapper/rhel-root isize=512 agcount=4, agsize=1113856 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=4455424, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 4455424 to 9697280 [root@cib-server1 ~]# df -h
(END)
-
kali linux操作记录(kali版本为2020.1)
2020-06-06 20:04:52linux换源 1.在终端输入 vim /etc/apt/sources.list 2.按i进入编辑模式,用#注释掉官方源,或者直接删去。 3.填入需要更改的源,一下选其一即可。 #阿里云 deb ... -
LINUX 操作记录到syslog,并发送到syslog服务器上
2018-08-14 20:10:00首先配置命令记录到syslog中: 在客户端的/etc/bashrc 下添加: logger -p local3.info \"`who am i` ======================================= is login \" export PROMPT_COMMAND='{ msg=$(history 1 | ... -
将linux操作记录到 /var/log/message 中
2016-08-03 09:06:22vim rsys.shcat>>/etc/profile<<EOF HISTFILESIZE=2000 HISTSIZE=2000 HISTTIMEFORMAT="%Y%m%d-%H%M%S:" exportHISTTIMEFORMAT exportPROMPT_COMMAND='{command=\$(history1|{rea... -
Linux操作系统中记录操作记录的地方
2020-04-20 18:10:09清除Linux操作系统里的操作记录:①history -c 命令②~/.bash_history文件 ③/var/log/secure安全日志文件④/var/log/lastlog二进制日志文件⑤/var/log/wtmp二进制日志文件。 -
linux用户操作记录工具
2014-10-17 15:51:34linux用户操作记录工具,用于跳板机,操作监控 -
Linux服务器记录并查询历史操作记录
2019-04-03 14:49:57一般我们可以用history命令来查看用户的操作记录,但是这个命令不能记录是哪个用户登录操作的,也不能记录详细的操作时间,且不完整;所以误操作而造成重要的数据丢失,就很难查到是谁操作的。 在这里我们通过脚本... -
linux mysql操作记录
2020-08-26 11:43:27linux mysql操作记录 进入mysql //若端口号为默认(3306) // u:用户,p:密码,密码需回车后输入 mysql -u root -p //若端口号不为默认值,为6033,加-P mysql -u root -p -P 6033 //若mysql在其他服务器,加-h ... -
linux远程记录终端操作记录
2013-10-16 08:59:03网上流传个这样一篇关于记录linux远程操作记录的文章:很可惜的是没有该出详细的解释, USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'` (who -u am i 会显示系统中登陆进来的用户及... -
linux操作指令记录
2018-01-01 18:31:30对于平时经常使用的linux 指令做个收集,方便自己忘记的时候过来查找。 文本操作 进入文本 vi a.txt (查看模式) 编辑文本 查看模式下按a之后方可编辑文档。 保存文档 q/q! (退出文本)w (保存文本)wq/wq!... -
Linux记录用户操作
2019-11-29 10:29:35Linux记录所有用户操作记录,包括操作日期、用户名、登录IP地址、具体操作等信息; 1、在/etc/profile下增加下面内容即可: #history 记录用户操作 USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed ... -
Linux 记录所有用户的操作记录
2017-11-08 13:18:00随着时代的发展,我们生活中了解计算机的越来越多,黑客...下面的内容设置可以实现在Linux下所有用户,不管是远程还是本地登陆,在本机的所有操作都会记录下来,并生成包含“用户/IP/时间/操作指令”的文件存放在指... -
LINUX 记录操作历史记录
2016-02-26 10:50:36得到的结果,永久保存,每个用户的命令记录分目录保存 # ls -l /var/log/.hist/root/ -rw------- 1 root root 546 2006-05-26 10:00 218.82.245.54.hist.20060526_092458 -rw------- 1 root root 243 ... -
linux 防火墙操作记录
2019-01-03 10:53:34--检查防火墙状态 firewall-cmd --state systemctl status firewalld --启动防火墙 systemctl start firewalld --停止防火墙 systemctl disable firewalld --禁用防火墙 systemctl stop firewalld ... -
linux登录mysql之后的操作记录_在Linux下记录所有用户的登录和操作日志
2021-02-10 13:45:17一般我们可以用history命令来查看用户的操作记录,但是这个命令不能记录是哪个用户登录操作的,也不能记录详细的操作时间,且不完整;所以误操作而造成重要的数据丢失,就很难查到是谁操作的。在这里我们通过脚本...