Professional Documents
Culture Documents
รวมคำสั่ง Linux Command
รวมคำสั่ง Linux Command
File/Directory Basics
ls
List files
cp
Copy files
mv
Rename files
rm
Delete files
ln
Link files
cd
Change directory
pwd
mkdir
Create directory
rmdir
Delete directory
( )
File Viewing
cat
View files
text file
less
head
tail
nl
Number lines
od
xxd
gv
xdvi
TeX
Text editor
GNU
vim
Text editor
vi
umask
permission mode
soffice
Word/Excel/PowerPoint
abiword
Word
gnumeric
Excel
File Properties
stat
//
wc
Count bytes/words/lines
du
file
touch
chown
chgrp
chmod
chattr
Isattr
File Location
find
Locate files
slocate
which
Locate commands
whereis
cut
Extract columns
paste
Append columns
tr
Translate characters
sort
Sort lines
uniq
tee
stdout
File Compression
gzip
.gz
Compress
Unix
bzip2
.bz2
zip
WinZip
File Comparison
diff
comm
cmp
md5sum
Compute Checksums
md5
mount
fsck
sync
dump
Back up a disk
restore
Restore a dump
tar
cdrecord
Burn a CD
rsync
Print files
Printing
lpr
lpq
lprm
Spelling Operations
look
Look up spelling
aspell
spell
ps
uptime
top
Monitor processes
xload
free
kill
Terminate processes
nice
renice
Processes
Scheduling Jobs
sleep
watch
at
Schedule a job
crontab
uname
hostname
ifconfig
host
Look up DNS
DNS
whois
ping
traceroute
Hosts
Networking
ssh
()
telnet
()
scp
()
stfp
(
)
ftp
(
)
evolution
mutt
text
mozilla
Web browser
lynx
text
wget
slrn
usenet
gaim
Instant messaging/IRC
talk
Linux/Unix chat
write
mesg
Prohibit talk/write
/ write
MP3
xmms
audacity
Edit audio
xcdroast
Burn CDs
1.1
ls : home directory
------------------------------------------------------------------------------- ls RWXRWXRWX
webmaster
CGI
CGI server
Perl (x)
chmod 755 hello.pl chmod 775 fileforyou.pl chmod +x test.pl 3
R Read
W Write
X Execute
--- : (
0)
--X : (
1)
R-- : (
4)
RW- : (
6)
R-X : ( 5)
RWX : (
7) RWXRWXRWX 9
3
3
3
RWX------ :
(
700)
RWXRWX--- :
(
770)
RWXR-XR-X : ( 755)
R--R--R-- : (
444)
chmod 777 index.php :: 3
chmod 755 * -Rf :: direcroty
-------------------------------------------------------------------------------1.3
man :
(Manual)
man man :: man
man ls :: ls
man useradd :: useradd
-------------------------------------------------------------------------------1.4
------------------------------------------------------------------------------- dos
directory
directory
3 mkdir directory (Make directory) rm directory
------------------------------------------------------------------------------- pico
pico
emacs ctrl-h ctrl-x + ctrl-c
pico editor emacs
pico emacs
Welcome to GNU Emacs, one component of a Linux-based GNU system.
Get help
C-h (Hold down CTRL and press h)
Undo changes
C-x u
Exit Emacs
C-x C-c
Get a tutorial C-h t
Use Info to read docs C-h i
Ordering manuals C-h RET
Activate menubar F10 or ESC ` or M-`
(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
If you have no Meta key, you may instead type ESC followed by the character.)
-------------------------------------------------------------------------------1.7
vi : editor text
dd
x
1
cw
:w
:q!
:wq vi
-------------------------------------------------------------------------------1.8
-------------------------------------------------------------------------------
id uname :: account uname
-------------------------------------------------------------------------------
cat /etc/passwd :: /etc/passwd
cat /etc/passwd | more :: /etc/passwd
passwd suwit:x:500:500:Suwit:/home/suwit:/bin/bash prasert:x:501:501::
/home/prasert:/bin/bash bcom101:x:502:502::/home/bcom302:/bin/bash
-------------------------------------------------------------------------------1.10
ifconfig :
Network interface
------------------------------------------------------------------------------- ifconfig
eth0
Link encap:Ethernet HWaddr 00:20:18:C0:06:C4
inet addr:202.29.78.12 Bcast:202.29.78.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:673054 errors:0 dropped:0 overruns:0 frame:0
TX packets:666268 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:74892865 (71.4 Mb) TX bytes:680121131 (648.6 Mb)
Interrupt:9 Base address:0xcf00
eth0:1 Link encap:Ethernet HWaddr 00:20:18:C0:06:C4
inet addr:202.29.78.1 Bcast:202.29.78.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:9 Base address:0xcf00
ip
1 ip #/sbin/ifconfig eth0:1 202.29.78.1
IP 9.10 /etc/rc.d/rc.local
-------------------------------------------------------------------------------1.11
netstat :
------------------------------------------------------------------------------- netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address
Foreign Address
State
tcp
0
0 *:mysql
*:*
LISTEN
tcp
0
0 *:http
*:*
LISTEN
tcp
0
0 *:ftp
*:*
LISTEN
tcp
0
0 *:ssh
*:*
LISTEN
tcp
0
0 *:smtp
*:*
LISTEN
tcp
0
0 *:https
*:*
LISTEN
tcp
0
0 www.isinthai.com:ssh 202.29.78.200:1225
ESTABLISHED
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags
Type
State
I-Node Path
unix 2
[ ACC ] STREAM LISTENING 855 /var/lib/mysql/mysql.sock
unix 2
[ ACC ] STREAM LISTENING 119 /dev/log
unix 2
[]
STREAM CONNECTED 3007
unix 2
[]
STREAM CONNECTED 859
-------------------------------------------------------------------------------1.12
service : running
xinetd : xinetd
/etc/xinetd.d
ip
server
whereis :
PATH find
-------------------------------------------------------------------------------
whereis usermod :: usermod run
whereis ifconfig :: ifconfig /sbin/ifconfig
-------------------------------------------------------------------------------1.15
cp, rm, mv :
-------------------------------------------------------------------------------
cp x y :: x y x
cp
rm y :: y directory
ping : ip internet
-------------------------------------------------------------------------------
ping www.thaiall.com :: www.thaiall.com IP
ping 202.29.78.100 -c 5 :: 5
ping 202.29.78.2 :: ip PING 202.29.78.2 (202.29.78.2)
from 202.29.78.12 : 56(84) bytes of data. From 202.29.78.12 icmp_seq=1
Destination Host Unreachable From 202.29.78.12 icmp_seq=2 Destination
Host Unreachable From 202.29.78.12 icmp_seq=3 Destination Host Unreachable
-------------------------------------------------------------------------------1.17
env : environment
-------------------------------------------------------------------------------
env
HISTSIZE=1000
SSH_CLIENT=202.29.78.100 1091 22
OLDPWD=/usr/sbin
QTDIR=/usr/lib/qt3-gcc3.2
SSH_TTY=/dev/pts/0
USER=burin
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;.... :
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
MAIL=/var/spool/mail/burin
PWD=/etc
INPUTRC=/etc/inputrc
LANG=en_US.UTF-8
HOME=/root
SHLVL=2
LOGNAME=burin
LESSOPEN=|/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env
-------------------------------------------------------------------------------1.18
-------------------------------------------------------------------------------
lynx www.thaiall.com :: www.thaiall.com text mode
lynx http://www.yonok.ac.th :: www.yonok.ac.th text mode
lynx -dump http://www.yonok.ac.th :: interactive view
lynx -dump -width=500 http://piology.org/.procmailrc.html|grep '^|'|cut -c3- ::
-------------------------------------------------------------------------------1.19
------------------------------------------------------------------------------- Redhat dig host host yn1.yonok.ac.th dig yn1.yonok.ac.th nslookup exit >
nslookup 202.28.18.65
Non-authoritative answer:
65.18.28.202.in-addr.arpa name = mars.uni.net.th.
Authoritative answers can be found from:
18.28.202.in-addr.arpa nameserver = mars.uni.net.th.
18.28.202.in-addr.arpa nameserver = ns.netserv.chula.ac.th.
mars.uni.net.th internet address = 202.28.18.65
nslookup www.thaiall.com
Name: www.thaiall.com
Address: 66.150.1.141
-------------------------------------------------------------------------------1.20
tail : cat
-------------------------------------------------------------------------------
tail index.html :: index.html Current directory
tail --lines=5 /var/log/messages :: /var/log/messages
root
tail /var/log/html/access.log :: 10 default
tail --lines=100 /var/log/html/access_log > access_bak :: backup
mv
-------------------------------------------------------------------------------1.21
-------------------------------------------------------------------------------
telnet 202.202.202.202 :: 202.202.202.202 port port 23
telnet www.school.net.th 21 :: port 21 FTP port
telnet mail.loxinfo.co.th 25 :: smtp
telnet class.yonok.ac.th 110 :: pop service windows server 2003 Microsoft Windows POP3 Service Version 1.0 ready. USER aa@class.yonok.ac.th +OK PASS xxxxxxx +OK User successfully logged on
-------------------------------------------------------------------------------2.1
df : Harddisk
/dev/hda3
1423096 41956 1308848 4% /home
none
30740
0 30740 0% /dev/shm
/dev/hda2
3889924 1551872 2140456 43% /usr
/dev/hda6
1027768 952876 22684 98% /var
-------------------------------------------------------------------------------2.2
du : directory
------------------------------------------------------------------------------- directory
du :: directory
du -all :: directory
du | sort -g ::
directory sort Kb
du -b :: byte directory
-------------------------------------------------------------------------------2.3
ps : Process
ps -ef :: process
ps -ax :: process
ps -aux :: process
-------------------------------------------------------------------------------2.4
kill : process
process kill process
find : directory
-------------------------------------------------------------------------------
find / -name hello.pl ::
hello.pl directory
find / -name hello* :: hello
find /bin -size 626188c ::
626188 RH8 bash
-------------------------------------------------------------------------------2.6
-------------------------------------------------------------------------------
gzip -d x.tar.gz ::
gz
man gzip :: gzip
gzip -d radius-1.16.1.tar.Z :: ftp.livingston.com/pub/le/radius/
gzip -dc x.tar.Z|tar xvf - ::
2 gzip tar x.tar.z
-------------------------------------------------------------------------------2.7
tar : tar
-------------------------------------------------------------------------------
tar xvf x.tar :: tar directory
tar xvfz squid-2.3-200103110000-src.tar.gz :: gz tar
gzip tar
man tar :: tar
tar zcvf abc.tar.gz /etc :: copy /etc abc.tar.gz
tar zxvf abc.tar.gz :: abc.tar.gz directory /etc
-------------------------------------------------------------------------------2.8
last : login
-------------------------------------------------------------------------------
last |grep reboot :: reboot
last |more :: login
-------------------------------------------------------------------------------2.9
grep :
-------------------------------------------------------------------------------
more /etc/passwd|grep thaiall :: /etc/passwd thaiall
rpm -qa|grep ftp :: ftp
last |grep reboot :: reboot
-------------------------------------------------------------------------------2.10
-------------------------------------------------------------------------------
date +%x :: 04/27/01
date +%d :: 27
date 04271340 :: 27 4 13.40 . (mmddhhmmccyy)
hwclock --systohc :: date restart hardware clock hardware
-------------------------------------------------------------------------------2.11
top :
-------------------------------------------------------------------------------
top :: process Redhat 8.0
CPU states: 0.5% user, 1.3% system, 0.0% nice, 98.0% idle
Mem: 31328K av, 28872K used, 2456K free,
0K shrd, 1032K buff
Swap: 1718912K av, 2608K used, 1716304K free
16528K cached
PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
18306 root
14 0 852 852 672 R
0 1.5 2.7 0:00 top
18229 root
1 0 1684 1536 1240 S
0 0.3 4.9 0:00 sshd
1 root
0 0 160 116 92 S
0 0.0 0.3 0:08 init
2 root
0 0 0 0 0 SW
0 0.0 0.0 0:01 kflushd
-------------------------------------------------------------------------------2.12
ntsysv
setup : -
-------------------------------------------------------------------------------
setup :: system services server httpd, imap, ipop3, iptables, named, network, sendmail, servers, services, vsftpd, xinetd web, mail, ftp dns
ntsysv :: - setup, services ( RH )
-------------------------------------------------------------------------------2.13
route :
-------------------------------------------------------------------------------
# route
Kernel IP routing table
Destination Gateway
Genmask
Flags Metric Ref Use Iface
202.29.78.0 *
255.255.255.0 U 0
0
0 eth0
127.0.0.0
*
255.0.0.0
U 0
0
0 lo
default
202.29.78.254 0.0.0.0
UG 0
0
0 eth0
--------------------------------------------------------------------------------
2.14
shutdown, reboot :
-------------------------------------------------------------------------------
shutdown -h now halt :: ( 1 )
reboot shutdown -r now :: clear
-------------------------------------------------------------------------------2.15
runlevel :
/etc/inittab level : level chkconfig 2.18
-------------------------------------------------------------------------------
#/sbin/runlevel :: level
#cat /etc/inittab :: level
-------------------------------------------------------------------------------2.16
fsck : linux
-------------------------------------------------------------------------------
#fsck / :: harddisk / harddisk
#fsck /dev/hdc :: harddisk
/dev/hdc harddisk
-------------------------------------------------------------------------------2.17
chown, chgrp :
chkconfig : level