Find content in files
============
find ./ -name "*.c" | xargs grep TEXT
ln
==
# Symbolic Link is very similar to what we know from Windows - a shortcut.
ln -s [full path to source directory] [target]
# Hardlink cannot be created for directories (folders).
Ref: http://www.maxi-pedia.com/difference+between+symbolic+link+and+hard+link
useradd
========
The options which apply to the useradd command are:
-g (primary group assigned to the users)
-s starting program (shell)
-p password
-d home directory
-m (Create the user's home directory
useradd -gusers -s/bin/bash -pshutdown -d/home/shutdown -m shutdown
passwd shutdown
usermod -a -G sudo shutdown
Set Console Font
=============
setfont /usr/share/consolefonts/Uni1-VGA8.psf.gz
tar zcvpf backup.tar.gz directory-name/
tar บนลีนุกซ์ สามารถระบุออปชั่น z เพื่อบีบขนาดของไฟล์ได้เลย
extract
tar xvzf abc.tgz
$ sudo update-java-alternatives -s java-6-sun
$ JAVA_HOME="/usr/lib/jvm/java-6-sun"
$ export JAVA_HOME
Change console language in Debian
==================================
enter 'sudo dpkg-reconfigure locales' to set the default locale for the system environment
force check disk linux on the next reboot
==========================
sudo touch /forcefsck
Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts
Saturday, October 1, 2011
Tuesday, July 26, 2011
Display GUI from other source on localhost
จาก user อื่นที่เรา su ไป
====================
เจอ error ประมาณนี้
.... : Gtk-WARNING **: cannot open display: ...
ให้ run คำสั่ง "xhost +"
เพื่อ "access control disabled, clients can connect from any host"
จะ enable อีกครั้งก็ "xhost -"
access control enabled, only authorized clients can connect
จาก remote host ที่ connect ด้วย ssh
================================
ssh -p 2222 -X username@remote-host
X = Enables X11 forwarding.
p = port
====================
เจอ error ประมาณนี้
.... : Gtk-WARNING **: cannot open display: ...
ให้ run คำสั่ง "xhost +"
เพื่อ "access control disabled, clients can connect from any host"
จะ enable อีกครั้งก็ "xhost -"
access control enabled, only authorized clients can connect
จาก remote host ที่ connect ด้วย ssh
================================
ssh -p 2222 -X username@remote-host
X = Enables X11 forwarding.
p = port
Labels:
unix
Saturday, July 16, 2011
IP Addr and Internet Name - Part 1 Commands
cat /etc/resolv.conf
BIND
====
BIND is an acronym for the Berkeley Internet Name Domain project,
which is a group that maintains the DNS-related software suite that runs under Linux.
The most well known program in BIND is named, the daemon that responds to DNS queries from remote machines.
ref: http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch18_:_Configuring_DNS
The Host Command
=================
The host command accepts arguments that are either the fully qualified domain name
or the IP address of the server when providing results. To perform a forward lookup,
use the syntax:
[root@bigboy tmp]# host www.linuxhomenetworking.com
www.linuxhomenetworking.com has address 65.115.71.34
The nslookup Command
=====================
The nslookup command provides the same results on Windows PCs. To perform forward lookup, use.
sudo apt-get install dnsutils
s@penguin:~$ nslookup portal.trueinternet.co.th
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
Name: portal.trueinternet.co.th
Address: 61.91.230.178
authoritative = ซึ่งเชื่อถือได้
dig
====
dig {domain.to.lookup}
>> look in /etc/resolv.conf file and querying the DNS servers listed there.
s@penguin:~$ dig portal.trueinternet.co.th +nocmd +nostats +noquestion
; <<>> DiG 9.7.3 <<>> portal.trueinternet.co.th +nocmd +nostats +noquestion
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47978 ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; ANSWER SECTION: portal.trueinternet.co.th. 531 IN A 61.91.230.178 s@penguin:~$ dig portal.trueinternet.co.th ; <<>> DiG 9.7.3 <<>> portal.trueinternet.co.th
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27376
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;portal.trueinternet.co.th. IN A
;; ANSWER SECTION:
portal.trueinternet.co.th. 243 IN A 61.91.230.178
;; Query time: 4 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Thu May 26 09:25:52 2011
;; MSG SIZE rcvd: 59
Lines beginning with ; are comments that are not part of the information received from the DNS server
the RA flag shows that recursive queries are available.
The IN means this is an Internet lookup (in the Internet class).
The A record stores the host IP address.
The CNAME is an alias record, which is used to give multiple aliases to a single computer.
The MX record is the mail exchange record, which tells mail servers how to route email for this domain.
* to query other DNS servers
dig @ns.hosteurope.com www.hungrypenguin.net
Ref: http://www.linux.com/learn/tutorials/442431-check-your-dns-records-with-dig
List open ports and listening services
$ netstat -an
# -n : to get port numbers instead of having the utility try to provide names for services
$ netstat -lnptu
$ sudo apt-get install nmap
$ nmap localhost
$ sudo apt-get install sockstat
$ sockstat
then
$ grep -w 631 /etc/services
Fix IP
=======
sudo vi /etc/network/interfaces
replace
allow-hotplug eth0
iface eth0 inet dhcp
with
auto eth0
iface eth0 inet static
address 192.168.1.36
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
sudo ifconfig eth1 192.168.2.3 netmask 255.255.255.0
sudo route add default gw 192.168.2.1 eth1
more info: http://www.cyberciti.biz/faq/setting-up-an-network-interfaces-file/
BIND
====
BIND is an acronym for the Berkeley Internet Name Domain project,
which is a group that maintains the DNS-related software suite that runs under Linux.
The most well known program in BIND is named, the daemon that responds to DNS queries from remote machines.
ref: http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch18_:_Configuring_DNS
The Host Command
=================
The host command accepts arguments that are either the fully qualified domain name
or the IP address of the server when providing results. To perform a forward lookup,
use the syntax:
[root@bigboy tmp]# host www.linuxhomenetworking.com
www.linuxhomenetworking.com has address 65.115.71.34
The nslookup Command
=====================
The nslookup command provides the same results on Windows PCs. To perform forward lookup, use.
sudo apt-get install dnsutils
s@penguin:~$ nslookup portal.trueinternet.co.th
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
Name: portal.trueinternet.co.th
Address: 61.91.230.178
authoritative = ซึ่งเชื่อถือได้
dig
====
dig {domain.to.lookup}
>> look in /etc/resolv.conf file and querying the DNS servers listed there.
s@penguin:~$ dig portal.trueinternet.co.th +nocmd +nostats +noquestion
; <<>> DiG 9.7.3 <<>> portal.trueinternet.co.th +nocmd +nostats +noquestion
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47978 ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; ANSWER SECTION: portal.trueinternet.co.th. 531 IN A 61.91.230.178 s@penguin:~$ dig portal.trueinternet.co.th ; <<>> DiG 9.7.3 <<>> portal.trueinternet.co.th
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27376
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;portal.trueinternet.co.th. IN A
;; ANSWER SECTION:
portal.trueinternet.co.th. 243 IN A 61.91.230.178
;; Query time: 4 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Thu May 26 09:25:52 2011
;; MSG SIZE rcvd: 59
Lines beginning with ; are comments that are not part of the information received from the DNS server
the RA flag shows that recursive queries are available.
The IN means this is an Internet lookup (in the Internet class).
The A record stores the host IP address.
The CNAME is an alias record, which is used to give multiple aliases to a single computer.
The MX record is the mail exchange record, which tells mail servers how to route email for this domain.
* to query other DNS servers
dig @ns.hosteurope.com www.hungrypenguin.net
Ref: http://www.linux.com/learn/tutorials/442431-check-your-dns-records-with-dig
List open ports and listening services
$ netstat -an
# -n : to get port numbers instead of having the utility try to provide names for services
$ netstat -lnptu
$ sudo apt-get install nmap
$ nmap localhost
$ sudo apt-get install sockstat
$ sockstat
then
$ grep -w 631 /etc/services
Fix IP
=======
sudo vi /etc/network/interfaces
replace
allow-hotplug eth0
iface eth0 inet dhcp
with
auto eth0
iface eth0 inet static
address 192.168.1.36
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
sudo ifconfig eth1 192.168.2.3 netmask 255.255.255.0
sudo route add default gw 192.168.2.1 eth1
more info: http://www.cyberciti.biz/faq/setting-up-an-network-interfaces-file/
Wednesday, September 23, 2009
Briefcase on Unix
โปรแกรม my briefcase บน M$ Window$
ทำ two-way synchronize Files หรือ Folder ได้
คือ ไม่ว่าจะมีการแก้ไขไฟล์ที่ฝั่งใด เมื่อให้มันทำการ check
มันก็จะแจ้ง และให้ผู้ใช้เลือกได้ว่าจะทำ action ใด
เช่น update ให้สองฝั่งเท่ากัน หรือ skip เป็นต้น
โปรแกรมบน unix ที่ทำงานเหมือนกัน
มีตัวนึงชื่อ Unison
แต่โดย Default จะ check content ภายในไฟล์ด้วย
จะให้มัน fast check คือ check แค่ size กับ modified date
ทำได้โดย
แก้ไข Profile (เช่น /home/{username}/.unison/default.prf)
เพิ่ม fastcheck = true
เช่น
root = /data/directory1
root = /mnt/directory1
perms = 0
fastcheck = true
perms = 0 เป็นการกำหนดให้ unison ไม่ต้อง sync Permission
แก้ error เวลา sync จาก ext3 กับ ntfs ได้ด้วย
เพิ่มเติม http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html
OS: ubuntu 9.04
สิริพงษ์ พงศ์ภิญโญภาพ
ทำ two-way synchronize Files หรือ Folder ได้
คือ ไม่ว่าจะมีการแก้ไขไฟล์ที่ฝั่งใด เมื่อให้มันทำการ check
มันก็จะแจ้ง และให้ผู้ใช้เลือกได้ว่าจะทำ action ใด
เช่น update ให้สองฝั่งเท่ากัน หรือ skip เป็นต้น
โปรแกรมบน unix ที่ทำงานเหมือนกัน
มีตัวนึงชื่อ Unison
แต่โดย Default จะ check content ภายในไฟล์ด้วย
จะให้มัน fast check คือ check แค่ size กับ modified date
ทำได้โดย
แก้ไข Profile (เช่น /home/{username}/.unison/default.prf)
เพิ่ม fastcheck = true
เช่น
root = /data/directory1
root = /mnt/directory1
perms = 0
fastcheck = true
perms = 0 เป็นการกำหนดให้ unison ไม่ต้อง sync Permission
แก้ error เวลา sync จาก ext3 กับ ntfs ได้ด้วย
เพิ่มเติม http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html
OS: ubuntu 9.04
สิริพงษ์ พงศ์ภิญโญภาพ
Subscribe to:
Comments (Atom)