Linux Commands
Public and private key
- Create a public and private key pair.
- Upload your public key on your remote Unix and Linux servers.
- Use ssh to login to your remote servers without using a password.
- Add your key at the end of
~/.ssh/authorized_keys
file
ssh-keygen -t rsa
scp ~/.ssh/id_rsa.pub username@192.168.1.100:~
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
|
location of bash script
Source: Hiks Gerganov
echo "${BASH_SOURCE}"
echo "$(dirname -- "$(readlink -f "${BASH_SOURCE}")")"
|
sort & uniq
sort -n test.txt | while read num ;do echo $num ; sum=`expr $sum + $num 2> /dev/null`;echo $sum > /tmp/sum.tmp ;done ; echo -n "sum is :" ;cat /tmp/sum.tmp
sort -n C.txt >T.txt
cat data1.txt | sort | uniq
|
head and tail
tail 实例3:从第5行开始显示文件 命令: tail -n +5 log2014.log
|
echo
echo AAA echo -e "\033[41;36m something here \033[0m" echo -e "\033[40;37m red \033[0m" echo -e "\033[41;37m blue \033[0m" echo -e "\033[42;37m green \033[0m" echo -e "\033[43;37m 黄底白字 \033[0m" echo -e "\033[44;37m 蓝底白字 \033[0m" echo -e "\033[45;37m 紫底白字 \033[0m" echo -e "\033[46;37m 天蓝底白字 \033[0m" echo -e "\033[47;30m 白底黑字 \033[0m"
|
find
find . -type f -empty -print -delete
|
mail
mail test@126.com Cc 编辑抄送对象,Subject:邮件主题,输入回车,邮件正文后,按Ctrl-D结束
echo "邮件正文" | mail -s 邮件主题 591465908@qq.com
mail -s test test@126.com < test.txt
uuencode 附件名称 附件显示名称 | mail -s 邮件主题 发送地址
|
Release Cached RAM
echo 1 > /proc/sys/vm/drop_caches
|
record screen as gif
byzanz-record -d 40 -x 0 -y 0 -w 400 -h 320 byzanz-demo.gif
其中:
-d 40 为录制的时长为 40 秒 -x 0 录制区域的横坐标 -y 0 录制区域的纵坐标,记住:屏幕右上角为原点(0,0) -w 400 录制区域的宽度 -h 320 录制区域的高度
byzanz-demo.gif 保存的文件名
xwd -silent -root | convert xwd:- -crop 800x600+0+76 test.png
|
for fun
case
case $Random in 1) /media/ken/Data/Python-Voice/speak.sh "WARNNING!" ;; 2) /media/ken/Data/Python-Voice/speak.sh "PLEASE_HELP_ME!" ;; 3) /media/ken/Data/Python-Voice/speak.sh "WARNNING!" /media/ken/Data/Python-Voice/speak.sh "I_DONT_WANT_TO_GO" esac
pstree -up
|
Time
time1=$(date) echo $time1
time2=$(date "+%Y%m%d%H%M%S") echo $time2
|
Font
reference: 某某某的账号
stat
海王 2011
File: public/
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 802h/2050d Inode: 348256 Links: 1
Access: (0777/drwxrwxrwx) Uid: ( 1000/ ken) Gid: ( 1000/ ken)
Access: 2020-07-29 23:57:44.005512600 +0800
Modify: 2020-07-29 23:57:43.560542100 +0800
Change: 2020-07-29 23:57:43.560542100 +0800
Birth: -
SCP
scp -P 8022 root@192.168.3.6:~/test.md .
scp -P 8022 test.md root@192.168.3.6:~/
|
Similar to SCP, this commands could help you to skip files already exist:
rsync -avz --ignore-existing test2/* username@IP:path
````
<a name="IPgOq"></a>
```bash lscpu
lspci | grep -i 'eth'
|
GPU inf
Disable Keys/Mouse
We could use the xinput list
to check all the input devices and disable it with xinput disable $id
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ LXDDZ JLab Epic Keys id=12 [slave pointer (2)]
⎜ ↳ LXDDZ JLab Epic Keys Consumer Control id=14 [slave pointer (2)]
⎜ ↳ RH USB Gaming Mouse id=18 [slave pointer (2)]
⎜ ↳ RH USB Gaming Mouse Consumer Control id=20 [slave pointer (2)]
⎜ ↳ TSTP MTouch id=9 [slave pointer (2)]
⎜ ↳ TSTP MTouch id=10 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
xinput disable 9 xinput disable 10
|
∼ TSTP MTouch id=9 [floating slave]
∼ TSTP MTouch id=10 [floating slave]
Mount remate file system
ssh-keygen -t rsa
sudo apt install sshfs sudo mkdir /mnt/cypress
sudo sshfs -o allow_other,IdentityFile=~/.ssh/id_rsa wliu15@cypress.tulane.edu:/lustre/project/wdeng7/wliu15/ /mnt/cypress/
|