advertisement
2021年6月29日
2021年4月20日
linux下 串列埠 工具 串口 序列埠 軟體 linux putty alternative for serial
請參考此篇文章 Use Serial Port To Remote Control
使用cu command
cu -l /dev/device -s baud-rate-speed
# cu -l /dev/ttyS0 -s 57600
若出現
cu: open (/dev/ttyS0): Permission denied
cu: /dev/ttyS0: Line in use
請打下列指令確認權限
# ls -la /dev/ttyUSB0
# chmod 666 /dev/ttyUSB0
ref:https://superuser.com/questions/794309/linux-tells-me-a-serial-port-is-in-use-but-it-isnt/1155172
https://www.cyberciti.biz/hardware/5-linux-unix-commands-for-connecting-to-the-serial-console/
2021年4月6日
Debian Buster 10 root $PATH in bash does not include /sbin and /usr/sbin
Debian 10 切換root超級使用者權限,超級使用者/管理者指令找不到,下echo $PATH發現環境變數與一般使用者一樣。
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
$ su
密碼:
# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
根據Debian官方說明 Debian 10 su 指令是使用了util-linux套件,其PATH使用預設值且不會警告,若要切換至超級使用者與環境變數,須下達 su - 或 su -l 或 su --login ,三者亦同。
$ su -
密碼:
root@debian10:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Reference:
https://wiki.debian.org/NewInBuster
https://unix.stackexchange.com/questions/460478/debian-su-and-su-path-differences
#ifconfig, #debian 10, #debian buster, #chpasswd, #fdisk, ,#useradd, #lsmod, #command not found, #指令找不到, #命令找不到
2020年10月8日
2019年8月28日
2019年8月9日
Linux 學習
Bash will expand a lone ~ to point to your home directory, but you can also use it to point to
other users' home directories. For example, if we wanted to refer to a file called fredsfile.txt in
Fred's home directory, we could type:
$ ./myprog ~fred/fredsfile.txt
my home directories
example: $ ./myprog ~/myfile.txt
Looking at directories
Sometimes, you'll want to look at a directory, rather than inside it. For these situations, you
can specify the -d option, which will tell ls to look at any directories that it would normally
look inside:
$ ls -dl /usr /usr/bin /usr/X11R6/bin ../share
drwxr-xr-x 4 root root 96 Dec 18 18:17 ../share
drwxr-xr-x 17 root root 576 Dec 24 09:03 /usr
drwxr-xr-x 2 root root 3192 Dec 26 12:52 /usr/X11R6/bin
drwxr-xr-x 2 root root 14576 Dec 27 08:56 /usr/bin
$ ls -dl /usr/local
drwxr-xr-x 8 root root 240 Dec 22 20:57 /usr/local
If we take a look at the second column from the left, we see that the directory /usr/local
(inode 5120) is referenced eight times. On my system, here are the various paths that
reference this inode:
/usr/local
/usr/local/.
/usr/local/bin/..
/usr/local/games/..
/usr/local/lib/..
/usr/local/sbin/..
/usr/local/share/..
/usr/local/src/..
mkdir -p
However, mkdir has a handy -p option that tells mkdir to create any missing parent
directories, as you can see here:
$ mkdir -p easy/as/pie
After typing this command, myfile.txt will be moved to /home/drobbins/myfile.txt. And if
/home/drobbins is on a different filesystem than /var/tmp, the mv command will handle the
copying of myfile.txt to the new filesystem and erasing it from the old filesystem. As you might guess, when myfile.txt is moved between filesystems, the myfile.txt at the new location
will have a new inode number. This is because every filesystem has its own independent set
of inode numbers.
A given inode can have any number of hard links, and
the inode will persist on the filesystem until the all the hard links disappear. When the last
hard link disappears and no program is holding the file open, Linux will delete the file
automatically.
you can only make hard links to files,not directories.
The second limitation
of hard links is that they can't span filesystems. This means that you can't create a link from
/usr/bin/bash to /bin/bash if your / and /usr directories exist on separate filesystems.
Note that double quotes will work similarly to single quotes, but will still allow bash to do
some limited expansion. Therefore, single quotes are your best bet when you are truly
interested in passing literal text to a command.
wildcards=globbing
https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.htmlhttps://www.linuxjournal.com/content/bash-extended-globbing.
http://www.globtester.com/ globbing debuger
If the first character following the ‘[’ is a ‘!’ or a ‘^’ then any character not enclosed is matched.
wayne.su@rd1-4:~/configdec$ ls
myfile1 myfile2 myfile3 myfile4
wayne.su@rd1-4:~/configdec$ ls myfile[!2]
myfile1 myfile3 myfile4
wayne.su@rd1-4:~/configdec$ ls myfile[^2]
myfile1 myfile3 myfile4
regular expression
| grep regex operator | Meaning | Example |
| . | Matches any single character. | grep '.' file grep 'foo.' input |
| ? | The preceding item(k) is optional and will be matched zero or at most, once. | grep 'vivek?' /etc/passwd |
| * | The preceding item(k) will be matched zero or more times. | grep 'vivek*' /etc/passwd |
| + | The preceding item will be matched one or more times. | ls /var/log/ | grep -E "^[a-z]+\.log." |
| {N} | The preceding item is matched exactly N times. | egrep '[0-9]{2} input |
| {N,} | The preceding item is matched N or more times. | egrep '[0-9]{2,} input |
| {N,M} | The preceding item is matched at least N times, but not more than M times. | egrep '[0-9]{2,4} input |
| – | Represents the range if it’s not first or last in a list or the ending point of a range in a list. | grep ':/bin/[a-z]*' /etc/passwd |
| ^ | Matches the empty string at the beginning of a line; also represents the characters not in the range of a list. | grep '^vivek' /etc/passwd grep '[^0-9]*' /etc/passwd |
| $ | Matches the empty string at the end of a line. | grep '^$' /etc/passwd |
| \b | Matches the empty string at the edge of a word. | vivek '\bvivek' /etc/passwd |
| \B | Matches the empty string provided it’s not at the edge of a word. | grep '\B/bin/bash /etc/passwd |
| \< | Match the empty string at the beginning of word. | grep '\<="" kbd="" style="box-sizing: inherit;"> |
| \> | Match the empty string at the end of word. | grep 'bash\>' /etc/passwd grep '\' /etc/passwd |
- https://www.digitalocean.com/community/tutorials/using-grep-regular-expressions-to-search-for-text-patterns-in-linux
- https://www.cyberciti.biz/faq/grep-regular-expressions/
- https://www.debuggex.com/r/tMQ8TzNdVe3jzS5y 好用的Debug regular
You can reverse the meaning of the square brackets by putting a ^ immediately after the [.
In this case, the brackets will match any character that is not listed inside the brackets.
Again, note that we use [^] with regular expressions
$ grep dev.hda[^12] /etc/fstab
a line that starts with the # character and ends with the . character, with any number of other
characters in between:
$ grep '^#.*\.$' /etc/fstab
# /etc/fstab: static file system information
When bash starts it opens the three standard file descriptors: stdin (file descriptor 0), stdout (file descriptor 1), and stderr (file descriptor 2). You can open more file descriptors (such as 3, 4, 5, ...), and you can close them
~ # ls -l a
ls: a: No such file or directory
~ # ls -l a 2>abc
~ # cat abc
ls: a: No such file or directory
~ # ls -l a 1>abc
ls: a: No such file or directory
~ # cat abc
~ # ls -l a &>abc
~ # cat abc
ls: a: No such file or directory
https://catonmat.net/bash-one-liners-explained-part-three
bash exit code
http://www.tldp.org/LDP/abs/html/exitcodes.html
makefile .PHONY的作用
讓cc變成一個偽目標,即使沒有cc這個檔案也可以執行。
2019年6月12日
安裝 Nvidia 顯示卡驅動
https://www.nvidia.com/object/unix.html
# bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
# /sbin/shutdown -r now
# service lightdm stop
# chmod +x NVIDIA-Linux-x86_64-390.116.run
# ./NVIDIA-Linux-x86_64-390.116.run
-----Testing-----
$ nvidia-settings
2019年6月10日
2019年6月3日
Linux 方便簡單的截圖軟體 Imagemagick
# apt-get install imagemagick
執行
$ import sc1.png
$ import -window root image1.png
若出現
import: unable to open X server `' @ error/import.c/ImportImageCommand/366.
錯誤訊息
請重新開機即可
2019年6月2日
No common CD-ROM drive was detected 解決方式
請使用https://rufus.ie/ rufus燒入軟體,將ISO燒製USB,並且選擇 DD Image mode
DD Image mode VS ISO Image mode
https://askubuntu.com/questions/896911/is-dd-image-disk-writing-permanent
2018年7月11日
真誠的讚美 帶給雙方美好的感受
如何真誠讚美一個人?
什麼叫不一樣突出的點
在禮堂台上演講者發問問題,讓台下的聽眾來舉手回答,等了一會兒有位人舉了手回答這沒人回答的問題,並且答案完全正確!!在休息時間裝水的時候,我剛好遇到他,我就說:嗨~你怎麼知道剛剛那題的答案呀OAO!! 他跟你說明之後原來他很熱愛看戰爭片所以他很熟這問題,我就覺得:哇賽! 現場那麼多人只有你答得出來耶 好猛喔OAO!
任何人都一定有優點!!
簡單舉
身邊的同學有什麼優點? 成績好、很會聊、很會打球、願意無私分享知識。
在更小的事情~
我發現你不但不會隨手丟垃圾,只要你路過看到地上有垃圾都會主動撿起來。
玩遊戲的時候~我仔細觀察發現他玩遊戲滑鼠移動看起來好可愛哦O口O!! 看起來像撲撲車的感覺!!
那那如果是剛出生的小寶寶有什麼優點?
.
.
.
.
.
2018年7月7日
嫉妒 可以誹謗一個人 也可以讓自己成長
嫉妒?
只要是正常人都會有嫉妒之心,嫉妒主要對象是人,我們會嫉妒一個人的好,一個人的優點或快樂,卻不會嫉妒一個人的缺點或不快樂,嫉妒屬於七宗罪對人類惡行的之一,在嫉妒心的作用之下,人可能會透過謠言、搬弄是非、誹謗和其他間接的行為以貶損被嫉妒的人,而無意之間造口業。
不好的行為
簡單舉如果一個人一天到晚都在想要怎麼陷害那個人要怎麼到處詆毀那個人,可能你會花很多心思在策劃如何陷害他,而當你一開口到處散佈不實謠言詆毀他人,別人對你的第一印象就是你很愛說說別人的壞話或毀謗他人,而這樣的結果不僅浪費時間在思考怎麼陷害一個人,一個經常到處口出惡言,會有多少人喜歡他呢?
相反的一個人仔細觀察一個人看出一個人的好,用真誠的心來讚美他,到處讚美別人說好話,別人想到你的第一瞬間不會是惡事,而是你的好話!
真誠的讚美
被害人的影響
好的行為
仔細觀察他人找出他的優點向他學習或模仿來提升自我,讓自己成長、讓自己進步,嘗試讓自己接近或達到被嫉妒的人的成就,或者在其他方面能夠更勝於他,來緩和嫉妒的情緒。 簡單舉例如果有個英文很好的同學每次段考英文總是拿第一,而你是位很努力很拼命的人,不管再怎麼努力英文還是無法贏過他,仔細觀察為什麼他的英文總是這麼好,他的優點是什麼,向他學習他的優點或請教他,或許他從小在國外受教育所以英文對他來說易如反掌,那先天的優勢我們可以反過來思考我們自身的優勢,加強自身的強項來戰勝他人,達到自我成長也是可以的。
正向思考
自我的影響
兩舌
兩舌則是利用機會在兩人之間道長話短並搬弄是非,最終目的在於挑撥離間,破壞當事人的處事和諧。在日常生活中,犯了這四項口業,其惡口傷害了對方感情,妄言破壞了當事人人格,而搬弄是非及綺語亦使彼此相處無法真誠對待。 ref: https://zh.wikipedia.org/wiki/%E5%8F%A3%E6%A5%AD
2018年6月27日
2018年5月17日
2017年4月12日
2017年4月10日
How to choose right PWM frequency
- Switching has to be done several times a minute in an electric stove; 120 Hz in a lamp dimmer; between a few kilohertz (kHz), to tens of kHz for a motor drive; and well into the tens or hundreds of kHz in audio amplifiers and computer power supplies.
- For a question like this, you will probably get as many answers as there are people interested in answering. Here is my answer: It depends.Here are some of the limiting factors, first the lower limits:
- Persistence of vision:
- Different people are differently sensitive to flicker in a light source. Some would notice flicker even at 100 Hertz, others perhaps not even at as low as 10 Hz.
- Motion of light source relative to the eye makes flicker more discernible, scaling up with speed of the motion.
- Human vision sensitivity at low intensity of light - both ambient and source intensity. At very low intensity, the eye is much more sensitive to any change in intensity. So an LED operated at low duty cycle / low current and in a dark environment would require a higher minimum PWM frequency.
Now the upper limits:- LED turn-on characteristics: An LED cannot be toggled at arbitrarily high frequency, once the pulse duration approaches the turn-on time, the LED never really turns on fully, hence linearity of PWM control is lost to begin with, and at higher frequency / shorter pulses, eventually the LED just stays dim or off.
- PWM provider capabilities: Your microcontroller would have its own maximum PWM rate, which sets a hard limit.
- Switching losses: Any switching system, MOSFET based, BJT based, or other, suffers switching losses of power as switching rate increases. At one point this become significant both in terms of heating of switching device, and efficiency of illumination.
Thus, depending on these parameters, and any others affecting your specific requirement, the correct answer could be anywhere in the 50 Hz to few dozen KHz range. - Persistence of vision:
- motor frequency 可以測試不同頻率下輸出電流來決定
- Ref:










