linux 命令

linux命令大全,html版本
http://billie66.github.io/TLCL/book/index.html

从 shell 眼中看世界, 花括号展开

 echo {1..5}
 echo $(cal)
 echo "$(cal)"

ssh 登陆

ssh sam@55.67.217.193

本地与远端互通文件

  1. scp
scp abc.txt jim@55.67.217.193:downloads/abc11-04.txt
  1. sftp
sftp jim@55.67.217.193
#将远程当前目录下的文件test.cpp下载到本地当前目录的Project文件夹中
get test.cpp ./Project/
#本地iso文件传送到远程登陆主机
put abc.iso /home/ppl/
  1. rsync
#把当前目录的backup文件夹同步到远端jerome用户的home目录,
#如果home目录下没有backup文件夹,则会先创建backup文件夹
#--delete 删除所有DST中有,而SRC中没有的文件
#then delete these files
rsync -av --delete --rsh=ssh ./backup jim@55.77.227.193:~/

#inverse synchronize
rsync -av --delete --rsh=ssh jim@55.77.227.193:~/backup ./

#特别值得注意的地方, 下面两个命令是有区别的,第一个会在本地创建一个html文件夹,第二个不会
rsync -av --delete --rsh=ssh jim@55.77.227.193:~/../var/html ./
rsync -av --delete --rsh=ssh jim@55.77.227.193:~/../var/html/ ./

rsync 排除指定目录或文件进行同步
rsync -av --exclude "node_modules" --rsh=ssh ./ root@xxx.xxx.xxx.xxx:~/../var/www/html/learn/eng_corner/
rsync -av --exclude "node_modules" --rsh=ssh root@xxx.xxx.xxx.xxx:~/../var/www/html/learn/eng_corner/ ./
rsync -arv --exclude={node_modules,public/corner} /home/ben /media/ben/thumbdrive/
rsync 排除多个指定目录或文件进行同步

https://askubuntu.com/questions/320458/how-to-exclude-multiple-directories-with-rsync

useradd -m -U -s /bin/bash jim

#更改用户root的登陆目录
usermod -d /home/hnlinux root

#将用户sam的登录Shell修改为ksh,用户组改为developer。
usermod -s /bin/bash –g developer sam

passwd -d jim
passwd jim

apache

/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start
/usr/local/apache2/bin/apachectl restart

systemctl status apache2
systemctl stop apache2
systemctl start apache2
#显示用户列表
cat /etc/passwd|grep -v nologin|grep -v halt|grep -v shutdown|awk -F":" '{ print $1"|"$3"|"$4 }'|more

sed

#把distros.txt中的MM/DD/YYYY => YYYY-MM-DD
sed 's/\([0-9]\{2\}\)\/\([0-9]\{2\}\)\/\([0-9]\{4\}\)$/\3-\1-\2/' distros.txt

#inverse above
sed 's/\([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\)$/\2\/\3\/\1/' distros.txt

echo "aaabbbccc" | sed 's/b/B/g'

cat > foo.txt
The quick brown fox jumped over the lazy dog.
回车,Ctrl + d

sed -i 's/lazy/laxy/; s/jumped/jimped/' foo.txt

tail命令

#截取从第二行开始到末尾行的文本
tail -n +2
#截取倒数两行的文本
tail -n 2

tar 命令

#将当前目录的所有文本txt文件,归档为test.tar, 只归档不压缩
tar -cvf test.tar *.txt
#将父目录的test.tar 解开,放置到当前目录
tar -xvf ../test.tar
#查看test.tar中的内容
tar -tvf test.tar

http://blog.chinaunix.net/uid-8038341-id-179295.html

硬件,操作系统信息相关命令

lsb_release -a
lscpu
df -lh 查看硬盘使用情况
du -h test_folder
du -sh caches/
du -h  --max-depth=1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值