Routed AP(openWrt)

12
Configuration
The changes below assume an OpenWrt default configuration, the relevant files are:
·         /etc/config/network
·         /etc/config/wireless
·         /etc/config/dhcp
·         /etc/config/firewall
Edit /etc/config/network and define a new interface section:
config 'interface' 'wifi'
        option 'proto'      'static'
        option 'ipaddr'     '192.168.2.1'
        option 'netmask'    '255.255.255.0'
Note that no ifname option is set here, it is not required since the wireless network will reference this section later.
http://wiki.openwrt.org/_media/meta/48px-dialog-warning.svg.png
Make sure that the chosen IP address is in a different subnet than the one used by the lan interface.
In /etc/config/wireless, locate the existing wifi-iface section and change its network option to point to the newly created interface section.
config 'wifi-iface'
        option 'device'     'wl0'
        option 'network'    'wifi'
        option 'mode'       'ap'
        option 'ssid'       'OpenWrt'
        option 'encryption' 'none'
In the existing section, network was changed to point to the wifi interface defined in the previous step.
Optionally change the last line for option encryption 'psk2' and add the line option key 'secret key' to enable WPA encryption
Since wireless is not bridged to LAN anymore, no DHCP leases are served to wireless clients yet. In order to support DHCP on wireless as well, a new dhcp pool must be defined in /etc/config/dhcp:
config 'dhcp' 'wifi'
        option 'interface'  'wifi'
        option 'start'      '100'
        option 'limit'      '150'
        option 'leasetime'  '12h'

By default, traffic originating from the wireless network is not allowed to reach the WAN or the LAN interface. There is also no firewall zone defined for it yet, so only the default policies apply to the wireless network.
Edit /etc/config/firewall and add new zone section covering the wifi interface:
config 'zone'
        option 'name'       'wifi'
        option 'input'      'ACCEPT'
        option 'output'     'ACCEPT'
        option 'forward'    'REJECT'
Now that the zone is defined, traffic forwarding control for the wireless network can be implemented. To allow wireless clients to use the WAN interface, add the following forwarding section:
config 'forwarding'
        option 'src'        'wifi'
        option 'dest'       'wan'
If LAN clients should be able to contact wireless clients, add the following forwarding:
config 'forwarding'
        option 'src'        'lan'
        option 'dest'       'wifi'
To allow wireless clients to reach the LAN network, add the reversed rule below as well:
config 'forwarding'
        option 'src'        'wifi'
        option 'dest'       'lan'
1.    Enable the new wireless network
2.  ifup wifi
wifi
3.    Restart the firewall
/etc/init.d/firewall restart
4.    Restart the DHCP service
/etc/init.d/dnsmasq restart


سحب وتنزيل موقع باستخدام الأمر wget


Wget هي أداة – أمر – متوفرة على أنظمة GNU/Linux لتنزيل الملفات من على الوب تدعم بروتوكولات HTTP، HTTPS، و FTP. كما أن بإمكانها إيجاد وتنزيل ملفات عبر وسيط (بروكسي) HTTP .
من الميزات المهمة التي تُوفرها هذه الأداة:
  • استكمال التنزيل إذا كان الخادم يدعم ذلك.
  • مصممة لتتكيف مع الاتصالات الضعيفة وغير الثابتة، ففي حالة فشل التنزيل بسبب مشكلة في الاتصال، فإنها تستمر في إعادة المحاولة حتى اكتمال التنزيل.
  • تتبع روابط صفحات HTML ، XHTML و CSS لإنشاء نسخة محلية يمكن تصفحها دون الحاجة للاتصال بالشبكة. (أو ما يعرف بالتنزيل التكراري – Recursive Download – حيث لا يقتصر الأمر على تنزيل ملف صفحة ويب فقط بل كل الملفات التي تشير إليها هذه الصفحة، مثل الصور والسكريبتات، من أجل عرضها كما لو كنتَ تتصفح موقع ويب).

استعمال الأداة

ينفذ الأمر wget بالطريقة التالية
wget [option] … [URL]…
حيث
  • option تمثل خيار أو خيارات الأمر.
  • URL رابط أو روابط التحمبل (يمكن أيضا كما سنرى استبدال رابط التنزيل بملف يحوي مجموعة من الروابط لتنزيل الملفات التي تشير إليها تلك الراوبط).
  • عادة الأقواس المعكوفة مستخدمة بكثرة خصوصا في مجتمع لينكس للإشارة إلى أنه ليس ضروريا إعطاء كل الخيارات،
سنتطرق في الفقرات التالية لأهم خيار ات الأمر wget إذ ليس بالإمكان عرضها كلها. لمعرفة المزيد من الخيارات يمكن ذلك عن طريق مطالعة دليل لينكس عبر إدخال الأمر man wget في الطرفية أو عن طريق مطالعة هذه الصفحة (اللغة الانجليزية هي المستخدمة في كلتا الحالتين).

أهم خيارات الأمر wget

تتوفر الخيارات بنسختين (كمعظم الخيارات في أوامر لينكس)، طويلة وضعتُها بين قوسين (الخيارات الطويلة تكون ميبوقة بشرطتين “–”) و قصيرة. استخدام أي من النسختين ينتج عنه نفس المفعول.
الخيار r- ( أو recursive–) : تفعيل تتبع الروابط.
عند استخدام هذا الخيار فإن الأمر يتتبع الروابط حتى المستوى المنصوص عليه في الإعدادات الافتراضية (وهو المستوى الخامس) ابتداءً من رابط الصفحة المعطى في الأمر.
لشرح ما أعنيه بالمستوى، دعوني آخذ المثال التالي:
لو افترضنا أن هذه المدونة تحوي صفحة باسم “أوامر لينكس” يمكن الوصول إليها عبر صفحة باسم “لينكس” يوجد لها رابط على الصفحة “الرئيسية” ، فإن الصفحة “أوامر لينكس” توجد في المستوى الثالث بالنسبة للصفحة الرئيسية “الرئيسية (المستو الأول) >> لينكس (الثاني) >> أوامر لينكس (الثالث)” . يمكن استخدام الخيار l- (أو level– ) لتحديد المستوى الذي يصل إليه التنزيل.
مثال: الأمر التالي يقوم بتنزيل جميع الملفات الموجودة في هذه المدونة حتى المستوى الثالث (الخيار l3- أو level=3– )
wget -r -l3 zeine77.wordpress.com
الخيار k- ( أو convert-links– ) : التحويل إلى روابط محلية
من الخيارات المهمة جدا، إذ يقوم بتحويل الروابط المجودة على صفحة وب لروابط محلية تمكن من تصفح الموقع المُحمل مِن على الجهاز لديك دون الحاجة للاتصال بالشبكة. يستخدم الخيار بالشكل التالي
حيث http://www.exemple.com هو عنوان الصفحة المُراد تنزيلها. طبعا يمكننا إضافته للأمر السابق لتنزيل ملفات موقع ما وجعلها قابلة للتصفح محليا.
wget -k -r -l3 zeine77.wordpress.com
الخيار p- ( أو page-requisites–) : تنزيل متعلقات صفحة
يوجه الأمر wget لتنزيل كل الملفات التي تحتاجها صفحة الوب ليتم عرضها دون الحاجة للاتصال بالشبكة.
لنأخذ مثال التدوينة السابقة، حيث توجد صورة توضح إصدارات جافا وكيفية تنزيلها. عند تطبيق الأمر wget على عنوان التدوينة المذكورة دون استخدام الخيار p- فلن يتم تنزيل الصورة مما يعني أنك لن تستطيع رؤيتها على النسخة المحلية. استخدام الخيار p- يمكن من التغلب على هذا الأمر. في حالة تفعيل تتبع الروابط (الخيار r- ) دون استخدام p- فإن الملفات – صور وغيرها – التي تحتاجها صفحات المستوى الأخير (المستوى الثالث في المثال الأول) لن يتم تنزيلها.
الخيار np- ( أو no-parent– ) : قصر التنزيل على المجلدات الفرعية
يستخدم مع الخيار r- لمنع تنزيل صفحات من مستوى أعلى من مستوى الصفحة المعطاة في العنوان. مثلا بإمكانك استخدام هذا الخيار لتنزيل قسم من موقع دون الاضطرار لتنزيل الموقع بكامله.

تنزيل موقع بالكامل باستخدام wget

بدمج الخيارات أعلاه يمكننا تنزيل موقع وتصفحه محليا من على الجهاز كما لو كنت تتصفحه عبر الشبكة عن طريق الأمر التالي:
wget -r -k -np -p http://www.site.com
r- لتتبع الروابط (التنزيل التكراري – Recursive Download)
k- لتحويل الروابط لروابط محلية
np- للتأكد من تنزيل الصفحات التي نريدها فقط وليس صفحات مستوى أعلى (في حالة موقع به العديد من الأقسام أو المواقع التي تستخدم اسمَ نطاق مشترك كهذه المدونة)
p- لتنزيل الملفات التي تحتاجها صفحات المستوى الأخير.
حسب رأيي الخيارات أعلاه هي الأساسية لأمر wget . أدناه سأذكر بشكل سريع بعض الخيارات الأخرى التي قد تكون مفيدة.

خيارات أخرى

الخيار b- ( أو background –) : التشغيل في الخلفية.
تشغيل الأمر في الخلفية، بإمكانك مثلا الدخول على النظام باسم مستخدم “محمد”، تشغيل تنزيل موقع في الخلفية عن طريق هذا الخيار، قفل الجلسة (session) ثم الدخول باسم مستخدم ثان “أحمد” دون انقطاع التنزيل الذي شغله المستخدم الأول “محمد”.
الخيار c- ( أو continue– ) : استكمال التنزيل.
استكمال تنزيل ملف حتى ولو لم تكن استخدمت wget لبدأ التنزيل (بدأتَ التنزيل عن طريق المتصفح مثلا ثم انقطع التنزيل لسبب أو آخر)
الخيار i- (أو input– ) : تنزيل روابط موجودة في ملف .
يستخدم هكذا wget -i file أو wget –input=file فيقوم بقراءة روابط المواقع أو الصفحات المُراد تنزيلها من ملف (file هنا تمثل المسار الذي يوجد عليه الملف، في الملف كل سطر يحوي رابطا واحدا ) ثم تنزيلها واحدا تلو الآخر.

اوامر ضغط وفك ضغط الملفات tar&zip


هده اوامر ضغط زفك ضغط الملفات
يمكن عمل تلك الشغلات بدون طرفية اي من خلال الواجهة الرسومية
لكن من الطرفية يكون اسرع واضبط + سوف تحتاجها عند التعامل مع السرفرات او من خلال الشل الخ
أمر الضغط بامتداد zip
qzip failname
امر فك الضغط بامتداد zip

unzip failname


أمر الضغط بامتداد tar


tar -zcf zz.tar daily
أمر فك الضغط بامتداد tar


tar -zxf zz.tar
أمر ضغط الملف بامتداد gz


tar -czvf file name.tar.gz file name.sql
فك الضغط بامتداد gz


gzip -d file.gz
كيفية ضغط قاعدة البيانات
tar -czvf file name.tar.gz file name.sql
كيفية فك قواعد البيانات
tar -zxvf file name.tar.gz


chown&chmod command

About chown
Command for system V that changes the owner of a file.
Syntax
chown [-R] newowner filenames
-R
Change the permission on files that are in the subdirectories of the directory that you are currently in.
newowner
The alias/username of the new owner of the file.
filenames
The file that you are changing the rights to.
Examples
#chown chope file.txt
Give permissions as owner to user chope for the file file.txt.
#chown -R chope work
Give chown permissions to chope for all files in the work directory.
--------------------------------------------------------------------------------
About chmod
Changes the permission of a file.

Syntax
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...
-c, --changes
like verbose but report only when a change is made
--no-preserve-root
do not treat `/' specially (the default)
--preserve-root
fail to operate recursively on `/'
-f, --silent, --quiet
suppress most error messages
-v, verbose
output a diagnostic for every file processed
--reference=RFILE
use RFILE's mode instead of MODE values
-R, --recursive
change files and directories recursively
--help
display this help and exit
--version
output version information and exit
Permissions
u - User who owns the file.
g - Group that owns the file.
o - Other.
a - All.
r - Read the file.
w - Write or edit the file.
x - Execute or run the file as a program.
Numeric Permissions:
CHMOD can also to attributed by using Numeric Permissions:
400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody
Examples
The above numeric permissions can be added to set a certain permission, for example, a common HTML file on a Unix or Linux server accessible over the Internet would be given the below permissions.
#chmod 644 file.htm
This gives the file read/write by the owner and only read by everyone else (-rw-r--r--).
Files such as scripts that need to be executed need more permissions. Below is another example of a common permission given to scripts.
#chmod 755 file.cgi
This would be the following 400+040+004+200+100+010+001 = 755 where you are giving all the rights except the capability for anyone to write to the file.cgi file(-rwxr-xr-x).
#chmod 666 file.txt
Finally, another common CHMOD permission is 666, as shown below, which is read and write by everyone.
Tip: The above commands are all done through the command line. However, if you upload a file using FTPthese permissions can also be adjusted through many FTP clients by right-clicking the file and choosing permissions.
Additional information
Below is an example of how a file may be listed when typing ( ls -l ) at the prompt as well as information on how to interpret it.
-rw-rw-r-- 1   hope 123   Feb 03 15:36   file.txt
-
rw
rw-
r--
1
hope
123
Feb 03 15:36
file.txt
File
owner
group
everyone else
links
owner
size
mod date
file name