DIY Linux Summaries
- I) Command Lines
- 1.1) difference between "esc+shift+i" and "esc+shift+a"
- 1.2) how to use escape character to have computing on multiplication
- 1.3) file types in Linux
- 1.4) how to unset variables
- 1.5) create file by cat -- rename a file -- show file with less -- seach/find words by grep
- 1.7) how to use the device/parameter just runing in another tool
- 1.8) how to use ESC escape character (data processing)
- 1.9) command: find / -empty or history
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"