Showing posts with label Linux Basic. Show all posts

Whiptail - Công cụ tạo giao diện đồ họa trên terminal (bash shell)

Công cụ này được dùng để tạo ra một giao diện đồ họa đơn giản để install hoặc settting một phần mềm nào đó trên môi trường bash shell của terminal.

Một ví dụ, chẳng hạn khi muốn config cấu hình của raspberry pi:
Gõ lệnh "sudo raspi-config" 

sẽ ra giao diện như dưới đây :


Note: Chi tiết cách sử dụng có thể tham khảo wiki





Tuesday, December 31, 2019

System start - init - /etc/init.d

1. Init


Init là chương trình khởi động được chạy tiếp theo sau khi chạy xong kernel
các script được Init gọi dùng để chạy các service.
Các step:
+ Init đọc và phân tích file /etc/inittab để khởi chạy các service, tuy nhiên các version sau này inittab không còn được sử dụng
+ Lần lượt chạy các script
    - /etc/init.d/rcS         => chạy start script trong /etc/rcS.d
    - /etc/init.d/rc           => chạy lần lượt các script tring /etc/rc*.d
    - /etc/init.d/rc.local  => user add thêm các script của riêng mình
+ getty => login user & password

2. Các folder
+ /etc/init.d   :  thư mục chứa các script để start/stop service
+ /etc/rc*.d   : gồm các script được bắt đầu bằng
                        - S****         => start service
                        - K****        => stop service
                      các script này thực chấy được symbol link từ /etc/init.d
     



Sunday, October 15, 2017

QMake


QMake là một chương trình thuộc bộ công cụ QT Framework có tác dụng tạo ra Makefile cho các QT project, nói chung tương tự như CMake.
Xem thêm các bài viết về QT Framework tại đây.


Sunday, October 4, 2015

GNU Make (GMake/Make)


GNU Make hay còn gọi là gmake hoặc make, là một công cụ mặc định trên Linux được dùng trong quá trình compile thư viện hoặc một chương trình nào đó. Một bộ 3 công cụ và script sau được dùng trong qúa trình trên:
+ Make (GNU Make)
+ Makefile (Shell script)
+ GCC Compiler

Makefile chứa các thông tin và chỉ dẫn (các lời gọi lệnh GCC Compiler); Make sẽ đọc, phân tích Makefile để làm các công việc theo các hướng dẫn trong đó.

Để xem thông tin về make

 [ninhld@localhost ~]$   
 [ninhld@localhost ~]$ gmake --version  
 GNU Make 3.82  
 Built for x86_64-redhat-linux-gnu  
 Copyright (C) 2010 Free Software Foundation, Inc.  
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>  
 This is free software: you are free to change and redistribute it.  
 There is NO WARRANTY, to the extent permitted by law.  
 [ninhld@localhost ~]$   
 [ninhld@localhost ~]$   
 [ninhld@localhost ~]$   
 [ninhld@localhost ~]$ make --version  
 GNU Make 3.82  
 Built for x86_64-redhat-linux-gnu  
 Copyright (C) 2010 Free Software Foundation, Inc.  
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>  
 This is free software: you are free to change and redistribute it.  
 There is NO WARRANTY, to the extent permitted by law.  
 [ninhld@localhost ~]$   

 [ninhld@localhost ~]$   
 [ninhld@localhost ~]$ make --help  
 Usage: make [options] [target] ...  
 Options:  
  -b, -m           Ignored for compatibility.  
  -B, --always-make      Unconditionally make all targets.  
  -C DIRECTORY, --directory=DIRECTORY  
                Change to DIRECTORY before doing anything.  
  -d             Print lots of debugging information.  
  --debug[=FLAGS]       Print various types of debugging information.  
  -e, --environment-overrides  
                Environment variables override makefiles.  
  --eval=STRING        Evaluate STRING as a makefile statement.  
  -f FILE, --file=FILE, --makefile=FILE  
                Read FILE as a makefile.  
  -h, --help         Print this message and exit.  
  -i, --ignore-errors     Ignore errors from recipes.  
  -I DIRECTORY, --include-dir=DIRECTORY  
                Search DIRECTORY for included makefiles.  
  -j [N], --jobs[=N]     Allow N jobs at once; infinite jobs with no arg.  
  -k, --keep-going      Keep going when some targets can't be made.  
  -l [N], --load-average[=N], --max-load[=N]  
                Don't start multiple jobs unless load is below N.  
  -L, --check-symlink-times  Use the latest mtime between symlinks and target.  
  -n, --just-print, --dry-run, --recon  
                Don't actually run any recipe; just print them.  
  -o FILE, --old-file=FILE, --assume-old=FILE  
                Consider FILE to be very old and don't remake it.  
  -p, --print-data-base    Print make's internal database.  
  -q, --question       Run no recipe; exit status says if up to date.  
  -r, --no-builtin-rules   Disable the built-in implicit rules.  
  -R, --no-builtin-variables Disable the built-in variable settings.  
  -s, --silent, --quiet    Don't echo recipes.  
  -S, --no-keep-going, --stop  
                Turns off -k.  
  -t, --touch         Touch targets instead of remaking them.  
  -v, --version        Print the version number of make and exit.  
  -w, --print-directory    Print the current directory.  
  --no-print-directory    Turn off -w, even if it was turned on implicitly.  
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE  
                Consider FILE to be infinitely new.  
  --warn-undefined-variables Warn when an undefined variable is referenced.  
  --warn-undefined-functions Warn when an undefined user function is called.  
   
 This program built for x86_64-redhat-linux-gnu  
 Report bugs to <bug-make@gnu.org>  
 [ninhld@localhost ~]$  

Các bài viết liên quan:
+ Makefile
+ Cross Compiler
Cross compiling the libraries



Sunday, July 5, 2015

CMake

Bài viết liên quan:

CMake là một công cụ trợ giúp cho việc build library, có chức năng sinh ra Makefile tương tự như script configure như thông thường.
Install CMake trên Fedora:
yum install cmake cmake-gui
Trong đó cmake là command line, cmake-gui là công cụ CMake bằng giao diện đồ họa, dễ sử dụng hơn so với command line.

Để bắt đầu chúng ta cùng build thư viện OpenCV-2.3.1, một thư viện sử dụng Cmake để build.
Download và giải nén, bạn sẽ thấy trong thư mục OpenCV-2.3.1 có một file cấu hình của CMake có tên CMakeLists.txt


 cd /home/ninhld/Documents/OpenCV-2.3.1  
 mkdir release  
 cd release  
 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/usr/local ..  #chu y phai co hai dau cham  
 make  
 make install  

Sau khi installed xong, bạn mở thư mục /home/usr/local 





Install GTK
yum install gtk2-devel

DisplayImage.cpp
 #include <stdio.h>  
 #include <opencv2/opencv.hpp>  
   
 using namespace cv;  
   
 int main(int argc, char** argv )  
 {  
   if ( argc != 2 )  
   {  
     printf("usage: DisplayImage.out <Image_Path>\n");  
     return -1;  
   }  
   
   Mat image;  
   image = imread( argv[1], 1 );  
   
   if ( !image.data )  
   {  
     printf("No image data \n");  
     return -1;  
   }  
   namedWindow("Display Image", CV_WINDOW_AUTOSIZE );  
   imshow("Display Image", image);  
   
   waitKey(0);  
   
   return 0;  
 }  
   


Build application
 export OPENCV_DIR=/home/usr/local
 export PATH=$PATH:${OPENCV_DIR}/bin  
 export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${OPENCV_DIR}/lib/pkgconfig #open opencv.pc and check install folder link  
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OPENCV_DIR}/lib  
   
 g++ `pkg-config --cflags opencv` `pkg-config --libs opencv` DisplayImage.cpp -o DisplayImage  
   

FromId3.jpg



Execute
 [ninhld@localhost ex]$   
 [ninhld@localhost ex]$ export OPENCV_DIR=/home/usr/local    
 [ninhld@localhost ex]$ export PATH=$PATH:${OPENCV_DIR}/bin  
 [ninhld@localhost ex]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OPENCV_DIR}/lib  
 [ninhld@localhost ex]$     
 [ninhld@localhost ex]$ ./DisplayImage FromId3.jpg   
   

Kết quả



Ở phần trên là build OpenCV cho host, bạn xem thêm bài viết về phần cross compiling OpenCV cho board nhúng FriendlyARM Mini2440 tại đây.

Bài viết liên quan:
+ CMake Cross Compiling

Saturday, July 4, 2015

Pkg-config

Bài viết liên quan:
+ Cross compiling the libraries

pkg-config là một chương trình build-in sẵn trong linux, có chức năng lấy thông tin về một thư viện nào đó đã được installed để phục vụ cho việc build một ứng dụng hoặc một thư viện khác có sử dụng thư viện này.
Thư viện đã installed sẽ có các file có đuôi mở rộng ".pc" chứa các thông tin về thư viện, chương trình pkg-config sẽ đọc thông tin từ các file này ra thông qua một biến môi trường có tên là PKG_CONFIG_PATH.
Theo như ví dụ như trong bài viết Cross compiling the libraries chúng ta đã build xong thư viện taglib-1.6.3


taglib.pc
 prefix=/home/ninhld/Documents/taglib_install  
 exec_prefix=${prefix}  
 libdir=${exec_prefix}/lib64  
 includedir=${prefix}/include  
   
 Name: TagLib  
 Description: Audio meta-data library  
 Requires:   
 Version: 1.6.3  
 Libs: -L${libdir} -ltag  
 Cflags: -I${includedir}/taglib   
   

taglib_c.pc
 prefix=/home/ninhld/Documents/taglib_install  
 exec_prefix=${prefix}  
 libdir=${exec_prefix}/lib64  
 includedir=${prefix}/include  
   
 Name: TagLib C Bindings  
 Description: Audio meta-data library (C bindings)  
 Requires: taglib  
 Version: 1.6.3  
 Libs: -L${libdir} -ltag_c  
 Cflags: -I${includedir}/taglib   
   


Các thông tin chính bao gồm:
+ Đường dẫn đến thư mục header, tương ứng với CFLAGS
+ Đường dẫn đến thư mục lib (chứa .la, .so), tương ứng với LDFLAGS


pkg-config hoạt động như thế nào:
+ Export biến môi trường PKG_CONFIG_PATH
+ Sử dụng lệnh pkg-config cùng với các options như --cflags, --libs, ...

 [ninhld@localhost examples]$   
 [ninhld@localhost examples]$ export TAGLIBDIR=/home/ninhld/Documents/taglib_install  
 [ninhld@localhost examples]$ export PATH=$PATH:${TAGLIBDIR}/bin 
 [ninhld@localhost examples]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${TAGLIBDIR}/lib64 
 [ninhld@localhost examples]$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${TAGLIBDIR}/lib64/pkgconfig  
 [ninhld@localhost examples]$   
 [ninhld@localhost examples]$ pkg-config --cflags taglib taglib_c  
 -I/home/ninhld/Documents/taglib_install/include/taglib   
 [ninhld@localhost examples]$   
 [ninhld@localhost examples]$ pkg-config --libs taglib taglib_c  
 -L/home/ninhld/Documents/taglib_install/lib64 -ltag_c -ltag   
 [ninhld@localhost examples]$   
 [ninhld@localhost examples]$   

Như vậy có thể thấy thay vì export các biến CFLAGS / LDFLAGS:
 export CFLAGS+="-I${TAGLIBDIR}/include/taglib -DDEBUG -Wall -g"    
 export LDFLAGS+="-L${TAGLIBDIR}/lib64 -ltag_c -ltag"    

thì bạn có thể dùng pkg-config:
 export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${TAGLIBDIR}/lib64/pkgconfig  
 pkg-config --libs --cflags taglib taglib_c  

Note: taglib / taglib_c tương ứng với taglib.pc / taglib_c.pc

Cuối cùng, cũng với ví dụ taglreader_c.c như trong bài  Cross compiling the libraries, hai cách dưới đây là tương đương:

 gcc -o tagreader tagreader_c.c ${CFLAGS} ${LDFLAGS}  

 gcc -o tagreader tagreader_c.c $(pkg-config --libs --cflags taglib taglib_c)  

Note: pkg-config rất hữu ích khi có rất nhiều thư viện được installed ở các thư mục khác nhau, thay vì phải liệt kê tất cả các đường dẫn và lib trong CFLAGS / LDFLAGS thì chỉ cần export PKG_CONFIG_PATH đến các thư mục pkgconfig của các thư viện installed là đủ.

Friday, July 3, 2015

Linux /dev directory


Thư mục /dev trong linux là một thư mục đặc biệt chứa tất cả các device file, để xem được bên trong /dev có gì bạn dùng lệnh:

 $ ls -l /dev/  
 total 0  
 crw-------. 1 root root    10, 235 Jul 2 20:18 autofs  
 drwxr-xr-x. 2 root root      240 Jul 3 2015 block  
 drwxr-xr-x. 2 root root      80 Jul 3 2015 bsg  
 crw-------. 1 root root    10, 234 Jul 2 20:18 btrfs-control  
 drwxr-xr-x. 3 root root      60 Jul 3 2015 bus  
 lrwxrwxrwx. 1 root root       3 Jul 2 20:18 cdrom -> sr0  
 drwxr-xr-x. 2 root root     3720 Jul 2 20:18 char  
 crw-------. 1 root root    5,  1 Jul 2 20:18 console  
 lrwxrwxrwx. 1 root root      11 Jul 3 2015 core -> /proc/kcore  
 drwxr-xr-x. 6 root root      140 Jul 2 20:18 cpu  
 crw-------. 1 root root    10, 62 Jul 2 20:18 cpu_dma_latency  
 drwxr-xr-x. 5 root root      100 Jul 3 2015 disk  
 drwxr-xr-x. 2 root root      100 Jul 3 2015 dri  
 crw-rw----. 1 root video   29,  0 Jul 2 20:18 fb0  
 lrwxrwxrwx. 1 root root      13 Jul 3 2015 fd -> /proc/self/fd  
 crw-rw-rw-. 1 root root    1,  7 Jul 2 20:18 full  
 crw-rw-rw-. 1 root root    10, 229 Jul 2 20:18 fuse  
 crw-------. 1 root root   247,  0 Jul 2 20:18 fw0  
 crw-------. 1 root root   250,  0 Jul 2 20:18 hidraw0  
 crw-------. 1 root root    10, 228 Jul 2 20:18 hpet  
 drwxr-xr-x. 2 root root       0 Jul 2 20:18 hugepages  
 prw-------. 1 root root       0 Jul 2 20:18 initctl  
 drwxr-xr-x. 4 root root      500 Jul 2 20:18 input  
 crw-r--r--. 1 root root    1, 11 Jul 2 20:18 kmsg  
 crw-rw----+ 1 root root    10, 232 Jul 2 20:18 kvm  
 srw-rw-rw-. 1 root root       0 Jul 3 2015 log  
 crw-rw----. 1 root disk    10, 237 Jul 2 20:18 loop-control  
 crw-rw----. 1 root lp     6,  0 Jul 2 20:18 lp0  
 crw-rw----. 1 root lp     6,  1 Jul 2 20:18 lp1  
 crw-rw----. 1 root lp     6,  2 Jul 2 20:18 lp2  
 crw-rw----. 1 root lp     6,  3 Jul 2 20:18 lp3  
 drwxr-xr-x. 2 root root      60 Jul 3 2015 mapper  
 crw-------. 1 root root    10, 227 Jul 2 20:18 mcelog  
 crw-------. 1 root root   245,  0 Jul 2 20:18 media0  
 crw-------. 1 root root   246,  0 Jul 2 20:18 mei0  
 crw-r-----. 1 root kmem    1,  1 Jul 2 20:18 mem  
 crw-------. 1 root root    10, 59 Jul 2 20:18 memory_bandwidth  
 drwxrwxrwt. 2 root root      40 Jul 3 2015 mqueue  
 drwxr-xr-x. 2 root root      60 Jul 2 20:18 net  
 crw-------. 1 root root    10, 61 Jul 2 20:18 network_latency  
 crw-------. 1 root root    10, 60 Jul 2 20:18 network_throughput  
 crw-rw-rw-. 1 root root    1,  3 Jul 2 20:18 null  
 crw-------. 1 root root    10, 144 Jul 2 20:18 nvram  
 crw-r-----. 1 root kmem    1,  4 Jul 2 20:18 port  
 crw-------. 1 root root   108,  0 Jul 2 20:18 ppp  
 crw-rw-rw-. 1 root tty     5,  2 Jul 2 21:06 ptmx  
 crw-------. 1 root root   248,  0 Jul 2 20:18 ptp0  
 drwxr-xr-x. 2 root root       0 Jul 3 2015 pts  
 crw-rw-rw-. 1 root root    1,  8 Jul 2 20:18 random  
 drwxr-xr-x. 2 root root      60 Jul 3 2015 raw  
 lrwxrwxrwx. 1 root root       4 Jul 3 2015 resume -> sda7  
 crw-rw-r--+ 1 root root    10, 55 Jul 2 20:18 rfkill  
 lrwxrwxrwx. 1 root root       4 Jul 2 20:18 rtc -> rtc0  
 crw-------. 1 root root   254,  0 Jul 2 20:18 rtc0  
 brw-rw----. 1 root disk    8,  0 Jul 2 20:18 sda  
 brw-rw----. 1 root disk    8,  1 Jul 2 20:18 sda1  
 brw-rw----. 1 root disk    8,  2 Jul 2 20:18 sda2  
 brw-rw----. 1 root disk    8,  3 Jul 2 20:18 sda3  
 brw-rw----. 1 root disk    8,  5 Jul 2 20:18 sda5  
 brw-rw----. 1 root disk    8,  6 Jul 2 20:18 sda6  
 brw-rw----. 1 root disk    8,  7 Jul 2 20:18 sda7  
 brw-rw----. 1 root disk    8,  8 Jul 2 20:18 sda8  
 brw-rw----. 1 root disk    8,  9 Jul 2 20:18 sda9  
 crw-rw----. 1 root disk    21,  0 Jul 2 20:18 sg0  
 crw-rw----+ 1 root cdrom   21,  1 Jul 2 20:18 sg1  
 drwxrwxrwt. 2 root root      120 Jul 2 21:06 shm  
 crw-------. 1 root root    10, 231 Jul 2 20:18 snapshot  
 drwxr-xr-x. 3 root root      280 Jul 2 20:18 snd  
 brw-rw----+ 1 root cdrom   11,  0 Jul 2 20:18 sr0  
 lrwxrwxrwx. 1 root root      15 Jul 3 2015 stderr -> /proc/self/fd/2  
 lrwxrwxrwx. 1 root root      15 Jul 3 2015 stdin -> /proc/self/fd/0  
 lrwxrwxrwx. 1 root root      15 Jul 3 2015 stdout -> /proc/self/fd/1  
 crw-------. 1 root root    10, 224 Jul 2 20:18 tpm0  
 crw-rw-rw-. 1 root tty     5,  0 Jul 2 20:18 tty  
 crw--w----. 1 root tty     4,  0 Jul 2 20:18 tty0  
 crw--w----. 1 root tty     4,  1 Jul 2 20:18 tty1  
 crw--w----. 1 root tty     4, 10 Jul 2 20:18 tty10  
 crw--w----. 1 root tty     4, 11 Jul 2 20:18 tty11  
 crw--w----. 1 root tty     4, 12 Jul 2 20:18 tty12  
 crw--w----. 1 root tty     4, 13 Jul 2 20:18 tty13  
 crw--w----. 1 root tty     4, 14 Jul 2 20:18 tty14  
 crw--w----. 1 root tty     4, 15 Jul 2 20:18 tty15  
 crw--w----. 1 root tty     4, 16 Jul 2 20:18 tty16  
 crw--w----. 1 root tty     4, 17 Jul 2 20:18 tty17  
 crw--w----. 1 root tty     4, 18 Jul 2 20:18 tty18  
 crw--w----. 1 root tty     4, 19 Jul 2 20:18 tty19  
 crw--w----. 1 root tty     4,  2 Jul 2 20:18 tty2  
 crw--w----. 1 root tty     4, 20 Jul 2 20:18 tty20  
 crw--w----. 1 root tty     4, 21 Jul 2 20:18 tty21  
 crw--w----. 1 root tty     4, 22 Jul 2 20:18 tty22  
 crw--w----. 1 root tty     4, 23 Jul 2 20:18 tty23  
 crw--w----. 1 root tty     4, 24 Jul 2 20:18 tty24  
 crw--w----. 1 root tty     4, 25 Jul 2 20:18 tty25  
 crw--w----. 1 root tty     4, 26 Jul 2 20:18 tty26  
 crw--w----. 1 root tty     4, 27 Jul 2 20:18 tty27  
 crw--w----. 1 root tty     4, 28 Jul 2 20:18 tty28  
 crw--w----. 1 root tty     4, 29 Jul 2 20:18 tty29  
 crw--w----. 1 root tty     4,  3 Jul 2 20:18 tty3  
 crw--w----. 1 root tty     4, 30 Jul 2 20:18 tty30  
 crw--w----. 1 root tty     4, 31 Jul 2 20:18 tty31  
 crw--w----. 1 root tty     4, 32 Jul 2 20:18 tty32  
 crw--w----. 1 root tty     4, 33 Jul 2 20:18 tty33  
 crw--w----. 1 root tty     4, 34 Jul 2 20:18 tty34  
 crw--w----. 1 root tty     4, 35 Jul 2 20:18 tty35  
 crw--w----. 1 root tty     4, 36 Jul 2 20:18 tty36  
 crw--w----. 1 root tty     4, 37 Jul 2 20:18 tty37  
 crw--w----. 1 root tty     4, 38 Jul 2 20:18 tty38  
 crw--w----. 1 root tty     4, 39 Jul 2 20:18 tty39  
 crw--w----. 1 root tty     4,  4 Jul 2 20:18 tty4  
 crw--w----. 1 root tty     4, 40 Jul 2 20:18 tty40  
 crw--w----. 1 root tty     4, 41 Jul 2 20:18 tty41  
 crw--w----. 1 root tty     4, 42 Jul 2 20:18 tty42  
 crw--w----. 1 root tty     4, 43 Jul 2 20:18 tty43  
 crw--w----. 1 root tty     4, 44 Jul 2 20:18 tty44  
 crw--w----. 1 root tty     4, 45 Jul 2 20:18 tty45  
 crw--w----. 1 root tty     4, 46 Jul 2 20:18 tty46  
 crw--w----. 1 root tty     4, 47 Jul 2 20:18 tty47  
 crw--w----. 1 root tty     4, 48 Jul 2 20:18 tty48  
 crw--w----. 1 root tty     4, 49 Jul 2 20:18 tty49  
 crw--w----. 1 root tty     4,  5 Jul 2 20:18 tty5  
 crw--w----. 1 root tty     4, 50 Jul 2 20:18 tty50  
 crw--w----. 1 root tty     4, 51 Jul 2 20:18 tty51  
 crw--w----. 1 root tty     4, 52 Jul 2 20:18 tty52  
 crw--w----. 1 root tty     4, 53 Jul 2 20:18 tty53  
 crw--w----. 1 root tty     4, 54 Jul 2 20:18 tty54  
 crw--w----. 1 root tty     4, 55 Jul 2 20:18 tty55  
 crw--w----. 1 root tty     4, 56 Jul 2 20:18 tty56  
 crw--w----. 1 root tty     4, 57 Jul 2 20:18 tty57  
 crw--w----. 1 root tty     4, 58 Jul 2 20:18 tty58  
 crw--w----. 1 root tty     4, 59 Jul 2 20:18 tty59  
 crw--w----. 1 root tty     4,  6 Jul 2 20:18 tty6  
 crw--w----. 1 root tty     4, 60 Jul 2 20:18 tty60  
 crw--w----. 1 root tty     4, 61 Jul 2 20:18 tty61  
 crw--w----. 1 root tty     4, 62 Jul 2 20:18 tty62  
 crw--w----. 1 root tty     4, 63 Jul 2 20:18 tty63  
 crw--w----. 1 root tty     4,  7 Jul 2 20:18 tty7  
 crw--w----. 1 root tty     4,  8 Jul 2 20:18 tty8  
 crw--w----. 1 root tty     4,  9 Jul 2 20:18 tty9  
 crw-rw----. 1 root dialout   4, 64 Jul 2 20:18 ttyS0  
 crw-rw----. 1 root dialout   4, 65 Jul 2 20:18 ttyS1  
 crw-rw----. 1 root dialout   4, 66 Jul 2 20:18 ttyS2  
 crw-rw----. 1 root dialout   4, 67 Jul 2 20:18 ttyS3  
 crw-------. 1 root root    10, 239 Jul 2 20:18 uhid  
 crw-------. 1 root root    10, 223 Jul 2 20:18 uinput  
 crw-rw-rw-. 1 root root    1,  9 Jul 2 20:18 urandom  
 drwxr-xr-x. 2 root root      60 Jul 3 2015 usb  
 crw-------. 1 root root   251,  0 Jul 2 20:18 usbmon0  
 crw-------. 1 root root   251,  1 Jul 2 20:18 usbmon1  
 crw-------. 1 root root   251,  2 Jul 2 20:18 usbmon2  
 drwxr-xr-x. 4 root root      80 Jul 2 20:18 v4l  
 crw-------. 1 root root    10, 58 Jul 2 20:18 vboxdrv  
 crw-------. 1 root root    10, 57 Jul 2 20:18 vboxdrvu  
 crw-------. 1 root root    10, 56 Jul 2 20:18 vboxnetctl  
 drwxr-x---. 4 root vboxusers    80 Jul 2 20:18 vboxusb  
 crw-rw----. 1 root tty     7,  0 Jul 2 20:18 vcs  
 crw-rw----. 1 root tty     7,  1 Jul 2 20:18 vcs1  
 crw-rw----. 1 root tty     7,  2 Jul 2 20:18 vcs2  
 crw-rw----. 1 root tty     7,  3 Jul 2 20:18 vcs3  
 crw-rw----. 1 root tty     7,  4 Jul 2 20:18 vcs4  
 crw-rw----. 1 root tty     7,  5 Jul 2 20:18 vcs5  
 crw-rw----. 1 root tty     7,  6 Jul 2 20:18 vcs6  
 crw-rw----. 1 root tty     7, 128 Jul 2 20:18 vcsa  
 crw-rw----. 1 root tty     7, 129 Jul 2 20:18 vcsa1  
 crw-rw----. 1 root tty     7, 130 Jul 2 20:18 vcsa2  
 crw-rw----. 1 root tty     7, 131 Jul 2 20:18 vcsa3  
 crw-rw----. 1 root tty     7, 132 Jul 2 20:18 vcsa4  
 crw-rw----. 1 root tty     7, 133 Jul 2 20:18 vcsa5  
 crw-rw----. 1 root tty     7, 134 Jul 2 20:18 vcsa6  
 drwxr-xr-x. 2 root root      60 Jul 2 20:18 vfio  
 crw-------. 1 root root    10, 63 Jul 2 20:18 vga_arbiter  
 crw-------. 1 root root    10, 137 Jul 2 20:18 vhci  
 crw-------. 1 root root    10, 238 Jul 2 20:18 vhost-net  
 crw-rw----+ 1 root video   81,  0 Jul 2 20:18 video0  
 crw-------. 1 root root    10, 130 Jul 2 20:18 watchdog  
 crw-------. 1 root root   253,  0 Jul 2 20:18 watchdog0  
 crw-------. 1 root root   253,  1 Jul 2 20:18 watchdog1  
 crw-rw-rw-. 1 root root    1,  5 Jul 2 20:18 zero  


/dev/fd0
Đĩa mềm

/dev/fb0
Framebuffer device.

/dev/hda
/dev/hda is the master IDE drive on the primary IDE controller. /dev/hdb the slave drive on the primary controller. /dev/hdc , and /dev/hdd are the master and slave devices on the secondary controller respectively

/dev/psaux
The PS/2 mouse port.

/dev/random or /dev/urandom
These are kernel random number generators. /dev/random is a non-deterministic generator which means that the value of the next number cannot be guessed from the preceding ones. It uses the entropy of the system hardware to generate numbers. When it has no more entropy to use then it must wait until it has collected more before it will allow any more numbers to be read from it. /dev/urandom works similarly. Initially it also uses the entropy of the system hardware, but when there is no more entropy to use it will continue to return numbers using a pseudo random number generating formula. This is considered to be less secure for vital purposes such as cryptographic key pair generation. If security is your overriding concern then use /dev/random, if speed is more important then /dev/urandom works fine. They are character devices on major node 1 with minor nodes 8 for /dev/random and 9 for /dev/urandom.

/dev/sda
The first SCSI drive on the first SCSI bus. The following drives are named similar to IDE drives. /dev/sdb is the second SCSI drive, /dev/sdc is the third SCSI drive, and so forth.

/dev/ttyS0
The first serial port.

/dev/input/*
Mouse and keyboard,...

/dev/zero
This is a simple way of getting many 0s. Every time you read from this device it will return 0. This can be useful sometimes, for example when you want a file of fixed length but don't really care what it contains. It is a character device on major node 1 and minor node 5.

/dev/null
The bit bucket. A black hole where you can send data for it never to be seen again. Anything sent to /dev/null will disappear. This can be useful if, for example, you wish to run a command but not have any feedback appear on the terminal. It is a character device on major node 1 and minor node 3.

Bài viết liên quan:
+ File System
+ Device file
+ Wiki

Thursday, July 2, 2015

- Copyright © Lập trình hệ thống nhúng Linux . Powered by Luong Duy Ninh -