0%

常用的Linux命令

常用的Linux命令,备查,欢迎在评论区与我分享!
# 上传文件
rz -bey
# 清理磁盘
du -h --max-depth=1
# 磁盘是否满了
df -hl
# 去掉环境变量
unset 
env 查看
# grep 含引号
grep 'retCode":"10002"' rlog.log
# 查看谁登录了
w
#查看指定行
cat crm/protected/modules/Tumall/controllers/SellerController.php | tail -n +494 | head -n 10
#测试网络
echo "" | telnet 192.168.3.97 11218
# 搜索排除注释
grep -E "^$|^#" -v grep.txt
#查看文件某些行
sed -n '349,360p' basic/components/webservice.php
sed -n 'a,bp' basic/components/webservice.php, 查看 a-b行,如果b 覆盖, >> 追加
#grep显示附件的内容,-A,-B,-C
cat include/connectDB.inc.php |grep -C 5 fileServer
grep -A 5 zoneTypes src/To8to/CommonBundle/config/CategoryConfig.inc.php
#查找目录下哪些文件包含某个字符串
 grep -r m.to8to.com conf/conf.d/
#curl命令POST请求
curl --data "param1=value1¶m2=value2" https://example.com/resource.cgi
#查看Linux系统发行版本
cat /etc/issue
#查看Debian版本
more /etc/debian_version
#查找文件
find / -name curl_for_test.txt
find /usr/ -name php7
#修改~vimrc后怎样立刻生效
:source ~/.vimrc (你得确定你的vimrc的路径)
#cpu
root@nginx-php-fastcgi ~# cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores	: 1
root@nginx-php-fastcgi ~# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
1
root@nginx-php-fastcgi ~# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
      1  Intel(R) Core(TM) i3-4170 CPU @ 3.70GHz
root@nginx-php-fastcgi ~# cat /proc/cpuinfo| grep "processor"| wc -l
1
root@nginx-php-fastcgi ~# 
#查找
grep access /etc/nginx/conf.d/shejiben.conf
#awk
#备份文件并验证
root@nginx-php-fastcgi ~/backup# cp my.conf my.conf`date +%F` 
root@nginx-php-fastcgi ~/backup# md5sum my.conf my.conf2018-05-28 
8cd2616e051a7b8aea043c437e9c2b49  my.conf
8cd2616e051a7b8aea043c437e9c2b49  my.conf2018-05-28
#建目录
root@nginx-php-fastcgi /tmp# mkdir -p /tmp/mini_program/{aa,bb}
#查看文件大小等信息
stat img/xcx/interface_img.jpg 
#查看用户
cat /etc/passwd | grep www-data
#远程文件传输
scp root@192.168.1.233:/root/mobileapi2.lua ./
#文件夹
scp -r root@192.168.1.233:/root/mobileapi2.lua ./
指定端口
scp -P 10086 root@192.168.1.154:/usr/local/java/abc.zip ./
#登录
ssh root@192.168.0.11
#合并两个文件夹的文件
rsync -av /source/ /destination/
#合并后删除源文件夹
rm -rf /source/
#开启自启动
vi /etc/rc.d/rc.local
加入自启动的服务,如: service nginx start
另一个命令:chkconfig 
#包相关的目录文件
dpkg -L
#查看开机启动程序
vim /etc/rc.local
#切换到root
sudo -i
#创建/usr/local/php/bin/php的软链接为php53
ln -s /usr/local/php/bin/php /usr/bin/php53
#cut截取
 git branch -a | grep "remotes/origin" | cut -nb 18-50 
#查看Java进程所在目录
[root@java154 ~]# pidof java | xargs pwdx
#crontab
直接改文件可以 vim /etc/crontab 
但crontab -e 就不生效

[root@localhost ~]# cat ~/.bash_history

[root@localhost ~]# ls -ld /var/www/html/

[root@localhost ~]# head -10 phpinfo.txt

[root@localhost ~]# cat test.txt | tr [a-z] [A-Z]

[root@localhost ~]# wc -l /etc/passwd

[root@localhost ~]# cut -d: -f1 /etc/passwd

[root@localhost ~]# diff --brief log.txt index.html

[root@localhost ~]# ls -l test.txt 
-rw-r--r--. 1 root root 10 Feb  1 03:57 test.txt
[root@localhost ~]# echo "I'm hacker" >> test.txt 
[root@localhost ~]# ls -l test.txt 
-rw-r--r--. 1 root root 21 Feb  1 04:07 test.txt
[root@localhost ~]# touch -d "2019-02-01 03:57" test.txt 
[root@localhost ~]# ls -l test.txt 
-rw-r--r--. 1 root root 21 Feb  1 03:57 test.txt

[root@localhost ~]# dd if=/dev/zero of=10M_file count=1 bs=10M

[root@localhost ~]# file /dev/zero

[root@localhost ~]# grep -v /sbin/nologin /etc/passwd #反选

#将标准输出和错误输出共同写入到文件中
0  17  *  *  * root php /var/www/html/advanced/yii task/log >/dev/null 2>&1


[root@localhost ~]# ls -l /etc/ | more
#查询绝对路径
[root@xhs ~]# whereis php
#查进程的线程数
ps -Lf 21371 | wc -l
#查不包含某字符串的文件
ls | grep Deal -v | wc -l
#历史命令不显示行号
history | cut -c 8-
history | tail | cut -c 8-
#创建公钥
ssh-keygen
#查某个java服务
ps -ef | grep `jps | grep gdm | awk '{print $1}'`