Sunteți pe pagina 1din 5

1.

Cau hinh date bang command line - Hien thi gio ta dung lenh date [root@linux ~]# date Thu Jan 31 06:20:25 ICT 2002 - Xem giup do cau lenh "date" [root@linux ~]#date --help [root@linux ~]#info date [root@linux ~]#man date - Cau hinh date cho linux [root@linux ~]# date -s "14 March 2011 16:01:00" Mon Mar 14 16:01:00 ICT 2011 => -s nghia la set, thiet lap gio theo mot doan string - Thay doi timezone [root@linux ~]#vi /etc/sysconfig/clock # The ZONE parameter is only evaluated by system-config-date. # The timezone of the system is defined by the contents of /etc/localtime. ZONE="Asia/Ho_Chi_Minh" UTC=true ARC=false Ta co the su dung giao dien do hoa [root@linux ~]#setup - Link tham khao set timezone http://www.cyberciti.biz/faq/howto-linux-unix-change-setup-timezone-tz-variable/ - Cau hinh timezone tren Ubuntu [root@linux ~]#nano /etc/timezone Asia/Ho_Chi_Minh hoac ta co the su dung giao dien do hoa [root@linux ~]#dpkg-reconfigure tzdata TIP: Ta nen cau hinh "NTP SERVER de dong bo thoi gian cho cac may PC trong Enter prise Network" 2. Su dung lenh "touch" - Tao ra mot file rong khong co noi dung neu nhu file nay khong co trong thu muc hien hanh. [student@linux test_touch]$ touch 123456.txt [student@linux test_touch]$ cat 123456.txt [student@linux test_touch]$ ls -l

total 4 -rw-rw-r-- 1 student student 0 Mar 14 16:07 123456.txt ==> file 123456.txt duoc tao ra luc 16:07 - Ta su dung lenh touch vao file 123456.txt da duoc tao ra se lam thay doi times tamp cua file [student@linux test_touch]$ date Mon Mar 14 16:08:58 ICT 2011 [student@linux test_touch]$ touch 123456.txt [student@linux test_touch]$ ls -l total 20 -rw-rw-r-- 1 student student 0 Mar 14 16:09 123456.txt [student@linux test_touch]$ => Thoi gian da duoc thay doi tu 16:07 ---> 16:09 - Su dung touch voi tham so -t de thay doi timestamp theo y muon [student@linux test_touch]$ ls -l total 4 -rw-rw-r-- 1 student student 0 Mar 14 16:09 123456.txt Cu phap: touch -t YYYYMMDDhhmm file [student@linux test_touch]$ touch -t 201003141500 123456.txt Kiem tra lai timestamp [student@linux test_touch]$ ls -l total 4 -rw-rw-r-- 1 student student 0 Mar 14 2010 123456.txt ==> 0 Mar 14 2010 3. Su dung lenh "stat" de kiem tra cac thuoc tinh cua file [student@linux test_touch]$ stat 123456.txt File: `123456.txt' Size: 0 Blocks: 8 IO Block: 4096 regular empty file Device: fd01h/64769d Inode: 2782571 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 501/ student) Gid: ( 501/ student) Access: 2010-03-14 15:00:00.000000000 +0700 Modify: 2010-03-14 15:00:00.000000000 +0700 Change: 2011-03-14 16:18:23.000000000 +0700 TIP: Ta co the su dung software 'inotify' de cau hinh ghi nhat ky cac thao tac d a duoc thuc thi tren file. 4. Su dung lenh 'find' de tim kiem - Cu phap find [vi_tri_tim_kiem] [phuong_thuc_tim_kiem] - Tim kiem file co ten la "ifconfig"

[root@linux ~]# find /sbin -name "ifconfig" /sbin/ifconfig - Tim kiem file co kieu nhan dang la "i?config" [root@linux ~]# find /sbin -name "i?config" /sbin/iwconfig /sbin/ifconfig - Tim kiem file co nguoi so huu la user nhanld [root@linux ~]# find /home -user nhanld /home/nhanld /home/nhanld/.bash_history /home/nhanld/.mozilla /home/nhanld/.mozilla/extensions /home/nhanld/.mozilla/plugins /home/nhanld/.bash_profile /home/nhanld/.bashrc /home/nhanld/.bash_logout - Tim kiem file co nguoi so huu la user nhanld va co ten nhan dang la "?bash*" [root@linux ~]# find /home -user nhanld -name "?bash*" /home/nhanld/.bash_history /home/nhanld/.bash_profile /home/nhanld/.bashrc /home/nhanld/.bash_logout - Tim kiem cac thu muc trong thu muc hien hanh [root@linux ~]# su root [root@linux ~]# find . -type d - Tim kiem cac file dang hiden trong thu muc hien hanh [root@linux ~]# find . -type f -name ".*" - Tim kiem cac file ben trong /root va chi tim o thu muc hien hanh ( tim 1 cap ) [root@linux ~]# find /root -maxdepth 1 -type f - Tim kiem cac file ben trong /root va tim 2 cap [root@linux ~]# find /root -maxdepth 2 -type f TIP: Tham khao va hieu chinh COLOR theo cac dang file http://www.cyberciti.biz/tips/where-is-color-of-ls-command-defined.html 5. Su dung Alias - De liet ke cac alias da duoc thuc hien [root@linux ~]# alias

alias alias alias alias alias alias alias tlde'

cp='cp -i' l.='ls -d .* --color=tty' ll='ls -l --color=tty' ls='ls --color=tty' mv='mv -i' rm='rm -i' which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-ti

- Tao ra mot alias moi cho [root@linux ~]# alias copy='cp -v' [root@linux ~]# alias alias copy='cp -v' alias cp='cp -i' alias l.='ls -d .* --color=tty' alias ll='ls -l --color=tty' alias ls='ls --color=tty' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-ti lde' [root@linux ~]# 6. Su dung lenh history - De kiem tra cac lenh da duoc nhap [root@linux ~]#history - De thuc thi lenh so 50 trong cau lenh history [root@linux ~]#!50 - De hien thi 10 lenh dau tien/cuoi cung trong cau lenh history ta ket hop hai l enh: history va head hoac tail [root@linux ~]#history | head -n 10 [root@linux ~]#history | tail -n 10 - Xoa di cache history [root@linux ~]#history -c -c : clear 7. Tao thu muc bang lenh "mkdir" - Tao ra don le mot thu muc [root@linux ~]#mkdir Test - Tao ra nhieu thu cung 1 luc va o dong cap [root@linux ~]#mkdir t1 t2 t3 - Tao mot cap thu muc nhieu cap

[root@linux ~]#mkdir -p Test1/Test2/Test3 - Tao ra cung mot luc nhieu thu muc dong cap [root@linux ~]#mkdir -p Test10/{Test11,Test12,Test13} [root@linux ~]#mkdir -p Test100/{Test11/Test111,Test12/Test222,Test13/Test333} - Tao ra thu muc abc ben trong moi thu muc Test101, Test102, Test103 [root@linux ~]#mkdir -p Test1000/{Test101,Test102,Test103}/abc