Mánh trong tuần – 1
Đăng bởi dongthao on Tháng Một 8, 2008

- Mục đích Sử dụng lệnh trong Linux một cách hiệu quả nhất
- Dành cho Người sử dụng, Quản trị hệ thống
- Mức độ Trung bình
$ set -o ignoreeof Enable Ctrl+D$ set +o ignoreeof Disable Ctrl+D
alias timfile=”find -name”
thì sau đó, khi ta nhập lệnh timfile <file_name> shell sẽ chạy lệnh “find -name <file_name>”, tìm kiếm file mà ta yêu cầu.
Cấu trúc để đặt alias như sau:
$ alias tên_alias=”lệnh_tương_ứng_trên_shell”
Để tắt alias, ta dùng lệnh unalias:
$ unalias tên_alias.
Để xem các bí danh trong hệ thống, ta chỉ cần gõ “alias”.
3. Các lệnh được sử dụng gần đây nhất – Để xem 10 lệnh đã sử dụng gần đây nhất, chạy lệnh sau:
$ history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -rn|head -10
Thay số 10 bằng số lệnh tương ứng bạn muốn xem.
4. Xem thông tin hệ thống – Có một số lệnh bạn có thể dùng để xác định những thông tin hệ thống cơ bản như sau:
$ cat /proc/version = “It returns a full string of information”
$ uname -m = “The result of the machine’s number”
$ uname -r = “Show the version of the kernel”
$ uname -n = “Returns the local domain name”
$ uname -s = “Will show the system name”
$ uname -p = “It tells you the type and name of the processor”
$ uname -a = “Will show all the information above and also the date and time of the system”
5. Sử dụng lịch – Linux có sẵn bộ lịch built-in trong hệ thống, truy xuất bằng những lệnh đơn giản
$ cal -3 = “Simply display the calendar”
$ cal 1 2008 = “This command display a calendar of a particular month of the year”
$ date -d fri = “Display the date of the next on the current or next week”
$ date –date=’25 Dec’ +%A = “Tell you which day will be Christmas this year”
Đông Thao
Nguồn ảnh http://www.bw-it.be

