Linux Summary of My Own - Big

本文详细介绍了Linux命令行中的各种技巧,包括不同键组合的使用、计算中的转义字符、文件类型判断、变量清除、文件操作、脚本执行、设备参数利用以及grep和find命令的应用。
摘要由CSDN通过智能技术生成

I) Command Lines

1.1) difference between “esc+shift+i” and “esc+shift+a”

“esc+shift+i” : input at the beginning of the line
“esc+shift+a” : input at the end of the line

1.2) how to use escape character to have computing on multiplication

val=`expr $a \* $b`
echo "a * b : $val"

1.3) file types in Linux

-f file 检测文件是否是普通文件(既不是目录,也不是设备文件),如果是,则返回 true。

if [ -f $file ]
then
   echo "文件为普通文件"
else
   echo "文件为特殊文件"
fi

1.4) how to unset variables

  • shell file/multiple lines in one file genre
name="LinuxSimpliy"
echo "Name before deletion: $name"
unset name
echo "Name after deletion: $name"
  • single line command line style
[root@iZ2vc5lqzt23aweti4j777Z ~]# name="LinuxSimpliy"

[root@iZ2vc5lqzt23aweti4j777Z ~]# echo "Name before deletion: $name"

Name before deletion: LinuxSimpliy

[root@iZ2vc5lqzt23aweti4j777Z ~]# unset name

[root@iZ2vc5lqzt23aweti4j777Z ~]# echo "Name after deletion: $name"

Name after deletion:

1.5) create file by cat – rename a file – show file with less – seach/find words by grep

[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# cat > filename
;             
[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# ls
filename
[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# cat filename 
;
[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# vim filename 
[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# mv filename filename.txt
[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# ls -al
total 12
drwxr-xr-x   2 root root 4096 Apr 10 07:13 .
dr-xr-x---. 27 root root 4096 Apr 10 07:07 ..
-rw-r--r--   1 root root 1140 Apr 10 07:07 filename.txt
[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# less filename.txt 
[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# cat filename.txt 
1971
Performer       Petula Clark
Title   The song of my life
Lyrictext
Everyone has a song that belongs to their life
That will go on and on through the years of their life
There's a wonderful song, one that you brought to me
And I look on this song as my life symphony

This is the song of my life
It will go on through my life
Something you said tenderly
Started its music for me within

Whisperings from things that we share

Lyricsvault.eu
Lyricsvault.net
Lyricsvault.be
Lyricsvault.info
Lyricsvault.org


Only through you is it there
I walk along day and night
Singing the song of my life

I can picture the past that renewed yesterday
Every tear, every laugh, every step of the way
I recall what was wrong and the things that were right
And each moment belongs to the song of my life

This is the song of my life
It will go on through my life
Something you said tenderly
Started its music for me within

Whisperings from things that we share
Only through you is it there
I walk along day and night
Singing the song of my life

This is the song of my life
It will go on through my life
Darada...


Transcribed / Corrected by Mark Coutinho


[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# less filename.txt 
[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# grep life filename.txt 
Title   The song of my life
Everyone has a song that belongs to their life
That will go on and on through the years of their life
And I look on this song as my life symphony
This is the song of my life
It will go on through my life
Singing the song of my life
And each moment belongs to the song of my life
This is the song of my life
It will go on through my life
Singing the song of my life
This is the song of my life
It will go on through my life
[root@iZ2vc5lqzt23aweti4j777Z April10th2024]# 

1.6) bash fileName.sh : another way to run sh file without chmod

[root@iZ2vc5lqzt23aweti4j777Z April18th2024]# vim bash.sh 

[root@iZ2vc5lqzt23aweti4j777Z April18th2024]# bash bash.sh 

Hakers love to learn on Null Byte

[root@iZ2vc5lqzt23aweti4j777Z April18th2024]# ls -al

total 12

drwxr-xr-x   2 root root 4096 Apr 18 17:52 .

dr-xr-x---. 30 root root 4096 Apr 18 17:52 ..

-rw-r--r--   1 root root   75 Apr 18 17:52 bash.sh

1.7) how to use the device/parameter just runing in another tool

#! usr/bin/bash
echo $(ifconfig) $(whoami)
echo $(whoami)

1.8) how to use ESC escape character (data processing)

[root@iZ2vc5lqzt23aweti4j777Z ~]# echo "123\$"
123$

1.9) command: find / -empty or history

[root@iZ2vc5lqzt23aweti4j777Z ~]# find / -empty
/run/udev/tags/systemd/c242:1
/run/udev/tags/systemd/+module:configfs
[root@iZ2vc5lqzt23aweti4j777Z ~]# history
    1   MAKRER=SHOW_LOCALE;printf $MAKRER""; locale; MAKRER=SHOW_LOCALE;printf $MAKRER"";
    2   CHECK_TYPE=SHELL; echo "INFO=${CHECK_TYPE} PID=$$ PPID=$PPID TTY=$(tty) SHELL=$0 HOME=$HOME PWD=$PWD| CHECK_SHELL_END"
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值