زکات علم

زَکاةُ العِلمِ أن تُعَلِّمَهُ عِبادَ اللّه‏ِ امام باقر (ع)
زکات علم

مطالبی در زمینه کامپیوتر و علاقه مندی های شخصی من مطالب این وبلاگ غالبا مطالبی ست که در جای جای اینترنت کتاب یا دانشته های شخصی خودم می باشد که به عنوان مرجعی برای رجوع دوباره در اینجا جمع آوری شده اند .
ehsunitd.ir personal website

پیوندها
هک کلمه ای است با معنایی بسیار گسترده. رسانه‌ها دوست دارند آن را یک چیز وحشتناک معرفی کنند که توسط آدم های باسواد و معمولا دارای نیت منفی استفاده می شود و کسانی که چندان از ماجرا سر در نمی آورند فکر می کنند هکر یک موجود خطرناک و بدذات است که اگر بخواهد می تواند به هر اطلاعاتی دسترسی پیدا کند.

هک کردن در دنیای امنیت کامپیوتر، به معنی پیدا کردن نقاط ضعف امنیتی یک سیستم و استفاده از آن برای نفوذ به آن سیستم است. عقیده عمومی این است که انجام اینکار نیاز به سواد کامپیوتری بالا دارد ولی واقعیت امر تا حدی متفاوت است. یک هکر ممکن است با داشتن سواد خیلی خیلی بالا بتواند چیزهایی را در سیستم ها کشف کند که پیش از این توسط دیگران دیده نشده ولی در اکثر موارد چنین هکری سوادش را صرف دزدیدن اطلاعات نمی کند. کسانی که به سراغ دزدی اطلاعات می‌روند (که سود مالی و اعتباری کمی هم دارد) معمولا کسانی با سواد بسیار کمتر هستند که از ابزارهایی که نفر اول ساخته، استفاده می کنند. خود هکرهای حوزه امنیت کامپیوتری برای تفکیک کردن این گونه‌ها از یکدیگر، از اصطلاحات مختلفی استفاده می کنند که در اینجا با هم نگاه سریعی به آن می اندازیم. البته پیش از آن لازم به ذکر است که برای برخی از هکرهای واقعی (از جمله اریک ریموند) کلمه هکر کلمه‌ای ارزشمند است که اطلاق آن به دزد اطلاعات، درست نیست. این افراد اصرار دارند که برای اشاره به کسانی که بدون سواد فقط به دنبال دزدیدن اطلاعات دیگر یا آزار بقیه هستند باید کرکر نامیده شوند.

هکر کلاه سفید
هکرهای کلاه سفید، کسانی هستند که به سیستم ها نفوذ می کنند اما بدون نیت بد. دلیل کار آن‌ها معمولا بررسی امنیت سیستم ها است - چیزی که در جامعه امنیت کامپیوتری به آن تست نفوذ می گویند. این افراد ممکن است با شرکت های قراردادی برای کشف نقاط ضعف سیستم آن‌ها ببیندند و تلاش کنند تا با رعایت کلیه اصول «هک اخلاقی» به سیستم آن‌ها نفوذ کنند. شاید برایتان جالب باشد بدانید که این تلاش برای نفوذ محدود به اینترنت نیست و ممکن است آن‌ها سعی کنند با تلفن زدن به یکی از کارمندان و جا زدن خود به جای رییس شرکت، پسوردهایی را به دست بیاورند یا حتی طناب و قلاب در دست بگیرند و شبانه سعی کنند به سرورهای دسترسی فیزیکی پیدا کنند. در دنیای امنیت داشتن دسترسی فیزیکی به یک سرور برابر داشتن تمام احتیارات روی آن سرور است.

هکر کلاه سیاه
هکر کلاه سیاه در مقابل هکر کلاه سفید قرار دارد و کسی است که برای سود شخصی یا نیت‌های غیراخلاقی دست به نفوذ به سیستم‌ها می‌زند. این همان شخصیتی است که معمولا در فیلم‌های هالیوودی و رسانه‌ها از هکر به نمایش گذاشته می‌شود. معمولا بخش بزرگی از این نفوذ وابسته به اشتباهات انسانی کاربران است. مثلا انتخاب سال تولد یا شماره تلفن به عنوان پسورد دعوت یک هکر کلاه سیاه است به نفوذ به یک سیستم. دوران طلایی این هکرها دهه هشتاد میلادی بود که سیستم‌های کامپیوتری تازه در حال گسترش بودند اما امروزه اقتصاددان‌ها تخمین می‌زنند دیگر کسی نمی‌تواند از این راه دارای درآمد قابل قبولی باشد و با پیشرفت سیستم‌های امنیتی، دیر یا زود این افراد دستگیر و دچار مشکلات جدی خواهند شد.

هکر کلاه خاکستری
خاکستری ترکیبی است از سیاه و سفید. یک هکر کلاه خاکستری معمولا چیزی بینابین هکرهای کلاه سیاه و کلاه سفید است. برخی از آن‌ها در اینترنت چرخ می‌زنند و وضعیت امنیتی سایت‌ها و سرورهایی که به آن می‌رسند را چک می‌کنند اما فقط به نیت یاد گرفنت چیزهای جدید یا کنجکاوی‌های فنی. این افراد گاهی با کشف یک مشکل، آن را به مدیران سیستم مورد بررسی اطلاع می‌دهند و حتی گاهی پیشنهاد همکاری برای حل مشکل را نیز با این گزارش همراه می‌کنند.

هکر نخبه
هکر نخبه یا الیت، هکری است که در بین هکرهای دیگر اعتبار اجتماعی بالایی دارد. این فرد معمولا مشکلات امنیتی تا به امروز ناشناخته را کشف می‌کند و با گزارش آن‌ها ثابت می‌کند که واقعا به چیزی دست پیدا کرده که پیش از این ناشناخته بوده. آپدیت‌های سیستم‌عامل‌ها معمولا محصول کشف و گزارش مشکلات توسط این هکرها هستند.

بچه اسکریپتی
در مقابل یک هکر واقعی، بچه اسکریپتی کسی است که با دانلود و اجرای برنامه‌ها و اسکریپت‌هایی که افراد باسواد نوشته‌اند سایت‌های با امنیت ضعیف و دارای مشکلات ایمنی شناخته شده را پیدا کرده و به آن‌ها نفوذ می‌کند. این بچه‌ها معمولا سواد چندانی ندارند اما دوست دارند هکر به نظر برسند. خطر اصلی که این افراد را تهدید می کند «جلو افتادن از خود» است. آن‌ها می‌توانند صفحه اول یک سایت مشهور که سرورهایش را به روز نکرده را به روز نکرده را با اجرای یک برنامه یا پیروی از چند راهنمای اینترنتی که در دسترس همه هستند عوض کنند و با اینکار در اطرافیان این احساس را به وجود بیاورند که آدم با سوادی هستند و در نتیجه دیگر هیچ وقت فرصت یا جرات پیدا نکنند که مفاهیم شبکه و کامپیوتر و سیستم عامل و ایمنی را از مرحله مقدماتی یاد بگیرند. سر و صدای این آدم‌ها معمولا بیشتر از سوادشان است.

نوب
نوب یا نیوبی یا n00b کسی است که تجربه ای در هک ندارد. یک نوب ممکن است به سمت بچه اسکریپتی شدن سوق پیدا کند و هیچ وقت از هک چیزی نفهمد یا ممکن است با برخورد به جامعه‌ای خوب، شروع به یادگیری مفاهیم از پایه بکند و بعد از مدتی به یک هکر واقعی و حتی یک هکر نخبه تبدیل شود.

هکر کلاه آبی
هکر کلاه آبی کسی است که خارج از یک شرکت مشاوره ایمنی، در نرم افزارها به دنبال باگ‌های امنیتی می‌گردد و آن‌ها را گزارش می‌کند. معمولا شرکت‌ها برنامه‌هایی را که نوشته‌اند برای مدتی در اختیار این افراد می‌گذارند تا مشکلات احتمالی امنیتی آن قبل از عرضه به بازار کشف و حل شود.

هکتیویست
این اصطلاح ترکیبی است از هک و اکتیویسم (فعالیت اجتماعی). هکتیویست‌ها هکرهایی هستند که برای اعلام و تبلیغ عقیده‌شان شروع به هک می‌کنند. هک آن‌ها ممکن است به شیوه یک بچه اسکریپتی و مثلا با هدف تغییر صفحه اول یک سایت دولتی به شعار دلخواه این افراد انجام شود یا واقعا نفوذی باشد به یک سرور به منظور دسترسی به اطلاعات محرمانه یک دولت و انتشار آن به نفع دیگران یا حتی نوشتن یک برنامه برای دادن امکانات به افراد مختلف.
  • ehsan gholami

بسم الله خیرالاسماء

سلام

اگر از ویندوز ۷ استفاده می کنید و پسورد ورود آن را فراموش کرده اید و یا خدایی نکرده قصد دیگری در سر دارید خیلی راحت می شود ویندوز را دور زد و به راحتی وارد ویندوز شد. برای این کار نیاز به هیچ نرم افزار اضافه ای هم ندارید.

این کار در دو مرحله ۱ و ۲ و مرحله اول از دو روش الف وب قابل اجرا می باشد.

۱- الف- پیشگیری (هنگام دسترسی به ویندوز)

اگر فراموشکار هستید و امکان دارد روزی پسورد خود را فراموش کنید (و یا افراد با نیت های شوم الان دسترسی به ادمین کامپیوتر خاصی دارند) بهتر است از فرصت استفاده کنید و با اجرای یک دستور ساده خیال خود را راحت کنید. 

در ویندوز ۷ در منوی استارت و در قسمت سرچ cmd را جستجو نمایید و با راست کلیک بر روی آن Run as administrator را انتخاب کنید. حالا کافیست دستور زیر را کپی کرده و در خط فرمان راست کلیک کرده و گزینه paste را انتخاب نمایید (ctrl+v در این جا paste نمی کند.)

REG ADD “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe” /v Debugger /t REG_SZ /d “C:\windows\system32\cmd.exe”

 

۱- ب- درمان (هنگام دسترسی نداشتن به ویندوز)

اگر قبلا طبق روش الف دستور مورد نظر را اجرا نکرده و الان پسورد خود را فراموش کرده اید (و یا افراد با نیت های شوم قصد نفوذ به ویندوز را دارند) باز هم بدون نیاز به نرم افزار کافی است کامپیوتر را با دی وی دی ویندوز ۷ بوت کرده و مراحل نصب را آغاز نمایید و مطابق تصاویر زیر ادامه دهید:

اگر فایل sethc را دوست دارید! ( و یا افراد خاص می خواهند آب از آب تکان نخورد ) بد نیست که قبل از اجرای دستور اصلی توسط  فرمان زیر یک کپی از sethc تهیه فرمایید.

copy c:\windows\system32\sethc.exe c:\windows\system32\sethc_1.exe

خب حالا کافی است فایل cmd  را با یک دستور ساده جایگزین sethc نمایید. (جالب است بدانید شما در هنگام اجرای ویندوز چنین دسترسی ندارید و ویندوز از این فایل محافظت می نماید)

copy c:\windows\system32\cmd.exe c:\windows\system32\sethc.exe

خب کار تمام شد.

این دستورها (روش الف و ب) چه کار می کند؟!

روش اول با دستکاری رجیستری ویندوز فایل cmd را در رجیستری به جای فایل sethc جایگزین می کند. روش دوم نیز فایل cdm را کلا به جای sethc قرار می دهد. فایل sethc وظیفه تغییر کنتراست را بر عهده دارد و نکته ای که شاید تاکنون نمی دانستید آن است که این فایل در صفحه ورود به ویندوز با کلید های ترکیبی left(alt+ shift)+ printscreen اجرا می شود. همانطور که متوجه شده اید بعد از اجرای دستور بالا خیلی راحت ویندوز را دور زده اید.

حذف پسورد 7

۲- مرحله نهایی (بعد از روش الف و ب)

حالا کافی است در صفحه ورود و هنگام درخواست پسورد توسط ویندوز کلید های ترکیبی left(alt+ shift)+ printscreen را گرفته و در صفحه cmd هر آنچه دوست دارید اجرا نمایید. اگر آشنایی زیادی با خط فرمان ویندوز و دستورات متنی ندارید از دستورات زیر استفاده نمایید:

ساختن یوز جدید مثلا با نام ali و پسورد ۱ :

net user ali 1 /add

تغییر پسورد یوزر administrator به مثلا ۱ :

net user administrator 1 /add 

ورود به دسکتاپ بدون یوزر و پسورد !! :

explorer

یه توضیح ساده این که طبق تجربه گاهی اوقات در تنظیمات گروپ پالیسی ویندوز اینطور تعریف شده است که پسورد باید ترکیبی از حروغ کوچک و بزرگ و عدد و نشانه باشد و با مثلا بیشتر از ۷ حرف انتخاب شود. پس اگر هنگام تعریف کاربر جدید و یا تغییر پسورد یوز موجود اخطاری مشاهده کردید به این دلیل است.

  • ehsan gholami

این ماسک را شاید همه شما بشناسید، ماسک گروه آنونیموس. ولی بعید است عده زیادی بدانند که تاریخچهٔ این نقاب جذاب چیست و از کجا آمده. بنابراین پیش از آنکه به خودِ آنونیموس و فعالیت های آنها در زمینه هک بپردازیم، در بخش اول از این مقاله سه بخشی، داستان جذاب شکل‌گیری این ماسک -به شکلی که امروزه می‌شناسیم- را برای شما تعریف می‌کنیم. 

  • ehsan gholami

اگر شما هم با لپ تاپ خود با یک سیستم عامل لینوکسی به طور مستقیم و بدون ابزار های مجازی سازی کار میکنید . جالب است بدانید همانطور که در ویندوز شما قابلیت سوییچ کردن بین کارت گرافیک اصلی و قدرتمند خود و کارت گرافیک onborad خود در لینوکس هم شما میتوانید با نصب یک پکیج با حجم تقریبی 50 مگ به مدیریت کارت گرافیک خود بپرازید

Description

Nvidia Optimus is an optimization technology created by Nvidia which, depending on the resource load generated by client software applications, will transparently and seamlessly switch between two graphics adapters within a computer system in order to provide either maximum performance or minimum power draw from the system's graphics rendering hardware. From Bumblebee's FAQ: Bumblebee is a effort to make Nvidia Optimus enabled laptops work in GNU/Linux systems. Such feature involves two graphics cards with two different power consumption profiles plugged in a layered way sharing a single framebuffer.

Install Dependencies

su -c "yum install -y libbsd-devel libbsd glibc-devel libX11-devel help2man autoconf git tar glib2 glib2-devel kernel-devel kernel-headers automake gcc gtk2-devel"

You also need to install VirtualGL. Download the latest version for your arch at the VirtualGL download page or use yum command

 yum install VirtualGL 

If you want to run 32 bit apps on your 64 bit system, then also install:

 yum install VirtualGL.i686 

Install Bumblebee

Install the Bumblebee yum repository

Fedora 17

yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee/fedora17/noarch/bumblebee-release-1.0-1.noarch.rpm

Fedora 18

yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee/fedora18/noarch/bumblebee-release-1.0-1.noarch.rpm

Fedora 19

yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee/fedora19/noarch/bumblebee-release-1.0-1.noarch.rpm

Now install Bumblebee:

yum -y install bbswitch bumblebee

Bumblebee with the NVIDIA proprietary drivers

The previous commands install bumbleblee with the nouveau drivers. If you want to install bumblebee with the NVIDIA proprietary drivers you must also follow these instructions:

Install the bumblebee-nonfree repository:

Fedora 17

yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee-nonfree/fedora17/noarch/bumblebee-nonfree-release-1.0-1.noarch.rpm

Fedora 18

yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee-nonfree/fedora18/noarch/bumblebee-nonfree-release-1.0-1.noarch.rpm

Fedora 19

yum -y --nogpgcheck install http://install.linux.ncsu.edu/pub/yum/itecs/public/bumblebee-nonfree/fedora19/noarch/bumblebee-nonfree-release-1.0-1.noarch.rpm

Make sure you have glibc-devel installed because it is needed for bumblebee-nvidia to compile the driver

sudo yum install glibc-devel

Now install bumblebee-nvidia

yum -y install bumblebee-nvidia

"bumblebee-nvidia" is both a rpm package and a shell script. The "bumblebee-nvidia" package contains the shell "wrapper" script, init scripts to run it at bootup, and a SELinux security policy, and lastly a copy of the NVidia Linux binary driver "blob" downloaded from NVidia's UNIX drivers page. This is why the packages are so large compared to the bumblebee package.

Reboot.

Testing Bumblebee

If you want to make sure you have bumblebee up and running, write:

optirun glxgears -info

You should see some gears rotating, and in the terminal you should see "GL_VENDOR = NVIDIA Corporation" or something similar.

Primus

For speed imrovements you can use primus. Primus is a shared library that provides OpenGL and GLX APIs and implements low-overhead local-only client-side OpenGL offloading via GLX forking, similar to VirtualGL. It intercepts GLX calls and redirects GL rendering to a secondary X display, presumably driven by a faster GPU. On swapping buffers, rendered contents are read back using a PBO and copied onto the drawable it was supposed to be rendered on in the first place. Currently primus requires the NVIDIA proprietary drivers.

Install primus:

yum install primus 

If you want to run 32 bit apps on your 64 bit system, then also install:

yum install primus.i686

Testing primus

Open up a terminal and run:

PRIMUS_VERBOSE=2 optirun -b primus glxgears -info

If primus is working properly, you should see "primus: profiling:" messages every so often in the terminal you ran it from.

How to use Bumblebee

General Usage:

optirun [options] <application> [application-parameters]

If you installed primus, then you can use the following command to take advantage of it:

optirun -b primus <application> [application-parameters]

Start Windows applications:

optirun wine <windows application>.exe

with primus:

optirun -b primus wine <windows application>.exe

By default, primus renders up to 60 fps. To render more frames per second:

vblank_mode=0 optirun -b primus <application> [application-parameters]

In practice this will probably only waste power, as most screens do not display more than 60 frames per second.

You can always run "man optirun" for more information.

  • ehsan gholami

Installing GRUB natively

گراب فایلیست همانند فایل boot در ویندوز که به دلیل پاک شدن یا ایجاد مشکل در آن سیستم بالا نمی آید و برای حل مشکل میتوان با rescue mode به داد سیستم رسید در اینجا توضیحی مبنی بر این که به احیای سیستم بپردازیم پرداخته شده است . در بخش اول با تغییر روت سیستم باعت برگرداندن دستورات و مسیر ها میشویم در بخش دوم نصب فایل گراب در ابتدای هارد برای بوت شدن سیستم

بخش اول

red Hat Enterprise Linux 6 – How to restore Grub.
1. Boot from RHEL6 DVD.
2. Select “Rescue installed system”.
3. Choose -> Language, Keyboard, and Rescue Method. Select “Local CD\DVD” for the Rescue Method.
4. Setup Networking -> Yes or No, doesn’t matter for restoring Grub.
5. Next on the “Rescue Screen”, select Continue and OK twice.
6. Next on the “First Aid Kit quickstart menu”, select “shell Start shell”.
The prompt will start:
Starting shell…
bash-4.1#
7. Type: “chroot /mnt/sysimage”
8. Type: “cd /boot/grub”
9. Type: “fdisk -l” to see where hd0.
10. Restore Grub, type: “grub-install /dev/sda1”
If No error, it should display:
# this device map was generated by anaconda
(hd0) /dev/sda
 

بخش دوم

Caution: Installing GRUB's stage1 in this manner will erase the normal boot-sector used by an OS.

GRUB can currently boot GNU Mach, Linux, FreeBSD, NetBSD, and OpenBSD directly, so using it on a boot sector (the first sector of a partition) should be okay. But generally, it would be a good idea to back up the first sector of the partition on which you are installing GRUB's stage1. This isn't as important if you are installing GRUB on the first sector of a hard disk, since it's easy to reinitialize it (e.g. by running `FDISK /MBR' from DOS).

If you decide to install GRUB in the native environment, which is definitely desirable, you'll need to create a GRUB boot disk, and reboot your computer with it. Otherwise, see Installing GRUB using grub-install.

Once started, GRUB will show the command-line interface (see Command-line interface). First, set the GRUB's root device1 to the partition containing the boot directory, like this:

     grub> root (hd0,0)

If you are not sure which partition actually holds this directory, use the commandfind(see find), like this:

     grub> find /boot/grub/stage1

This will search for the file name/boot/grub/stage1and show the devices which contain the file.

Once you've set the root device correctly, run the commandsetup(see setup):

     grub> setup (hd0)

This command will install the GRUB boot loader on the Master Boot Record (MBR) of the first drive. If you want to put GRUB into the boot sector of a partition instead of putting it in the MBR, specify the partition into which you want to install GRUB:

     grub> setup (hd0,0)

If you install GRUB into a partition or a drive other than the first one, you must chain-load GRUB from another boot loader. Refer to the manual for the boot loader to know how to chain-load GRUB.

After using the setup command, you will boot into GRUB without the GRUB floppy. See the chapter Booting to find out how to boot your operating systems from GRUB.

  • ehsan gholami
Boot failure : No DEFAULT or UI configuration directive found Error
Reason for the Error :

Generally the iso image that are intended to be burned and booted from CD/DVD has all the files required for Boot in the “ISOLINUX” folder. Whereas the iso images that are intended to be run from USB has all the files required for boot in the “SYSLINUX” folder. So when you try to burn and boot a CD/DVD iso from USB, it cannot recognize the type of boot medium as it will not have “syslinux” folder it will simply give “Boot failure : No DEFAULT or UI configuration directive found“.
Solution for the Error :

Open the USB installation media, then rename the following:

isolinux –&gt; syslinux (folder)
isolinux.bin –&gt; syslinux.bin
isolinux.cfg –&gt; syslinux.cfg
  • ehsan gholami

Sparse file

From Wikipedia, the free encyclopedia
A sparse file: The empty bytes don't need to be saved, thus they can be represented by metadata.

In computer science, a sparse file is a type of computer file that attempts to use file system space more efficiently when blocks allocated to the file are mostly empty. This is achieved by writing brief information (metadatarepresenting the empty blocks to disk instead of the actual "empty" space which makes up the block, using less disk space. The full block size is written to disk as the actual size only when the block contains "real" (non-empty) data.

When reading sparse files, the file system transparently converts metadata representing empty blocks into "real" blocks filled with zero bytes at runtime. The application is unaware of this conversion.

Most modern file systems support sparse files, including most Unix variants and NTFS.[1] Apple's HFS+ does not provide for sparse files, but in OS X, the VFS layer supports storing them in any supported file system, including HFS+. Sparse files are commonly used for disk imagesdatabasesnapshots, log files and in scientific applications.

Contents

  • 1 Advantages
  • 2 Disadvantages
  • 3 Sparse files in Unix
    • 3.1 Creation
    • 3.2 Detection
    • 3.3 Copying
    • 3.4 Piping
  • 4 See also
  • 5 References
  • 6 External links

Advantages

The advantage of sparse files is that storage is only allocated when actually needed: disk space is saved, and large files can be created even if there is insufficient free space on the file system. This also reduces the time of the first write as the system doesn't have to allocate blocks for the "skipped" space. Since initial allocation usually requires the system to write all zeros to the space, it also keeps the system from having to write over the "skipped" space twice.

Disadvantages

Disadvantages are that sparse files may become fragmented; file system free space reports may be misleading; filling up file systems containing sparse files can have unexpected effects (such as disk-full or quota-exceeded errors when merely overwriting an existing portion of a file that happened to have been sparse); and copying a sparse file with a program that does not explicitly support them may copy the entire, uncompressed size of the file, including the zero sections which are not allocated on disk—losing the benefits of the sparse property in the file. Sparse files are also not fully supported by all backup software or applications. However, the VFS implementation sidesteps the prior two disadvantages. Loading executables on Windows (exe or dll) which are sparse takes a much longer time, since the file cannot be memory mapped and not cached.

Sparse files in Unix

Sparse files are typically handled transparently to the user. But the differences between a normal file and sparse file become apparent in some situations.

Creation

The Unix command

dd of=sparse-file bs=1k seek=5120 count=0

will create a file of five mebibytes in size, but with no data stored on disk (only metadata). (GNU dd has this behaviour because it calls ftruncate to set the file size; other implementations may merely create an empty file.)

Similarly the truncate command may be used, if available:

truncate -s 5M <filename>

Detection

The -s option of the ls command shows the occupied space in blocks, and -k the apparent size in blocks too:

ls -lks sparse-file

-h can be used to print both in human readable format.

Alternatively, the du command prints the occupied space, while ls prints the apparent size. The option --block-size=1 prints the occupied space in bytes instead of blocks, so that it can be compared to the ls output:

du --block-size=1 sparse-file
ls -l sparse-file

Copying

Normally, the GNU version of cp is good at detecting whether a file is sparse, so

cp sparse-file new-file

creates new-file, which will be sparse. However, GNU cp does have a --sparse=WHEN option.[2] This is especially useful if a file containing long zero blocks is saved in a non-sparse way (i.e. the zero blocks have been written out to disk in full). Disk space can be saved by doing:

cp --sparse=always file1 file1_sparsed

Some cp implementations, like FreeBSD's cp, do not support the --sparse option and will always expand sparse files. A partially viable alternative on those systems is to use rsync with its own--sparse option[3] instead of cp. Unfortunately --sparse cannot be combined with --inplace, so rsyncing huge files across the network will always be wasteful of either network bandwidth or disk bandwidth.[citation needed]

Piping

cat somefile | cp --sparse=always /proc/self/fd/0 new-sparse-file
  • ehsan gholami

در این آموزش شما به صورت گام به گام با روند نصب توزیع محبوب Fedora 17 آشنا خواهید شد.این آموزش بر اساس نصب از روی DVD می باشد،هر چند که نصب از روی CD نیز مشابه می باشد.

نصب هر سیستم عاملی یکسری پیش نیاز ها دارد .برای نصب فدورا در حالت گرافیکی شما حداقل به موارد زیر نیاز خواهید داشت :

- داشتن ۷۶۸ مگابایت RAM یا بیشتر

- داشتن یک CPU Pentium 3  یا بیشتر

-داشتن ۱۰ گیگابایت فضای هارد دیسک یا بیشتر

تهیه دیسک های نصب فدورا :

برای تهیه دیسک های فدورا می توانید آنها را از سایت رسمی دانلود کنید یا اینکه از فروشگاه های اینترنتی sito.ir یا linuxshop.ir آنها را سفارش دهید.

از آنجا که ممکن است کاربرانی به تازگی وارد دنیای گنو-لینوکس شده اند و هنوز از سیستم عامل ماکروسافت استفاده می کنند فرض را بر آن داشتیم که الان روی این کامپیوتر یک نسخه از سیستم عامل ماکروسافت نصب می باشد.

به خاطر اینکه ما به صورت سفارشی روند نصب را انجام می دهیم لازم است قبل از نصب  هارد دیسک خود را پارتیشن بندی کنید. هر چند هنگام نصب هم می شود،ولی بهتر آن است که قبل از نصب اینکار را انجام دهیم.

برای پارتیشن بندی می توانید از ابزارهایی چون GParted که به صورت دیسک زنده و برنامه نصبی می باشد استفاده کنید یا از Parted Magic  استفاده کنید.

پارتیشن بندی که ما انجام دادیم به صورت زیر می باشد :

partition

partition

- پارتیشن C همان پارتیشنی هست که سیستم عامل ماکروسافت ویندوز در آن نصب می باشد

- پارتیشن D همان پارتیشنی می باشد که برنامه های ویندوز در آن می باشد(ممکن است شما علاوه بر این  پارتیشن های ویندوزی دیگری نیز داشته باشید)

- پارتیشن /  یا همان اسلش که فدورا در آن نصب می شود.(حداقل فضا ۱۰ گیگابایت)

- پارتیشن home/  که اطلاعات کاربران فدورا در آن قرار می گیرند.(مقدار فضای آن را بر اساس تعداد کاربران سیستم در نظر بگیرید،مثلا ۱۰ گیگابایت)

- پارتیشن media/Music/ که اطلاعات و فایل ها را در آن ذخیره می کنیم(مقدار فضای آن را بر اساس اطلاعات خود در نظر بگیرید)

- پارتیشن swap( حداکثر ۲ گیگابایت در نظر بگیرید)

اینها پارتیشن هایی بودند که ما در این آموزش در نظر گرفته ایم و ممکن است شما چیزی بیشتر از این پارتیشن ها داشته باشید.در کل روند پارتیشن بندی و نام گذاری آنها به همین صورت می باشد.

نکته اینکه برای نصب فدورا ، پارتیشن های /  و swap ضروری می باشند و سایر پارتیشن ها اختیاری می باشند.

برای شروع دیسک DVD فدورا را درون درایو دیسک خوان سیستم قرار دهید تا  سیستم از روی آن Boot شود.(برای تنظیم کردن Boot از روی درایودیسک خوان ممکن است باید وارد BIOS سیستم شوید)

بعد از Boot شدن از روی DVD فدورا با همچین صفحه ای روبرو خواهید شد که برای شروع نصب دکمه Enter را فشار دهید :

boot dvd

boot dvd

  • ehsan gholami

این روز ها مجازی سازی و کار با سیستم عامل های مختلف به صورت مجازی بسیار مورد توجه قرار گرفته است و یکی از ابزار های آن vmware می باشد که با آن میتوانید یکی از سیستم عامل های متن باز مانند لینوکس یا یک هر سیستم عامل دیگری را در کنار ویندوز خود نصب کنید در اینجا آموزش تصویری این کار را با هم خواهیم دید . سوالات و نظرات خود را با ما به اشتراک بگذارید .

در صورتی که این برنامه را ندارید میتوانید از این لینک سایت سافت 98 یا از سایت های دیگر دانلود کنید 

آموزش vmware

  • ehsan gholami

اگر شما هم جزو لینوکس کاران باشید میدانید راهای زیادی برای انتقال اطلاعات بین دو کامپیوتر وجود دارد و راهای بسیار جالبی که در ویندوز از آنها محرومیم خوب یکی از روش های که من به آن علاقه مندم rsync است . این برنامه کوچک لینوکسی قابلیت های زیادی به شما میدهد برای مثال شما میتوانید حجم زیادی از اطلاعات را با سرعت بالا منتقل کنید . پشتیبانی این برنامه از فایل های sparse هم قابل توجه است این فایل ها فایل هایی هستند که اگر شما برای مثال یک ماشین مجازی داشته باشید و در آن ماشین مجازی یک سیستم عامل نصب کرده باشید و حجم دیسک را 100 گیگ انتخاب کرده باشید ولی سیستم عامل شما در حقیقت 3 گیگ جا اشغال کرده باشد در صورت نیاز به انتقال با برنامه های عادی شما نیاز به 100 گیگ فضا داردید اما این برنامه میتواند حجم واقی را از مجازی تشخیص دهد . شما نیاز به 

آموزش کاربردی Rsync
نگارش یافته توسط علی رضا حبیبی   
Rsync  یک برنامه ساده  و کوچک، همانند یک برنامه انتقال فایل می باشد، آخرین نسخه ای که در زمان نوشتن این مقاله وجود دارد نسخه  3.0.4 می باشد که می توانید از سایت رسمی آن با آدرس http://samba.anu.edu.au/rsync   دریافت کنید.
با این برنامه حتی می توان فقط تغییراتی که بر روی یک فایل  انجام شده را انتقال داد ، در نظر بگیرید که شما سروری دارید که مدام مجبورید اطلاعات آن را با سرور دیگر بروز رسانی کنید، برای این کار لازم نیست هر بار اطلاعات مورد نظر را تماما انتقال دهید ، با کمک Rsync  می توان فقط فایل هایی را که در کامپیوتر مبدا و یا مقصد تغییر کرده اند، انتقال داد. این کار فواید بسیاری از جمله ، آپلود سریع تر و کم تر شدن ترافیک شبکه و صرفه جویی در پهنای باند مصرفی  را  بدنبال خواهد داشت.

در واقع  Rsync  یک برنامه چند منظوره است که کارهای Backup  & Mirroring   را برای شما انجام خواهد داد.

بعضی امکانات Rsync   عبارت اند از :
  • پشتیبانی از حفظ اطلاعات فایل منتقل شده ، همانند مالک فایل ، گروه فایل ، مجوز های فایل و ...
  • عدم نیاز به مجوز کاربر ریشه
  • ترانسپرنت شدن با پروتکل هایی نظیر ssh  ، rsh
  • قابلیت استفاده بصورت anonymous  یا authenticated

برای شروع ابتدا مطمئن شوید که برنامه مورد نظر در سیستم شما نصب میباشد من از CentOS 5.2 استفاده می کنم کلیه دستوران نوشته شده در این مقاله هم بر اساس همین توزیع می باشد.

برای این کار می توانید دستور rsync را اجرا کنید و یا خروجی دستور زیر را ببینید :
#rpm  -q  rysnc
و خروجی بمانند زیر خواهد بود :
[root@centos-test ~]# rpm -q rsync
rsync-3.0.4-1.el5.rf
[root@centos-test ~]#

در صورتی که برنامه در سیستم شما نصب نبود از دستور زیر استفاده کنید :
#yum install rsync

در دیگر توزیع ها همانند fedora , redhat , debian  هماند بالا میباشد با این تفاوت که در debian می بایست از apt-get  استفاده نمایید .
برای راه اندازی شما باید Rsync  را بصورت Daemon   راه اندازی کنید این کار با استفاده از دستور  rsync –daemon   در کنسول انجام خواهد شد، فایل پیکربندی آن بصورت پیشفرض در آدرس  etc/rsyncd.conf/  قرار دارد و با کمک Vi  می توانید آن را ویرایش کنید. تمام دستگاهایی که برنامه Rsync  را اجرا کنند می توانند با دستگاهی که  در آن Rsync Daemon  راه اندازی شده است همزمان شودند.
برای این کار شما باید یک دستگاه را که قرار است نقش سرور را بازی کند بصورت Daemon  راه اندازی کنید همچنین کلاینت ها نیز می توانند برای بر قراری یک ارتباط دو طرفه در حالت daemon  راه اندازی شوند.
در زیر بعضی از فایل های پیکربندی Rsync  را مشاهده می کنید

motd file = /etc/rsyncd.motd
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock

[simple_path_name]
path = /rsync_files_here
comment = My Very Own Rsync Server
uid = nobody
gid = nobody
read only = no
list = yes
auth users = username
secrets file = /etc/rsyncd.scrt



  • هر گاه شما بخواهید پیامی را به کاربران خود نمایش بدهید می توانید از فایل etc/rsyncd.motd/   استفاده کنید.
  • فایل بعدی فایلی است که لاگ های مربوط به Rsync  در آن ریخته خواهد شد.
  • دو فایل بعدی برای شماره پردازش Rsync  و قفل کردن آن می باشد.
  • در فایل پیکربندی گزینه Path  مسیری را که فایل ها به/ از آن همزمان خواهند شد را نشان می دهد,
  • Comment مختصری توضیح راجع به مسیر داده شده خواهد بود،
  • Uid &Gid  نام کاربری و گروهی که Rsync  با ان اجرا خواهد شد را نشان می دهد،
  • اگر شما بخواهید دسترسی را به یوزری که از قبل تعریف شده محدود کنید می توانید Auth Users  را برای آن مشخص کنید که این کار با فایلSecret  که بصورتplaintext   نوشته می شود و با فرمت Key/value  که نشان دهنده نام کاربری و رمز عبور است، انجام می شود.
rsync remote-update  یک پروتکل برای Rsync  می باشد که تنها  تغییرات صورت گرفته را بین دو ماشین منتقل می کند.
دو راه برای اتصال rsync  برای انتقال فایل وجود دارد ، یک راه استفاده از  برنامه های remote-shell  مانند ssh   بعنوان انتقال است و راه دیگر اتصال به daemon  برنامه Rsync  توسط پروتکل tcp  می باشد.
انتقال با remote-shell  هر زمانی که  مسیر های منبع و مقصد  محتوی  تنها یک کالن ( : ) بعد از مشخص کردن میزبان باشند استفاده میشود ،  اتصال به daemon  برنامه Rsync   تنها زمانی که مسیر های منبع و مقصد محتوی دو کالن  ( :: ) بعد از مشخص کردن میزبان  باشند و یا بکار بردن عبارت //:rsync  استفاده میشود


استفاده از Rsync  :

شما می توانید  با مشخص کردن مبدا و مقصد به راحتی از این برنامه استفاده کنید برای مثال :
rsync  -t *.c foo:src/
شاید این کلی ترین دستور برای  rsync   باشد ، در این دستور تمامی پترن های  شامل c.*  به سیستمی با نام foo ، و به دایرکتری src  انتقال پیدا می کند , اگر فایلی با نام مشابه در دایرکتری مقصد وجود داشته باشد ، rsync remote-update protocol برای بروز رسانی آن فایل ها تنها با فرستادن تغییرات شروع به کار می کند

rsync -avz foo:src/bar  /data/tmp

این دستور بصورت recursive  تمامی فایل های دایرکتری  src/bar را  در ماشین foo   به دایرکتری   data/tmp  در ماشین فعلی کپی می کند. فایل ها در حالت آرشیو منتقل می شوند که این کار باعث می شود تمامی مجوز ها و اطلاعات فایل در حین انتقال حفظ شود.
همچنین فشرده سازی باعث کاهش حجم فایل در حین انتقال خواهد شد.


در آخر هم سعی می کنیم یک مثال پیچیده را با هم بررسی کنیم

rsync --verbose  --progress --stats --compress --rsh=/usr/local/bin/ssh --recursive --times --perms --links --delete /www/* webserver:simple_path_name

خوب این دستور rsync   را با گزینه های verbose , progress , stats  راه اندازی می کند
گزینه Compress برای فشرده سازی اطلاعات و گزینه rsh  برای انتقال اصلاعات بصورت امن از طریق ssh  خواهد بود، خط بعد مشخص می کند که Rsync  چطور با فایل های  رفتار کند:
Recursive  به آن  می گوید که فایل ها و دایرکتری ها را بصورت recursive  انتقال دهد و اطلاعات زمان و مجوز ها را با دو عبارت times  و perms  انتقال دهد همچنین عبارت links نشان دهنده  کپی کردن symbolic ها و عبارت Delete  نشان دهنده پاک کردن دایرکتری و فایل ها در دایرکتری مقصد که در سیستم فعلی حذف شده اند می باشد */www/ فایل هایی از سیستم من که قرار است توسط Rsync  انتقال داده شوند را نشان می دهد و webserver:simple_path_name آدرس کامپیوتر مقصد خواهد بود.
با اجرای دستور فوق تمامی فایل های شاخه www  من به کامپیوتر webserver   با حفظ تمامی مجوز ها و اطلاعات ، انتقال پیدا خواهد کرد.

If the host computer is not running SSH (or RSH), we can configure and run rsync as a daemon in this computer. This would have rsync listening to the port 873 for incoming connections from other computers utilizing rsync. While this is not recommended for the transfer of files across unsecured networks, such as the Internet, because the actual data transfer is not encrypted, we can use this to keep information synchronized between different computers in internal networks, as well as perform backups.

There are two different approaches to have rsync running as a daemon, one is to launch the program with the --daemon parameter, and the other is to have inetd or xinetd to launchrsync and have it running as the other services that inetd and xinetd handles. But first, we must configure the file /etc/rsyncd.conf and create a file named rsyncd.secrets in /etc with the different usernames and passwords that will be allowed to connect to the rsync daemon.

As an example I am going to make available a folder called Documents inside my home folder (/home/juan) and show how to use a command to copy a directory from a different computer. All the uses that were covered in the post Synchronizing folders with rsync can be done with the rsync daemon, the only thing that changes is the addressing of either the source folder or the destination folder, whichever is the one that resides remotely.

Topics
Configuring rsyncd.conf
Creating the secrets file
Launching rsync with the --daemon attribute
Using inetd to handle the rsync daemon
Using xinetd to handle the rsync daemon
Connecting to the rsync daemon

Configuring rsyncd.conf

This file is located in the directory /etc, if it doesn't already exists, we need to create it there. We open the file in our preferred text editor, I am going to use gedit for the examples but we can use any editor such as kate in KDE, nano in a terminal, Vim, etc.

sudo gedit /etc/rsyncd.conf

In this file we add the following lines:

lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid

[documents]
    path = /home/juan/Documents
    comment = The documents folder of Juan
    uid = juan
    gid = juan
    read only = no
    list = yes
    auth users = rsyncclient
    secrets file = /etc/rsyncd.secrets
    hosts allow = 192.168.1.0/255.255.255.0

We can divide this file in two sections, the global parameters and the modules section. The global parameters define the overall behavior of rsync. Besides the three parameters that I use here and which I explain below, we can also configure things such as the port rsync will listen too, but we are going to go with the default 873.

  • lock file is the file that rsync uses to handle the maximum number of connections
  • log file is where rsync will save any information about it's activity; when it started running, when and from where does other computers connect, and any errors it encounters.
  • pid file is where the rsync daemon will write the process id that has been assigned to it, this is useful because we can use this process id to stop the daemon.

After the global parameters, we have the modules section, every module is a folder that we share with rsync, the important parts here are:

  • [name] is the name that we assign to the module. Each module exports a directory tree. The module name can not contain slashes or a closing square bracket.
  • path is the path of the folder that we are making available with rsync
  • comment is a comment that appears next to the module name when a client obtain the list of all available modules
  • uid When the rsync daemon is run as root, we can specify which user owns the files that are transfer from and to.
  • gid This allows us to set the group that own the files that are transferred if the daemon is run as root
  • read only determines if the clients who connect to rsync can upload files or not, the default of this parameter is true for all modules.
  • list allows the module to be listed when clients ask for a list of available modules, setting this to false hides the module from the listing.
  • auth users is a list of users allowed to access the content of this module, the users are separated by comas. The users don't need to exist in the system, they are defined by the secrets file.
  • secrets file defines the file that contains the usernames and passwords of the valid users for rsync
  • hosts allow are the addresses allowed to connect to the system. Without this parameter all hosts are allowed to connect.

Creating the secrets file

Once rsyncd.conf is properly set, we need to create the secrets file. This file contains all of the usernames and passwords that will be able to log in to the rsync daemon, this usernames and passwords are independent of the user that exist in the system, so we can create users whom already exist in the system without problems. As we specified the file/etc/rsyncd.secrets in rsyncd.conf, we will create and edit this file it in our favorite text editor:

sudo gedit /etc/rsyncd.secrets

In this file we add the usernames and the passwords, one per line, separated by a colon (I don't actually use passwords that are this simple, and you shouldn't either):

rsyncclient:passWord
juan:PassWord
backup:Password
user:password

Finally, change the permission of this file so it can't be read or modified by other users, rsyncwill fail if the permissions of this file are not appropriately set:

sudo chmod 600 /etc/rsyncd.secrets

Launching rsync with the --daemon attribute

Once everything is set, one of the ways to use rsync as a daemon is launching it with the --daemon parameter, if you followed the previous instructions you can simply use this command:

sudo rsync --daemon

We can check if it is running by seeing the log file that we defined in rsyncd.conf, in our example this is located in /var/log/rsyncd.log. Additionally, if the daemon is running, the file/var/run/rsyncd.pid will contain the process ID of rsync.

If we launched rsync in this manner, we can stop it by killing its process. We can obtaining the process ID by reading the contents of the file /var/run/rsyncd.pid and then invoke kill with this process ID. We can pass it directly to kill using:

sudo kill `cat /var/run/rsyncd.pid`

Using inetd to handle the rsync daemon

inetd, the InterNET Daemon, can handle all the services associated with Internet, such as FTP, telnet, and e-mail. While inetd is still used, due to security concerns it is being replaced by other more modern alternatives, a very popular one is xinetd (eXtended InterNET Daemon). Since the rsync daemon works using an Internet connection, we can add it to inetd or xinetdand allow either of them to handle it.

To enable rsync in inetd, we need to open the file /etc/inetd.conf in our favorite text editor and add the following line to it, assuming rsync is in /usr/bin as it should be in Linux distributions:

sudo gedit /etc/inetd.conf

Then add the following line:

rsync stream tcp nowait root /usr/bin/rsync rsync --daemon

When using inetd we need to get sure that the port 873 is appropriately mapped to rsync in the file /etc/services, by default it must be, we can check using:

cat /etc/services | grep rsync

It should show us this:

rsync 873/tcp

If you don't see this, then open the file /etc/services in a text editor and add that line.

Finally, restart the inetd daemon:

killall -1 inetd

Using xinetd to handle the rsync daemon

xinetd, the eXtended InterNET daemon, is a widely adopted replacement for inetd, as inetddoesn't offer security mechanisms. The handling of services is different from inetdxinetd may already have an entry for rsync that just needs to be enabled, the rsync configuration resides in the file /etc/xinetd.d/rsync, open this file in your text editor:

sudo gedit /etc/xinetd.d/rsync

and change the line disable = yes to disable = no.

If this file doesn't already exist, you can create it and edit it:

sudo gedit /etc/xinetd.d/rsync

And add the following lines to it:

service rsync
{
    disable         = no
    socket_type     = stream
    port            = 873
    protocol        = tcp
    wait            = no
    user            = root
    server          = /usr/bin/rsync
    server_args     = --daemon
    log_on_failure  += USERID
}

Unlike inetdxinetd doesn't need to have an entry in /etc/services, it can handle the port/protocol by itself. If rsync is defined in /etc/services, the lines port and protocol can be omitted. And now restart the xinetd daemon:

killall -1 xinetd

Connecting to the rsync daemon

To connect to rsync when it is running as a Daemon, instead of use a colon as we do when using SSH, we need to use a double colon, followed by the module name, and the file or folder that we want to copy or synchronize, we can use:

rsync -rtv user@host::module/source/ destination/

Another way to access the file would be using rsync:// followed by the host's address, the module, and finally the location of file or folder that we want to access:

rsync -rtv rsync://user@host/module/source/ destination/

For example, taking the parameters given in the example of rsyncd.conf that I posted, a way to transfer a folder called "source" inside the folder /home/juan/Documents of the host computer, would be using any of this two parameters, assuming the host is located at192.168.1.100

rsync -rtv juan@192.168.1.100::documents/source/ destination/
rsync -rtv rsync://juan@192.168.1.100/documents/source/ destination/

Just remember that the user that appears there is one of the users that we defined in/etc/rsyncd.secrets and not a user of the host computer.

  • ehsan gholami